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