forked from PowerDNS/pdns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
476 lines (433 loc) · 17.5 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
from invoke import task
from invoke.exceptions import Failure, UnexpectedExit
import os
import sys
import time
all_build_deps = [
'ccache',
'libboost-all-dev',
'libluajit-5.1-dev',
'libsodium-dev',
'libssl-dev',
'libsystemd-dev',
'libtool',
'make',
'pkg-config',
'python3-venv',
'systemd',
]
git_build_deps = [
'autoconf',
'automake',
'bison',
'bzip2',
'curl',
'flex',
'git',
'ragel'
]
auth_build_deps = [ # FIXME: perhaps we should be stealing these from the debian (Ubuntu) control file
'default-libmysqlclient-dev',
'libcdb-dev',
'libcurl4-openssl-dev',
'libgeoip-dev',
'libkrb5-dev',
'libldap2-dev',
'liblmdb-dev',
'libmaxminddb-dev',
'libp11-kit-dev',
'libpq-dev',
'libsqlite3-dev',
'libyaml-cpp-dev',
'libzmq3-dev',
'ruby-bundler',
'ruby-dev',
'sqlite3',
]
rec_build_deps = [
'libcap-dev',
'libfstrm-dev',
'libsnmp-dev',
]
rec_bulk_deps = [
'curl',
'libboost-all-dev',
'libcap2',
'libfstrm0',
'libluajit-5.1-2',
'libsnmp35',
'libsodium23',
'libssl1.1',
'libsystemd0',
'moreutils',
'pdns-tools',
'unzip'
]
dnsdist_build_deps = [
'libcap-dev',
'libcdb-dev',
'libedit-dev',
'libfstrm-dev',
'libgnutls28-dev',
'libh2o-evloop-dev',
'liblmdb-dev',
'libnghttp2-dev',
'libre2-dev',
'libsnmp-dev',
]
auth_test_deps = [ # FIXME: we should be generating some of these from shlibdeps in build
'authbind',
'bc',
'bind9utils',
'curl',
'default-jre-headless',
'dnsutils',
'faketime',
'gawk',
'ldnsutils',
'libboost-serialization1.71.0',
'libcdb1',
'libcurl4',
'libgeoip1',
'libkrb5-3',
'libldap-2.4-2',
'liblmdb0',
'libluajit-5.1-2',
'libmaxminddb0',
'libnet-dns-perl',
'libp11-kit0',
'libpq5',
'libsodium23',
'libsqlite3-dev',
'libssl1.1',
'libsystemd0',
'libyaml-cpp0.6',
'libzmq3-dev',
'ruby-bundler',
'ruby-dev',
'socat',
'softhsm2',
'unbound-host',
'unixodbc',
'wget'
]
@task
def apt_fresh(c):
c.sudo('apt-get update')
c.sudo('apt-get dist-upgrade')
@task
def install_clang(c):
"""
install clang-12 and llvm-12
"""
c.sudo('apt-get -qq -y --no-install-recommends install clang-12 llvm-12')
@task
def install_clang_runtime(c):
# this gives us the symbolizer, for symbols in asan/ubsan traces
c.sudo('apt-get -qq -y --no-install-recommends install clang-12')
@task
def install_auth_build_deps(c):
c.sudo('apt-get install -qq -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + auth_build_deps))
def setup_authbind(c):
c.sudo('touch /etc/authbind/byport/53')
c.sudo('chmod 755 /etc/authbind/byport/53')
auth_backend_test_deps = dict(
gsqlite3=['sqlite3'],
gmysql=['default-libmysqlclient-dev'],
gpgsql=['libpq-dev'],
lmdb=[],
remote=[],
bind=[],
geoip=[],
lua2=[],
tinydns=[],
authpy=[]
)
@task(help={'backend': 'Backend to install test deps for, e.g. gsqlite3; can be repeated'}, iterable=['backend'], optional=['backend'])
def install_auth_test_deps(c, backend): # FIXME: rename this, we do way more than apt-get
extra=[]
for b in backend:
extra.extend(auth_backend_test_deps[b])
c.sudo('apt-get -y -qq install ' + ' '.join(extra+auth_test_deps))
c.run('chmod +x /opt/pdns-auth/bin/* /opt/pdns-auth/sbin/*')
# c.run('''if [ ! -e $HOME/bin/jdnssec-verifyzone ]; then
# wget https://github.com/dblacka/jdnssec-tools/releases/download/0.14/jdnssec-tools-0.14.tar.gz
# tar xfz jdnssec-tools-0.14.tar.gz -C $HOME
# rm jdnssec-tools-0.14.tar.gz
# fi
# echo 'export PATH=$HOME/jdnssec-tools-0.14/bin:$PATH' >> $BASH_ENV''') # FIXME: why did this fail with no error?
c.run('touch regression-tests/tests/verify-dnssec-zone/allow-missing regression-tests.nobackend/rectify-axfr/allow-missing') # FIXME: can this go?
# FIXME we may want to start a background recursor here to make ALIAS tests more robust
setup_authbind(c)
@task
def install_rec_bulk_deps(c): # FIXME: rename this, we do way more than apt-get
c.sudo('apt-get --no-install-recommends -qq -y install ' + ' '.join(rec_bulk_deps))
c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
@task
def install_rec_test_deps(c): # FIXME: rename this, we do way more than apt-get
c.sudo('apt-get --no-install-recommends install -qq -y ' + ' '.join(rec_bulk_deps) + ' \
pdns-server pdns-backend-bind daemontools \
jq libfaketime lua-posix lua-socket bc authbind \
python3-venv python3-dev default-libmysqlclient-dev libpq-dev \
protobuf-compiler snmpd prometheus')
c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
setup_authbind(c)
c.run('sed "s/agentxperms 0700 0755 recursor/agentxperms 0777 0755/g" regression-tests.recursor-dnssec/snmpd.conf | sudo tee /etc/snmp/snmpd.conf')
c.sudo('systemctl restart snmpd')
time.sleep(5)
c.sudo('chmod 755 /var/agentx')
@task
def install_dnsdist_test_deps(c): # FIXME: rename this, we do way more than apt-get
c.sudo('apt-get install -qq -y \
libluajit-5.1-2 \
libboost-all-dev \
libcap2 \
libcdb1 \
libcurl4-openssl-dev \
libfstrm0 \
libgnutls30 \
libh2o-evloop0.13 \
liblmdb0 \
libnghttp2-14 \
libre2-5 \
libssl-dev \
libsystemd0 \
libsodium23 \
patch \
protobuf-compiler \
python3-venv snmpd prometheus')
c.run('sed "s/agentxperms 0700 0755 dnsdist/agentxperms 0777 0755/g" regression-tests.dnsdist/snmpd.conf | sudo tee /etc/snmp/snmpd.conf')
c.sudo('systemctl restart snmpd')
time.sleep(5)
c.sudo('chmod 755 /var/agentx')
@task
def install_rec_build_deps(c):
c.sudo('apt-get install -qq -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + rec_build_deps))
@task
def install_dnsdist_build_deps(c):
c.sudo('apt-get install -qq -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + dnsdist_build_deps))
@task
def ci_autoconf(c):
c.run('BUILDER_VERSION=0.0.0-git1 autoreconf -vfi')
@task
def ci_auth_configure(c):
res = c.run('''CFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int" \
CXXFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int -Wp,-D_GLIBCXX_ASSERTIONS" \
./configure \
CC='clang-12' \
CXX='clang++-12' \
--enable-option-checking=fatal \
--with-modules='bind geoip gmysql godbc gpgsql gsqlite3 ldap lmdb lua2 pipe remote tinydns' \
--enable-systemd \
--enable-tools \
--enable-unit-tests \
--enable-backend-unit-tests \
--enable-fuzz-targets \
--enable-experimental-pkcs11 \
--enable-remotebackend-zeromq \
--with-lmdb=/usr \
--with-libsodium \
--prefix=/opt/pdns-auth \
--enable-ixfrdist \
--enable-asan \
--enable-ubsan''', warn=True)
if res.exited != 0:
c.run('cat config.log')
raise UnexpectedExit(res)
@task
def ci_rec_configure(c):
sanitizers = ' '.join('--enable-'+x for x in os.getenv('SANITIZERS').split('+'))
res = c.run(''' CFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int" \
CXXFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int -Wp,-D_GLIBCXX_ASSERTIONS" \
./configure \
CC='clang-12' \
CXX='clang++-12' \
--enable-option-checking=fatal \
--enable-unit-tests \
--enable-nod \
--enable-systemd \
--prefix=/opt/pdns-recursor \
--with-libsodium \
--with-lua=luajit \
--with-libcap \
--with-net-snmp \
--enable-dns-over-tls ''' + sanitizers, warn=True)
if res.exited != 0:
c.run('cat config.log')
raise UnexpectedExit(res)
@task
def ci_dnsdist_configure(c):
sanitizers = ' '.join('--enable-'+x for x in os.getenv('SANITIZERS').split('+'))
res = c.run('''CFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int" \
CXXFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int -Wp,-D_GLIBCXX_ASSERTIONS" \
./configure \
CC='clang-12' \
CXX='clang++-12' \
--enable-option-checking=fatal \
--enable-unit-tests \
--enable-dnstap \
--enable-dnscrypt \
--enable-dns-over-tls \
--enable-dns-over-https \
--enable-systemd \
--prefix=/opt/dnsdist \
--with-gnutls \
--with-libsodium \
--with-lua=luajit \
--with-libcap \
--with-nghttp2 \
--with-re2 ''' + sanitizers, warn=True)
if res.exited != 0:
c.run('cat config.log')
raise UnexpectedExit(res)
@task
def ci_auth_make(c):
c.run('make -j8 -k V=1')
@task
def ci_rec_make(c):
c.run('make -j8 -k V=1')
@task
def ci_dnsdist_make(c):
c.run('make -j4 -k V=1')
@task
def ci_auth_install_remotebackend_ruby_deps(c):
with c.cd('modules/remotebackend'):
# c.run('bundle config set path vendor/bundle')
c.run('sudo ruby -S bundle install')
@task
def ci_auth_run_unit_tests(c):
res = c.run('make check', warn=True)
if res.exited != 0:
c.run('cat pdns/test-suite.log', warn=True)
c.run('cat modules/remotebackend/test-suite.log', warn=True)
raise UnexpectedExit(res)
@task
def ci_rec_run_unit_tests(c):
res = c.run('make check', warn=True)
if res.exited != 0:
c.run('cat test-suite.log')
raise UnexpectedExit(res)
@task
def ci_dnsdist_run_unit_tests(c):
res = c.run('make check', warn=True)
if res.exited != 0:
c.run('cat test-suite.log')
raise UnexpectedExit(res)
@task
def ci_make_install(c):
res = c.run('make install') # FIXME: this builds auth docs - again
@task
def add_auth_repo(c):
dist = 'ubuntu' # FIXME take these from the caller?
release = 'focal'
version = '44'
c.sudo('apt-get install -qq -y curl gnupg2')
if version == 'master':
c.sudo('curl -s -o /etc/apt/trusted.gpg.d/pdns-repo.asc https://repo.powerdns.com/CBC8B383-pub.asc')
else:
c.sudo('curl -s -o /etc/apt/trusted.gpg.d/pdns-repo.asc https://repo.powerdns.com/FD380FBB-pub.asc')
c.run(f"echo 'deb [arch=amd64] http://repo.powerdns.com/{dist} {release}-auth-{version} main' | sudo tee /etc/apt/sources.list.d/pdns.list")
c.run("echo 'Package: pdns-*' | sudo tee /etc/apt/preferences.d/pdns")
c.run("echo 'Pin: origin repo.powerdns.com' | sudo tee -a /etc/apt/preferences.d/pdns")
c.run("echo 'Pin-Priority: 600' | sudo tee -a /etc/apt/preferences.d/pdns")
c.sudo('apt-get update')
@task
def test_api(c, product, backend=''):
if product == 'recursor':
with c.cd('regression-tests.api'):
c.run(f'PDNSRECURSOR=/opt/pdns-recursor/sbin/pdns_recursor ./runtests recursor {backend}')
elif product == 'auth':
with c.cd('regression-tests.api'):
c.run(f'PDNSSERVER=/opt/pdns-auth/sbin/pdns_server PDNSUTIL=/opt/pdns-auth/bin/pdnsutil SDIG=/opt/pdns-auth/bin/sdig MYSQL_HOST="127.0.0.1" PGHOST="127.0.0.1" PGPORT="5432" ./runtests authoritative {backend}')
else:
raise Failure('unknown product')
backend_regress_tests = dict(
bind = [
'bind-both',
'bind-dnssec-both',
'bind-dnssec-nsec3-both',
'bind-dnssec-nsec3-optout-both',
'bind-dnssec-nsec3-narrow',
# FIXME 'bind-dnssec-pkcs11'
],
geoip = [
'geoip',
'geoip-nsec3-narrow'
# FIXME: also run this with the mmdb we ship
],
lua2 = [
'lua2',
'lua2-dnssec'
],
tinydns = [
'tinydns'
],
remote = [
'remotebackend-pipe',
'remotebackend-unix',
'remotebackend-http',
'remotebackend-zeromq',
'remotebackend-pipe-dnssec',
'remotebackend-unix-dnssec',
'remotebackend-http-dnssec',
'remotebackend-zeromq-dnssec'
],
lmdb = [
'lmdb-nodnssec-both',
'lmdb-both',
'lmdb-nsec3-both',
'lmdb-nsec3-optout-both',
'lmdb-nsec3-narrow'
],
gmysql = ['gmysql', 'gmysql-nodnssec-both', 'gmysql-nsec3-both', 'gmysql-nsec3-optout-both', 'gmysql-nsec3-narrow', 'gmysql_sp-both'],
gpgsql = ['gpgsql', 'gpgsql-nodnssec-both', 'gpgsql-nsec3-both', 'gpgsql-nsec3-optout-both', 'gpgsql-nsec3-narrow', 'gpgsql_sp-both'],
gsqlite3 = ['gsqlite3', 'gsqlite3-nodnssec-both', 'gsqlite3-nsec3-both', 'gsqlite3-nsec3-optout-both', 'gsqlite3-nsec3-narrow'],
)
@task
def test_auth_backend(c, backend):
if backend == 'remote':
ci_auth_install_remotebackend_ruby_deps(c)
if backend == 'authpy':
with c.cd('regression-tests.auth-py'):
c.run(f'PDNS=/opt/pdns-auth/sbin/pdns_server PDNS2=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig NOTIFY=/opt/pdns-auth/bin/pdns_notify NSEC3DIG=/opt/pdns-auth/bin/nsec3dig SAXFR=/opt/pdns-auth/bin/saxfr ZONE2SQL=/opt/pdns-auth/bin/zone2sql ZONE2LDAP=/opt/pdns-auth/bin/zone2ldap ZONE2JSON=/opt/pdns-auth/bin/zone2json PDNSUTIL=/opt/pdns-auth/bin/pdnsutil PDNSCONTROL=/opt/pdns-auth/bin/pdns_control PDNSSERVER=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig GMYSQLHOST=127.0.0.1 GMYSQL2HOST=127.0.0.1 MYSQL_HOST="127.0.0.1" PGHOST="127.0.0.1" PGPORT="5432" ./runtests')
return
with c.cd('regression-tests'):
if backend == 'lua2':
c.run('touch trustedkeys') # avoid silly error during cleanup
for variant in backend_regress_tests[backend]:
# FIXME this long line is terrible
c.run(f'PDNS=/opt/pdns-auth/sbin/pdns_server PDNS2=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig NOTIFY=/opt/pdns-auth/bin/pdns_notify NSEC3DIG=/opt/pdns-auth/bin/nsec3dig SAXFR=/opt/pdns-auth/bin/saxfr ZONE2SQL=/opt/pdns-auth/bin/zone2sql ZONE2LDAP=/opt/pdns-auth/bin/zone2ldap ZONE2JSON=/opt/pdns-auth/bin/zone2json PDNSUTIL=/opt/pdns-auth/bin/pdnsutil PDNSCONTROL=/opt/pdns-auth/bin/pdns_control PDNSSERVER=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig GMYSQLHOST=127.0.0.1 GMYSQL2HOST=127.0.0.1 MYSQL_HOST="127.0.0.1" PGHOST="127.0.0.1" PGPORT="5432" ./start-test-stop 5300 {variant}')
if backend == 'gsqlite3':
with c.cd('regression-tests.nobackend'):
c.run(f'PDNS=/opt/pdns-auth/sbin/pdns_server PDNS2=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig NOTIFY=/opt/pdns-auth/bin/pdns_notify NSEC3DIG=/opt/pdns-auth/bin/nsec3dig SAXFR=/opt/pdns-auth/bin/saxfr ZONE2SQL=/opt/pdns-auth/bin/zone2sql ZONE2LDAP=/opt/pdns-auth/bin/zone2ldap ZONE2JSON=/opt/pdns-auth/bin/zone2json PDNSUTIL=/opt/pdns-auth/bin/pdnsutil PDNSCONTROL=/opt/pdns-auth/bin/pdns_control PDNSSERVER=/opt/pdns-auth/sbin/pdns_server SDIG=/opt/pdns-auth/bin/sdig GMYSQLHOST=127.0.0.1 GMYSQL2HOST=127.0.0.1 MYSQL_HOST="127.0.0.1" PGHOST="127.0.0.1" PGPORT="5432" ./runtests')
c.run('/opt/pdns-auth/bin/pdnsutil test-algorithms')
return
@task
def test_ixfrdist(c):
with c.cd('regression-tests.ixfrdist'):
c.run('IXFRDISTBIN=/opt/pdns-auth/bin/ixfrdist ./runtests')
@task
def test_dnsdist(c):
c.run('chmod +x /opt/dnsdist/bin/*')
c.run('ls -ald /var /var/agentx /var/agentx/master')
c.run('ls -al /var/agentx/master')
with c.cd('regression-tests.dnsdist'):
c.run('DNSDISTBIN=/opt/dnsdist/bin/dnsdist ./runtests')
@task
def test_regression_recursor(c):
c.run('/opt/pdns-recursor/sbin/pdns_recursor --version')
c.run('PDNSRECURSOR=/opt/pdns-recursor/sbin/pdns_recursor RECCONTROL=/opt/pdns-recursor/bin/rec_control SKIP_IPV6_TESTS=y LIBFAKETIME=/bin/false ./build-scripts/test-recursor test_RecDnstap.py')
c.run('PDNSRECURSOR=/opt/pdns-recursor/sbin/pdns_recursor RECCONTROL=/opt/pdns-recursor/bin/rec_control SKIP_IPV6_TESTS=y ./build-scripts/test-recursor -I test_RecDnstap.py')
@task
def test_bulk_recursor(c, threads, mthreads, shards):
# We run an extremely small version of the bulk test, as GH does not seem to be able to handle the UDP load
with c.cd('regression-tests'):
c.run('curl -LO http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip')
c.run('unzip top-1m.csv.zip -d .')
c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
c.run(f'DNSBULKTEST=/usr/bin/dnsbulktest RECURSOR=/opt/pdns-recursor/sbin/pdns_recursor RECCONTROL=/opt/pdns-recursor/bin/rec_control THRESHOLD=95 TRACE=no ./timestamp ./recursor-test 5300 100 {threads} {mthreads} {shards}')
# this is run always
def setup():
if '/usr/lib/ccache' not in os.environ['PATH']:
os.environ['PATH']='/usr/lib/ccache:'+os.environ['PATH']
setup()