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