]> git.ipfire.org Git - thirdparty/pdns.git/blob - tasks.py
Merge pull request #12793 from omoerbeek/assorted-delint
[thirdparty/pdns.git] / tasks.py
1 from invoke import task
2 from invoke.exceptions import Failure, UnexpectedExit
3
4 import os
5 import sys
6 import time
7
8 auth_backend_ip_addr = os.getenv('AUTH_BACKEND_IP_ADDR', '127.0.0.1')
9
10 clang_version = os.getenv('CLANG_VERSION', '13')
11
12 all_build_deps = [
13 'ccache',
14 'libboost-all-dev',
15 'libluajit-5.1-dev',
16 'libsodium-dev',
17 'libssl-dev',
18 'libsystemd-dev',
19 'libtool',
20 'make',
21 'pkg-config',
22 'python3-venv',
23 'systemd',
24 ]
25 git_build_deps = [
26 'autoconf',
27 'automake',
28 'bison',
29 'bzip2',
30 'curl',
31 'flex',
32 'git',
33 'ragel'
34 ]
35 auth_build_deps = [ # FIXME: perhaps we should be stealing these from the debian (Ubuntu) control file
36 'default-libmysqlclient-dev',
37 'libcdb-dev',
38 'libcurl4-openssl-dev',
39 'libgeoip-dev',
40 'libkrb5-dev',
41 'libldap2-dev',
42 'liblmdb-dev',
43 'libmaxminddb-dev',
44 'libp11-kit-dev',
45 'libpq-dev',
46 'libsqlite3-dev',
47 'libyaml-cpp-dev',
48 'libzmq3-dev',
49 'ruby-bundler',
50 'ruby-dev',
51 'sqlite3',
52 'unixodbc-dev',
53 'cmake',
54 ]
55 rec_build_deps = [
56 'libcap-dev',
57 'libfstrm-dev',
58 'libsnmp-dev',
59 ]
60 rec_bulk_deps = [
61 'curl',
62 'libboost-all-dev',
63 'libcap2',
64 'libfstrm0',
65 'libluajit-5.1-2',
66 '"libsnmp[1-9]+"',
67 'libsodium23',
68 'libssl1.1',
69 'libsystemd0',
70 'moreutils',
71 'pdns-tools',
72 'unzip',
73 ]
74 dnsdist_build_deps = [
75 'libcap-dev',
76 'libcdb-dev',
77 'libedit-dev',
78 'libfstrm-dev',
79 'libgnutls28-dev',
80 'libh2o-evloop-dev',
81 'liblmdb-dev',
82 'libnghttp2-dev',
83 'libre2-dev',
84 'libsnmp-dev',
85 ]
86 auth_test_deps = [ # FIXME: we should be generating some of these from shlibdeps in build
87 'authbind',
88 'bc',
89 'bind9utils',
90 'curl',
91 'default-jre-headless',
92 'dnsutils',
93 'docker-compose',
94 'faketime',
95 'gawk',
96 'krb5-user',
97 'ldnsutils',
98 '"libboost-serialization1.7[1-9]+"',
99 'libcdb1',
100 'libcurl4',
101 'libgeoip1',
102 'libkrb5-3',
103 'libldap-2.4-2',
104 'liblmdb0',
105 'libluajit-5.1-2',
106 'libmaxminddb0',
107 'libnet-dns-perl',
108 'libp11-kit0',
109 'libpq5',
110 'libsodium23',
111 'libsqlite3-dev',
112 'libssl1.1',
113 'libsystemd0',
114 'libyaml-cpp0.6',
115 'libzmq3-dev',
116 'lmdb-utils',
117 'prometheus',
118 'ruby-bundler',
119 'ruby-dev',
120 'socat',
121 'softhsm2',
122 'unbound-host',
123 'unixodbc',
124 'wget',
125 ]
126 doc_deps = [
127 'autoconf',
128 'automake',
129 'bison',
130 'curl',
131 'flex',
132 'g++',
133 'git',
134 'latexmk',
135 'libboost-all-dev',
136 'libedit-dev',
137 'libluajit-5.1-dev',
138 'libssl-dev',
139 'make',
140 'pkg-config',
141 'python3-venv',
142 'ragel',
143 'rsync',
144 ]
145 doc_deps_pdf = [
146 'texlive-binaries',
147 'texlive-formats-extra',
148 'texlive-latex-extra',
149 ]
150
151 @task
152 def apt_fresh(c):
153 c.sudo('sed -i \'s/azure\.//\' /etc/apt/sources.list')
154 c.sudo('apt-get update')
155 c.sudo('apt-get -y --allow-downgrades dist-upgrade')
156
157 @task
158 def install_clang(c):
159 """
160 install clang and llvm
161 """
162 c.sudo(f'apt-get -y --no-install-recommends install clang-{clang_version} llvm-{clang_version}')
163
164 @task
165 def install_clang_tidy_tools(c):
166 c.sudo(f'apt-get -y --no-install-recommends install clang-tidy-{clang_version} clang-tools-{clang_version} bear python3-yaml')
167
168 @task
169 def install_clang_runtime(c):
170 # this gives us the symbolizer, for symbols in asan/ubsan traces
171 c.sudo(f'apt-get -y --no-install-recommends install clang-{clang_version}')
172
173 def install_libdecaf(c, product):
174 c.run('git clone https://git.code.sf.net/p/ed448goldilocks/code /tmp/libdecaf')
175 with c.cd('/tmp/libdecaf'):
176 c.run('git checkout 41f349')
177 c.run(f'CC=clang-{clang_version} CXX=clang-{clang_version} '
178 'cmake -B build '
179 '-DCMAKE_INSTALL_PREFIX=/usr/local '
180 '-DCMAKE_INSTALL_LIBDIR=lib '
181 '-DENABLE_STATIC=OFF '
182 '-DENABLE_TESTS=OFF '
183 '-DCMAKE_C_FLAGS="-Wno-sizeof-array-div -Wno-array-parameter" .')
184 c.run('make -C build')
185 c.run('sudo make -C build install')
186 c.sudo(f'mkdir -p /opt/{product}/libdecaf')
187 c.sudo(f'cp /usr/local/lib/libdecaf.so* /opt/{product}/libdecaf/.')
188
189 @task
190 def install_doc_deps(c):
191 c.sudo('apt-get install -y ' + ' '.join(doc_deps))
192
193 @task
194 def install_doc_deps_pdf(c):
195 c.sudo('apt-get install -y ' + ' '.join(doc_deps_pdf))
196
197 @task
198 def install_auth_build_deps(c):
199 c.sudo('apt-get install -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + auth_build_deps))
200 install_libdecaf(c, 'pdns-auth')
201
202 def setup_authbind(c):
203 c.sudo('touch /etc/authbind/byport/53')
204 c.sudo('chmod 755 /etc/authbind/byport/53')
205
206 auth_backend_test_deps = dict(
207 gsqlite3=['sqlite3'],
208 gmysql=['default-libmysqlclient-dev'],
209 gpgsql=['libpq-dev'],
210 lmdb=[],
211 remote=[],
212 bind=[],
213 geoip=[],
214 lua2=[],
215 tinydns=[],
216 authpy=[],
217 godbc_sqlite3=['libsqliteodbc'],
218 godbc_mssql=['freetds-bin','tdsodbc'],
219 ldap=[],
220 geoip_mmdb=[]
221 )
222
223 @task(help={'backend': 'Backend to install test deps for, e.g. gsqlite3; can be repeated'}, iterable=['backend'], optional=['backend'])
224 def install_auth_test_deps(c, backend): # FIXME: rename this, we do way more than apt-get
225 extra=[]
226 for b in backend:
227 extra.extend(auth_backend_test_deps[b])
228 c.sudo('DEBIAN_FRONTEND=noninteractive apt-get -y install ' + ' '.join(extra+auth_test_deps))
229
230 c.run('chmod +x /opt/pdns-auth/bin/* /opt/pdns-auth/sbin/*')
231 # c.run('''if [ ! -e $HOME/bin/jdnssec-verifyzone ]; then
232 # wget https://github.com/dblacka/jdnssec-tools/releases/download/0.14/jdnssec-tools-0.14.tar.gz
233 # tar xfz jdnssec-tools-0.14.tar.gz -C $HOME
234 # rm jdnssec-tools-0.14.tar.gz
235 # fi
236 # echo 'export PATH=$HOME/jdnssec-tools-0.14/bin:$PATH' >> $BASH_ENV''') # FIXME: why did this fail with no error?
237 c.run('touch regression-tests/tests/verify-dnssec-zone/allow-missing regression-tests.nobackend/rectify-axfr/allow-missing') # FIXME: can this go?
238 # FIXME we may want to start a background recursor here to make ALIAS tests more robust
239 setup_authbind(c)
240
241 # Copy libdecaf out
242 c.sudo('mkdir -p /usr/local/lib')
243 c.sudo('cp /opt/pdns-auth/libdecaf/libdecaf.so* /usr/local/lib/.')
244
245 @task
246 def install_rec_bulk_deps(c): # FIXME: rename this, we do way more than apt-get
247 c.sudo('apt-get --no-install-recommends -y install ' + ' '.join(rec_bulk_deps))
248 c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
249
250 @task
251 def install_rec_test_deps(c): # FIXME: rename this, we do way more than apt-get
252 c.sudo('apt-get --no-install-recommends install -y ' + ' '.join(rec_bulk_deps) + ' \
253 pdns-server pdns-backend-bind daemontools \
254 jq libfaketime lua-posix lua-socket bc authbind \
255 python3-venv python3-dev default-libmysqlclient-dev libpq-dev \
256 protobuf-compiler snmpd prometheus')
257
258 c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
259
260 setup_authbind(c)
261
262 c.run('sed "s/agentxperms 0700 0755 recursor/agentxperms 0777 0755/g" regression-tests.recursor-dnssec/snmpd.conf | sudo tee /etc/snmp/snmpd.conf')
263 c.sudo('/etc/init.d/snmpd restart')
264 time.sleep(5)
265 c.sudo('chmod 755 /var/agentx')
266
267 @task
268 def install_dnsdist_test_deps(c): # FIXME: rename this, we do way more than apt-get
269 c.sudo('apt-get install -y \
270 libluajit-5.1-2 \
271 libboost-all-dev \
272 libcap2 \
273 libcdb1 \
274 libcurl4-openssl-dev \
275 libfstrm0 \
276 libgnutls30 \
277 libh2o-evloop0.13 \
278 liblmdb0 \
279 libnghttp2-14 \
280 "libre2-[1-9]+" \
281 libssl-dev \
282 libsystemd0 \
283 libsodium23 \
284 lua-socket \
285 patch \
286 protobuf-compiler \
287 python3-venv snmpd prometheus')
288 c.run('sed "s/agentxperms 0700 0755 dnsdist/agentxperms 0777 0755/g" regression-tests.dnsdist/snmpd.conf | sudo tee /etc/snmp/snmpd.conf')
289 c.sudo('/etc/init.d/snmpd restart')
290 time.sleep(5)
291 c.sudo('chmod 755 /var/agentx')
292
293 @task
294 def install_rec_build_deps(c):
295 c.sudo('apt-get install -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + rec_build_deps))
296
297 @task
298 def install_dnsdist_build_deps(c):
299 c.sudo('apt-get install -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + dnsdist_build_deps))
300
301 @task
302 def ci_autoconf(c):
303 c.run('BUILDER_VERSION=0.0.0-git1 autoreconf -vfi')
304
305 @task
306 def ci_docs_build(c):
307 c.run('make -f Makefile.sphinx -C docs html')
308
309 @task
310 def ci_docs_build_pdf(c):
311 c.run('make -f Makefile.sphinx -C docs latexpdf')
312
313 @task
314 def ci_docs_upload_master(c, docs_host, pdf, username, product, directory=""):
315 rsync_cmd = " ".join([
316 "rsync",
317 "--checksum",
318 "--recursive",
319 "--verbose",
320 "--no-p",
321 "--chmod=g=rwX",
322 "--exclude '*~'",
323 ])
324 c.run(f"{rsync_cmd} --delete ./docs/_build/{product}-html-docs/ {username}@{docs_host}:{directory}")
325 c.run(f"{rsync_cmd} ./docs/_build/{product}-html-docs.tar.bz2 {username}@{docs_host}:{directory}/html-docs.tar.bz2")
326 c.run(f"{rsync_cmd} ./docs/_build/latex/{pdf} {username}@{docs_host}:{directory}")
327
328 @task
329 def ci_docs_add_ssh(c, ssh_key, host_key):
330 c.run('mkdir -m 700 -p ~/.ssh')
331 c.run(f'echo "{ssh_key}" > ~/.ssh/id_ed25519')
332 c.run('chmod 600 ~/.ssh/id_ed25519')
333 c.run(f'echo "{host_key}" > ~/.ssh/known_hosts')
334
335
336 def get_sanitizers():
337 sanitizers = os.getenv('SANITIZERS')
338 if sanitizers != '':
339 sanitizers = sanitizers.split('+')
340 sanitizers = ['--enable-' + sanitizer for sanitizer in sanitizers]
341 sanitizers = ' '.join(sanitizers)
342 return sanitizers
343
344
345 def get_cflags():
346 return " ".join([
347 "-O1",
348 "-Werror=vla",
349 "-Werror=shadow",
350 "-Wformat=2",
351 "-Werror=format-security",
352 "-Werror=string-plus-int",
353 ])
354
355
356 def get_cxxflags():
357 return " ".join([
358 get_cflags(),
359 "-Wp,-D_GLIBCXX_ASSERTIONS",
360 ])
361
362
363 def get_base_configure_cmd():
364 return " ".join([
365 f'CFLAGS="{get_cflags()}"',
366 f'CXXFLAGS="{get_cxxflags()}"',
367 './configure',
368 f"CC='clang-{clang_version}'",
369 f"CXX='clang++-{clang_version}'",
370 "--enable-option-checking=fatal",
371 "--enable-systemd",
372 "--with-libsodium",
373 "--enable-fortify-source=auto",
374 "--enable-auto-var-init=pattern",
375 ])
376
377
378 @task
379 def ci_auth_configure(c):
380 sanitizers = get_sanitizers()
381
382 unittests = os.getenv('UNIT_TESTS')
383 if unittests == 'yes':
384 unittests = '--enable-unit-tests --enable-backend-unit-tests'
385 else:
386 unittests = ''
387
388 fuzz_targets = os.getenv('FUZZING_TARGETS')
389 fuzz_targets = '--enable-fuzz-targets' if fuzz_targets == 'yes' else ''
390
391 modules = " ".join([
392 "bind",
393 "geoip",
394 "gmysql",
395 "godbc",
396 "gpgsql",
397 "gsqlite3",
398 "ldap",
399 "lmdb",
400 "lua2",
401 "pipe",
402 "remote",
403 "tinydns",
404 ])
405 configure_cmd = " ".join([
406 get_base_configure_cmd(),
407 "LDFLAGS='-L/usr/local/lib -Wl,-rpath,/usr/local/lib'",
408 f"--with-modules='{modules}'",
409 "--enable-tools",
410 "--enable-experimental-pkcs11",
411 "--enable-experimental-gss-tsig",
412 "--enable-remotebackend-zeromq",
413 "--with-lmdb=/usr",
414 "--with-libdecaf",
415 "--prefix=/opt/pdns-auth",
416 "--enable-ixfrdist",
417 sanitizers,
418 unittests,
419 fuzz_targets,
420 ])
421 res = c.run(configure_cmd, warn=True)
422 if res.exited != 0:
423 c.run('cat config.log')
424 raise UnexpectedExit(res)
425
426
427 @task
428 def ci_rec_configure(c):
429 sanitizers = get_sanitizers()
430
431 unittests = os.getenv('UNIT_TESTS')
432 unittests = '--enable-unit-tests' if unittests == 'yes' else ''
433
434 configure_cmd = " ".join([
435 get_base_configure_cmd(),
436 "--enable-nod",
437 "--prefix=/opt/pdns-recursor",
438 "--with-lua=luajit",
439 "--with-libcap",
440 "--with-net-snmp",
441 "--enable-dns-over-tls",
442 sanitizers,
443 unittests,
444 ])
445 res = c.run(configure_cmd, warn=True)
446 if res.exited != 0:
447 c.run('cat config.log')
448 raise UnexpectedExit(res)
449
450
451 @task
452 def ci_dnsdist_configure(c, features):
453 additional_flags = ''
454 if features == 'full':
455 features_set = '--enable-dnstap \
456 --enable-dnscrypt \
457 --enable-dns-over-tls \
458 --enable-dns-over-https \
459 --enable-systemd \
460 --prefix=/opt/dnsdist \
461 --with-gnutls \
462 --with-libsodium \
463 --with-lua=luajit \
464 --with-libcap \
465 --with-nghttp2 \
466 --with-re2 '
467 else:
468 features_set = '--disable-dnstap \
469 --disable-dnscrypt \
470 --disable-ipcipher \
471 --disable-systemd \
472 --without-cdb \
473 --without-ebpf \
474 --without-gnutls \
475 --without-libedit \
476 --without-libsodium \
477 --without-lmdb \
478 --without-net-snmp \
479 --without-nghttp2 \
480 --without-re2 '
481 additional_flags = '-DDISABLE_COMPLETION \
482 -DDISABLE_DELAY_PIPE \
483 -DDISABLE_DYNBLOCKS \
484 -DDISABLE_PROMETHEUS \
485 -DDISABLE_PROTOBUF \
486 -DDISABLE_BUILTIN_HTML \
487 -DDISABLE_CARBON \
488 -DDISABLE_SECPOLL \
489 -DDISABLE_DEPRECATED_DYNBLOCK \
490 -DDISABLE_LUA_WEB_HANDLERS \
491 -DDISABLE_NON_FFI_DQ_BINDINGS \
492 -DDISABLE_POLICIES_BINDINGS \
493 -DDISABLE_PACKETCACHE_BINDINGS \
494 -DDISABLE_DOWNSTREAM_BINDINGS \
495 -DDISABLE_COMBO_ADDR_BINDINGS \
496 -DDISABLE_CLIENT_STATE_BINDINGS \
497 -DDISABLE_QPS_LIMITER_BINDINGS \
498 -DDISABLE_SUFFIX_MATCH_BINDINGS \
499 -DDISABLE_NETMASK_BINDINGS \
500 -DDISABLE_DNSNAME_BINDINGS \
501 -DDISABLE_DNSHEADER_BINDINGS \
502 -DDISABLE_RECVMMSG \
503 -DDISABLE_WEB_CACHE_MANAGEMENT \
504 -DDISABLE_WEB_CONFIG \
505 -DDISABLE_RULES_ALTERING_QUERIES \
506 -DDISABLE_ECS_ACTIONS \
507 -DDISABLE_TOP_N_BINDINGS \
508 -DDISABLE_OCSP_STAPLING \
509 -DDISABLE_HASHED_CREDENTIALS \
510 -DDISABLE_FALSE_SHARING_PADDING \
511 -DDISABLE_NPN'
512 unittests = ' --enable-unit-tests' if os.getenv('UNIT_TESTS') == 'yes' else ''
513 sanitizers = ' '.join('--enable-'+x for x in os.getenv('SANITIZERS').split('+')) if os.getenv('SANITIZERS') != '' else ''
514 cflags = '-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int'
515 cxxflags = cflags + ' -Wp,-D_GLIBCXX_ASSERTIONS ' + additional_flags
516 res = c.run(f'''CFLAGS="%s" \
517 CXXFLAGS="%s" \
518 AR=llvm-ar-{clang_version} \
519 RANLIB=llvm-ranlib-{clang_version} \
520 ./configure \
521 CC='clang-{clang_version}' \
522 CXX='clang++-{clang_version}' \
523 --enable-option-checking=fatal \
524 --enable-fortify-source=auto \
525 --enable-auto-var-init=pattern \
526 --enable-lto=thin \
527 --prefix=/opt/dnsdist %s %s %s''' % (cflags, cxxflags, features_set, sanitizers, unittests), warn=True)
528 if res.exited != 0:
529 c.run('cat config.log')
530 raise UnexpectedExit(res)
531
532 @task
533 def ci_auth_make(c):
534 c.run('make -j8 -k V=1')
535
536 @task
537 def ci_auth_make_bear(c):
538 # Needed for clang-tidy -line-filter vs project structure shenanigans
539 with c.cd('pdns'):
540 c.run('bear --append -- make -j8 -k V=1 -C ..')
541
542 @task
543 def ci_rec_make(c):
544 c.run('make -j8 -k V=1')
545
546 @task
547 def ci_rec_make_bear(c):
548 # Assumed to be running under ./pdns/recursordist/
549 c.run('bear --append -- make -j8 -k V=1')
550
551 @task
552 def ci_dnsdist_make(c):
553 c.run('make -j4 -k V=1')
554
555 @task
556 def ci_dnsdist_make_bear(c):
557 # Assumed to be running under ./pdns/dnsdistdist/
558 c.run('bear --append -- make -j4 -k V=1')
559
560 @task
561 def ci_auth_install_remotebackend_test_deps(c):
562 with c.cd('modules/remotebackend'):
563 # c.run('bundle config set path vendor/bundle')
564 c.run('sudo ruby -S bundle install')
565 c.sudo('apt-get install -y socat')
566
567 @task
568 def ci_auth_run_unit_tests(c):
569 res = c.run('make check', warn=True)
570 if res.exited != 0:
571 c.run('cat pdns/test-suite.log', warn=True)
572 c.run('cat modules/remotebackend/test-suite.log', warn=True)
573 raise UnexpectedExit(res)
574
575 @task
576 def ci_rec_run_unit_tests(c):
577 res = c.run('make check', warn=True)
578 if res.exited != 0:
579 c.run('cat test-suite.log')
580 raise UnexpectedExit(res)
581
582 @task
583 def ci_dnsdist_run_unit_tests(c):
584 res = c.run('make check', warn=True)
585 if res.exited != 0:
586 c.run('cat test-suite.log')
587 raise UnexpectedExit(res)
588
589 @task
590 def ci_make_install(c):
591 res = c.run('make install') # FIXME: this builds auth docs - again
592
593 @task
594 def add_auth_repo(c, dist_name, dist_release_name, pdns_repo_version):
595 c.sudo('apt-get install -y curl gnupg2')
596 if pdns_repo_version == 'master':
597 c.sudo('curl -s -o /etc/apt/trusted.gpg.d/pdns-repo.asc https://repo.powerdns.com/CBC8B383-pub.asc')
598 else:
599 c.sudo('curl -s -o /etc/apt/trusted.gpg.d/pdns-repo.asc https://repo.powerdns.com/FD380FBB-pub.asc')
600 c.run(f"echo 'deb [arch=amd64] http://repo.powerdns.com/{dist_name} {dist_release_name}-auth-{pdns_repo_version} main' | sudo tee /etc/apt/sources.list.d/pdns.list")
601 c.run("echo 'Package: pdns-*' | sudo tee /etc/apt/preferences.d/pdns")
602 c.run("echo 'Pin: origin repo.powerdns.com' | sudo tee -a /etc/apt/preferences.d/pdns")
603 c.run("echo 'Pin-Priority: 600' | sudo tee -a /etc/apt/preferences.d/pdns")
604 c.sudo('apt-get update')
605
606 @task
607 def test_api(c, product, backend=''):
608 if product == 'recursor':
609 with c.cd('regression-tests.api'):
610 c.run(f'PDNSRECURSOR=/opt/pdns-recursor/sbin/pdns_recursor ./runtests recursor {backend}')
611 elif product == 'auth':
612 with c.cd('regression-tests.api'):
613 c.run(f'PDNSSERVER=/opt/pdns-auth/sbin/pdns_server PDNSUTIL=/opt/pdns-auth/bin/pdnsutil SDIG=/opt/pdns-auth/bin/sdig MYSQL_HOST={auth_backend_ip_addr} PGHOST={auth_backend_ip_addr} PGPORT=5432 ./runtests authoritative {backend}')
614 else:
615 raise Failure('unknown product')
616
617 backend_regress_tests = dict(
618 bind = [
619 'bind-both',
620 'bind-dnssec-both',
621 'bind-dnssec-nsec3-both',
622 'bind-dnssec-nsec3-optout-both',
623 'bind-dnssec-nsec3-narrow',
624 # FIXME 'bind-dnssec-pkcs11'
625 ],
626 geoip = [
627 'geoip',
628 'geoip-nsec3-narrow'
629 ],
630 lua2 = ['lua2', 'lua2-dnssec'],
631 tinydns = ['tinydns'],
632 remote = [
633 'remotebackend-pipe',
634 'remotebackend-unix',
635 'remotebackend-http',
636 'remotebackend-zeromq',
637 'remotebackend-pipe-dnssec',
638 'remotebackend-unix-dnssec',
639 'remotebackend-http-dnssec',
640 'remotebackend-zeromq-dnssec'
641 ],
642 lmdb = [
643 'lmdb-nodnssec-both',
644 'lmdb-both',
645 'lmdb-nsec3-both',
646 'lmdb-nsec3-optout-both',
647 'lmdb-nsec3-narrow'
648 ],
649 gmysql = [
650 'gmysql',
651 'gmysql-nodnssec-both',
652 'gmysql-nsec3-both',
653 'gmysql-nsec3-optout-both',
654 'gmysql-nsec3-narrow',
655 'gmysql_sp-both'
656 ],
657 gpgsql = [
658 'gpgsql',
659 'gpgsql-nodnssec-both',
660 'gpgsql-nsec3-both',
661 'gpgsql-nsec3-optout-both',
662 'gpgsql-nsec3-narrow',
663 'gpgsql_sp-both'
664 ],
665 gsqlite3 = [
666 'gsqlite3',
667 'gsqlite3-nodnssec-both',
668 'gsqlite3-nsec3-both',
669 'gsqlite3-nsec3-optout-both',
670 'gsqlite3-nsec3-narrow'
671 ],
672 godbc_sqlite3 = ['godbc_sqlite3-nodnssec'],
673 godbc_mssql = [
674 'godbc_mssql',
675 'godbc_mssql-nodnssec',
676 'godbc_mssql-nsec3',
677 'godbc_mssql-nsec3-optout',
678 'godbc_mssql-nsec3-narrow'
679 ],
680 ldap = [
681 'ldap-tree',
682 'ldap-simple',
683 'ldap-strict'
684 ],
685 geoip_mmdb = ['geoip'],
686 )
687
688 godbc_mssql_credentials = {"username": "sa", "password": "SAsa12%%"}
689
690 godbc_config = f'''
691 [pdns-mssql-docker]
692 Driver=FreeTDS
693 Trace=No
694 Server={auth_backend_ip_addr}
695 Port=1433
696 Database=pdns
697 TDS_Version=7.1
698
699 [pdns-mssql-docker-nodb]
700 Driver=FreeTDS
701 Trace=No
702 Server={auth_backend_ip_addr}
703 Port=1433
704 TDS_Version=7.1
705
706 [pdns-sqlite3-1]
707 Driver = SQLite3
708 Database = pdns.sqlite3
709
710 [pdns-sqlite3-2]
711 Driver = SQLite3
712 Database = pdns.sqlite32
713 '''
714
715 def setup_godbc_mssql(c):
716 with open(os.path.expanduser("~/.odbc.ini"), "a") as f:
717 f.write(godbc_config)
718 c.sudo('sh -c \'echo "Threading=1" | cat /usr/share/tdsodbc/odbcinst.ini - | tee -a /etc/odbcinst.ini\'')
719 c.sudo('sed -i "s/libtdsodbc.so/\/usr\/lib\/x86_64-linux-gnu\/odbc\/libtdsodbc.so/g" /etc/odbcinst.ini')
720 c.run(f'echo "create database pdns" | isql -v pdns-mssql-docker-nodb {godbc_mssql_credentials["username"]} {godbc_mssql_credentials["password"]}')
721 # FIXME: Skip 8bit-txt-unescaped test
722 c.run('touch ${PWD}/regression-tests/tests/8bit-txt-unescaped/skip')
723
724 def setup_godbc_sqlite3(c):
725 with open(os.path.expanduser("~/.odbc.ini"), "a") as f:
726 f.write(godbc_config)
727 c.sudo('sed -i "s/libsqlite3odbc.so/\/usr\/lib\/x86_64-linux-gnu\/odbc\/libsqlite3odbc.so/g" /etc/odbcinst.ini')
728
729 def setup_ldap_client(c):
730 c.sudo('DEBIAN_FRONTEND=noninteractive apt-get install -y ldap-utils')
731 c.sudo(f'sh -c \'echo "{auth_backend_ip_addr} ldapserver" | tee -a /etc/hosts\'')
732
733 @task
734 def test_auth_backend(c, backend):
735 pdns_auth_env_vars = 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={auth_backend_ip_addr} GMYSQL2HOST={auth_backend_ip_addr} MYSQL_HOST={auth_backend_ip_addr} PGHOST={auth_backend_ip_addr} PGPORT=5432'
736
737 if backend == 'remote':
738 ci_auth_install_remotebackend_test_deps(c)
739
740 if backend == 'authpy':
741 c.sudo(f'sh -c \'echo "{auth_backend_ip_addr} kerberos-server" | tee -a /etc/hosts\'')
742 with c.cd('regression-tests.auth-py'):
743 c.run(f'{pdns_auth_env_vars} WITHKERBEROS=YES ./runtests')
744 return
745
746 if backend == 'godbc_sqlite3':
747 setup_godbc_sqlite3(c)
748 with c.cd('regression-tests'):
749 for variant in backend_regress_tests[backend]:
750 c.run(f'{pdns_auth_env_vars} GODBC_SQLITE3_DSN=pdns-sqlite3-1 ./start-test-stop 5300 {variant}')
751 return
752
753 if backend == 'godbc_mssql':
754 setup_godbc_mssql(c)
755 with c.cd('regression-tests'):
756 for variant in backend_regress_tests[backend]:
757 c.run(f'{pdns_auth_env_vars} GODBC_MSSQL_PASSWORD={godbc_mssql_credentials["password"]} GODBC_MSSQL_USERNAME={godbc_mssql_credentials["username"]} GODBC_MSSQL_DSN=pdns-mssql-docker GODBC_MSSQL2_PASSWORD={godbc_mssql_credentials["password"]} GODBC_MSSQL2_USERNAME={godbc_mssql_credentials["username"]} GODBC_MSSQL2_DSN=pdns-mssql-docker ./start-test-stop 5300 {variant}')
758 return
759
760 if backend == 'ldap':
761 setup_ldap_client(c)
762
763 if backend == 'geoip_mmdb':
764 with c.cd('regression-tests'):
765 for variant in backend_regress_tests[backend]:
766 c.run(f'{pdns_auth_env_vars} geoipdatabase=../modules/geoipbackend/regression-tests/GeoLiteCity.mmdb ./start-test-stop 5300 {variant}')
767 return
768
769 with c.cd('regression-tests'):
770 if backend == 'lua2':
771 c.run('touch trustedkeys') # avoid silly error during cleanup
772 for variant in backend_regress_tests[backend]:
773 c.run(f'{pdns_auth_env_vars} ./start-test-stop 5300 {variant}')
774
775 if backend == 'gsqlite3':
776 if os.getenv('SKIP_IPV6_TESTS'):
777 pdns_auth_env_vars += ' context=noipv6'
778 with c.cd('regression-tests.nobackend'):
779 c.run(f'{pdns_auth_env_vars} ./runtests')
780 c.run('/opt/pdns-auth/bin/pdnsutil test-algorithms')
781 return
782
783 @task
784 def test_ixfrdist(c):
785 with c.cd('regression-tests.ixfrdist'):
786 c.run('IXFRDISTBIN=/opt/pdns-auth/bin/ixfrdist ./runtests')
787
788 @task
789 def test_dnsdist(c):
790 c.run('chmod +x /opt/dnsdist/bin/*')
791 c.run('ls -ald /var /var/agentx /var/agentx/master')
792 c.run('ls -al /var/agentx/master')
793 with c.cd('regression-tests.dnsdist'):
794 c.run('DNSDISTBIN=/opt/dnsdist/bin/dnsdist ./runtests')
795
796 @task
797 def test_regression_recursor(c):
798 c.run('/opt/pdns-recursor/sbin/pdns_recursor --version')
799 c.run('PDNSRECURSOR=/opt/pdns-recursor/sbin/pdns_recursor RECCONTROL=/opt/pdns-recursor/bin/rec_control ./build-scripts/test-recursor')
800
801 @task
802 def test_bulk_recursor(c, threads, mthreads, shards):
803 # We run an extremely small version of the bulk test, as GH does not seem to be able to handle the UDP load
804 with c.cd('regression-tests'):
805 c.run('curl -LO http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip')
806 c.run('unzip top-1m.csv.zip -d .')
807 c.run('chmod +x /opt/pdns-recursor/bin/* /opt/pdns-recursor/sbin/*')
808 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}')
809
810 @task
811 def install_swagger_tools(c):
812 c.run('npm install -g api-spec-converter')
813
814 @task
815 def swagger_syntax_check(c):
816 c.run('api-spec-converter docs/http-api/swagger/authoritative-api-swagger.yaml -f swagger_2 -t openapi_3 -s json -c')
817
818 @task
819 def install_coverity_tools(c, project):
820 token = os.getenv('COVERITY_TOKEN')
821 c.run(f'curl -s https://scan.coverity.com/download/linux64 --data "token={token}&project={project}" | gunzip | sudo tar xvf /dev/stdin --strip-components=1 --no-same-owner -C /usr/local', hide=True)
822
823 @task
824 def coverity_clang_configure(c):
825 c.sudo(f'/usr/local/bin/cov-configure --template --comptype clangcc --compiler clang++-{clang_version}')
826
827 @task
828 def coverity_make(c):
829 c.run('/usr/local/bin/cov-build --dir cov-int make -j8 -k')
830
831 @task
832 def coverity_tarball(c, tarball):
833 c.run(f'tar caf {tarball} cov-int')
834
835 @task
836 def coverity_upload(c, email, project, tarball):
837 token = os.getenv('COVERITY_TOKEN')
838 c.run(f'curl --form token={token} \
839 --form email="{email}" \
840 --form file=@{tarball} \
841 --form version="$(./builder-support/gen-version)" \
842 --form description="master build" \
843 https://scan.coverity.com/builds?project={project}', hide=True)
844
845 # this is run always
846 def setup():
847 if '/usr/lib/ccache' not in os.environ['PATH']:
848 os.environ['PATH']='/usr/lib/ccache:'+os.environ['PATH']
849
850 setup()