]> git.ipfire.org Git - thirdparty/pdns.git/blame - build-scripts/travis.sh
Merge pull request #4077 from pieterlexis/dnssec-stats
[thirdparty/pdns.git] / build-scripts / travis.sh
CommitLineData
bf6096f5
PL
1#!/bin/bash
2
3## "upstream" travis functions
4ANSI_RED="\033[31;1m"
5ANSI_GREEN="\033[32;1m"
6ANSI_RESET="\033[0m"
7ANSI_CLEAR="\033[0K"
8
9TRAVIS_TEST_RESULT=
10TRAVIS_CMD=
11
12function travis_cmd() {
13 local assert output display retry timing cmd result
14
15 cmd=$1
16 TRAVIS_CMD=$cmd
17 shift
18
19 while true; do
20 case "$1" in
21 --assert) assert=true; shift ;;
22 --echo) output=true; shift ;;
23 --display) display=$2; shift 2;;
24 --retry) retry=true; shift ;;
25 --timing) timing=true; shift ;;
26 *) break ;;
27 esac
28 done
29
30 if [[ -n "$timing" ]]; then
31 travis_time_start
32 fi
33
34 if [[ -n "$output" ]]; then
35 echo "\$ ${display:-$cmd}"
36 fi
37
38 if [[ -n "$retry" ]]; then
39 travis_retry eval "$cmd"
40 else
41 eval "$cmd"
42 fi
43 result=$?
44
45 if [[ -n "$timing" ]]; then
46 travis_time_finish
47 fi
48
49 if [[ -n "$assert" ]]; then
50 travis_assert $result
51 fi
52
53 return $result
54}
55
56travis_time_start() {
57 travis_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
58 travis_start_time=$(travis_nanoseconds)
59 echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}"
60}
61
62travis_time_finish() {
63 local result=$?
64 travis_end_time=$(travis_nanoseconds)
65 local duration=$(($travis_end_time-$travis_start_time))
66 echo -en "\ntravis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r${ANSI_CLEAR}"
67 return $result
68}
69
70function travis_nanoseconds() {
71 local cmd="date"
72 local format="+%s%N"
73 local os=$(uname)
74
75 if hash gdate > /dev/null 2>&1; then
76 cmd="gdate" # use gdate if available
77 elif [[ "$os" = Darwin ]]; then
78 format="+%s000000000" # fallback to second precision on darwin (does not support %N)
79 fi
80
81 $cmd -u $format
82}
83
84travis_assert() {
85 local result=${1:-$?}
86 if [ $result -ne 0 ]; then
87 echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" failed and exited with $result during $TRAVIS_STAGE.${ANSI_RESET}\n\nYour build has been stopped."
88 travis_terminate 2
89 fi
90}
91
92travis_result() {
93 local result=$1
94 export TRAVIS_TEST_RESULT=$(( ${TRAVIS_TEST_RESULT:-0} | $(($result != 0)) ))
95
96 if [ $result -eq 0 ]; then
97 echo -e "\n${ANSI_GREEN}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}"
98 else
99 echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}"
100 fi
101}
102
103travis_terminate() {
104 pkill -9 -P $$ &> /dev/null || true
105 exit $1
106}
107
108travis_wait() {
109 local timeout=$1
110
111 if [[ $timeout =~ ^[0-9]+$ ]]; then
112 # looks like an integer, so we assume it's a timeout
113 shift
114 else
115 # default value
116 timeout=20
117 fi
118
119 local cmd="$@"
120 local log_file=travis_wait_$$.log
121
122 $cmd &>$log_file &
123 local cmd_pid=$!
124
125 travis_jigger $! $timeout $cmd &
126 local jigger_pid=$!
127 local result
128
129 {
130 wait $cmd_pid 2>/dev/null
131 result=$?
132 ps -p$jigger_pid &>/dev/null && kill $jigger_pid
133 }
134
135 if [ $result -eq 0 ]; then
136 echo -e "\n${ANSI_GREEN}The command $cmd exited with $result.${ANSI_RESET}"
137 else
138 echo -e "\n${ANSI_RED}The command $cmd exited with $result.${ANSI_RESET}"
139 fi
140
141 echo -e "\n${ANSI_GREEN}Log:${ANSI_RESET}\n"
142 cat $log_file
143
144 return $result
145}
146
147travis_jigger() {
148 # helper method for travis_wait()
149 local cmd_pid=$1
150 shift
151 local timeout=$1 # in minutes
152 shift
153 local count=0
154
155 # clear the line
156 echo -e "\n"
157
158 while [ $count -lt $timeout ]; do
159 count=$(($count + 1))
160 echo -ne "Still running ($count of $timeout): $@\r"
161 sleep 60
162 done
163
164 echo -e "\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"$@\"${ANSI_RESET}\n"
165 kill -9 $cmd_pid
166}
167
168travis_retry() {
169 local result=0
170 local count=1
171 while [ $count -le 3 ]; do
172 [ $result -ne 0 ] && {
173 echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
174 }
175 "$@"
176 result=$?
177 [ $result -eq 0 ] && break
178 count=$(($count + 1))
179 sleep 1
180 done
181
182 [ $count -gt 3 ] && {
183 echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
184 }
185
186 return $result
187}
188
189travis_fold() {
190 local action=$1
191 local name=$2
192 echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
193}
194
195decrypt() {
196 echo $1 | base64 -d | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa.repo
197}
198
199
200run() {
201 travis_cmd "$1" --echo --assert
202}
203
204install_auth() {
205 # pkcs11 build requirements
206 run "sudo apt-get -qq --no-install-recommends install \
207 libp11-kit-dev"
208
209 # geoip-backend
210 run "sudo apt-get -qq --no-install-recommends install \
211 libgeoip-dev \
212 libyaml-cpp-dev"
213
214 # ldap-backend
215 run "sudo apt-get -qq --no-install-recommends install \
216 libldap-dev"
217
218 # opendbx-backend
219 run "sudo apt-get -qq --no-install-recommends install \
220 libopendbx1-dev \
221 libopendbx1-sqlite3"
222
223 # remote-backend build requirements
224 run "sudo apt-get -qq --no-install-recommends install \
225 libzmq3-dev"
226
227 # authoritative test requirements / setup
228 run "sudo apt-get -qq --no-install-recommends install \
229 bind9utils \
230 ldnsutils \
231 libnet-dns-perl \
232 moreutils \
233 unbound-host \
234 validns \
235 default-jre \
236 jq"
237
238 run "cd .."
239 run "wget http://www.verisignlabs.com/dnssec-tools/packages/jdnssec-tools-0.12.tar.gz"
240 run "sudo tar xfz jdnssec-tools-0.12.tar.gz --strip-components=1 -C /"
241 run "cd pdns"
242
243 # pkcs11 test requirements / setup
244 run "sudo apt-get -qq --no-install-recommends install \
245 p11-kit \
246 softhsm"
247 run "sudo mkdir -p /etc/pkcs11/modules/"
248 run "sudo cp -f regression-tests/softhsm.mod /etc/pkcs11/modules/softhsm.module"
249 run "sudo cp -f regression-tests/softhsm.conf /etc/softhsm/softhsm.conf"
250 run "sudo chmod 0755 /etc/softhsm/"
251 run "sudo chmod 0644 /etc/softhsm/softhsm.conf"
252 run "sudo chmod 0777 /var/lib/softhsm"
253 run "p11-kit -l" # ensure it's ok
254
255 # bind-backend tests requirements
256 run "sudo apt-get -qq --no-install-recommends install \
257 alien"
258 run "cd .."
259 run "wget ftp://ftp.nominum.com/pub/nominum/dnsperf/2.0.0.0/dnsperf-2.0.0.0-1-rhel-6-x86_64.tar.gz"
260 run "tar xzvf dnsperf-2.0.0.0-1-rhel-6-x86_64.tar.gz"
261 run "fakeroot alien --to-deb dnsperf-2.0.0.0-1/dnsperf-2.0.0.0-1.el6.x86_64.rpm"
262 run "sudo dpkg -i dnsperf_2.0.0.0-2_amd64.deb"
263 run "cd pdns"
264
265 # geoip-backend test requirements / setup
266 run "sudo apt-get -qq --no-install-recommends install \
267 geoip-database"
268
269 # gmysql-backend test requirements
270 run "sudo apt-get -qq --no-install-recommends install \
271 mysql-server"
272
273 # godbc-backend test setup
274 run echo\ -e\ "[pdns-sqlite3-1]\nDriver = SQLite3\nDatabase = ${PWD}/regression-tests/pdns.sqlite3\n\n[pdns-sqlite3-2]\nDriver = SQLite3\nDatabase = ${PWD}/regression-tests/pdns.sqlite32\n"\ >\ ${HOME}/.odbc.ini
275
276 # ldap-backend test setup
277 run "sudo apt-get -qq --no-install-recommends install \
278 slapd \
279 ldap-utils"
280 run "mkdir /tmp/ldap-dns"
281 run "pushd /tmp/ldap-dns"
282 run 'for schema in /etc/ldap/schema/{core,cosine}.schema ${TRAVIS_BUILD_DIR}/modules/ldapbackend/{dnsdomain2,pdns-domaininfo}.schema ; do echo include $schema ; done > ldap.conf'
283 run "mkdir slapd.d"
284 run "slaptest -f ldap.conf -F slapd.d"
285 run "sudo cp slapd.d/cn=config/cn=schema/cn={*dns*.ldif /etc/ldap/slapd.d/cn=config/cn=schema/"
286 run "sudo chown -R openldap:openldap /etc/ldap/slapd.d/"
287 run "sudo service slapd restart"
288 run "popd"
289 run "sudo -u openldap mkdir -p /var/lib/ldap/powerdns"
290 run "sudo ldapadd -Y EXTERNAL -H ldapi:/// -f ./modules/ldapbackend/testfiles/add.ldif"
291
292 # remote-backend tests requirements
293 run "sudo apt-get -qq --no-install-recommends install \
294 ruby-json \
295 rubygems-integration \
296 socat"
297 run "gem install bundler --no-rdoc --no-ri"
298 run "cd modules/remotebackend"
299 run "ruby -S bundle install"
300 run "cd ../.."
301
302 # tinydns
303 run "sudo apt-get -qq --no-install-recommends install \
304 libcdb-dev"
305
306 # No backend
307 run "sudo apt-get -qq --no-install-recommends install \
308 authbind \
309 faketime"
310 run "sudo touch /etc/authbind/byport/53"
311 run "sudo chmod 755 /etc/authbind/byport/53"
312}
313
314install_docs() {
315 ### documentation requirements
316 run "sudo apt-get -qq --no-install-recommends install \
317 pandoc \
318 xmlto"
319
320 # documentation test requirements
321 run "virtualenv $HOME/.venv"
322 run "source $HOME/.venv/bin/activate"
784247e7 323 run "pip install -q pandocfilters==1.2.3 mkdocs==0.14 linkchecker==9.3 click==5.1 requests==2.9.2"
bf6096f5
PL
324 run "deactivate"
325}
326
327install_recursor() {
328 # recursor test requirements / setup
329 run "sudo apt-get -qq --no-install-recommends install \
330 authbind \
331 daemontools \
332 libbotan-1.10-0 \
cb54e9b5 333 libfaketime \
bf6096f5
PL
334 liblua5.2-0 \
335 moreutils \
336 jq"
337 run "cd .."
338 run "wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip"
339 run "unzip top-1m.csv.zip -d ./pdns/regression-tests"
340 PDNS_SERVER_VERSION="0.0.880gcb54743-1pdns"
341 run "wget https://downloads.powerdns.com/autobuilt/auth/deb/$PDNS_SERVER_VERSION.trusty-amd64/pdns-server_$PDNS_SERVER_VERSION.trusty_amd64.deb"
342 run "wget https://downloads.powerdns.com/autobuilt/auth/deb/$PDNS_SERVER_VERSION.trusty-amd64/pdns-tools_$PDNS_SERVER_VERSION.trusty_amd64.deb"
343 run "sudo dpkg -i pdns-server_$PDNS_SERVER_VERSION.trusty_amd64.deb pdns-tools_$PDNS_SERVER_VERSION.trusty_amd64.deb"
344 run 'for suffix in {1..40}; do sudo /sbin/ip addr add 10.0.3.$suffix/32 dev lo; done'
345 run "sudo touch /etc/authbind/byport/53"
346 run "sudo chmod 755 /etc/authbind/byport/53"
347 run "cd pdns"
348}
349
350install_dnsdist() {
351 printf ""
352}
353
354build_auth() {
355 run "./bootstrap"
356 # Build without --enable-botan1.10 option, Botan/SoftHSM conflict #2496
357 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
358 --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 ldap lua mydns opendbx pipe random remote tinydns' \
359 --with-modules='' \
360 --with-sqlite3 \
361 --enable-libsodium \
362 --enable-experimental-pkcs11 \
363 --enable-remotebackend-zeromq \
364 --enable-tools \
365 --enable-unit-tests \
366 --enable-backend-unit-tests \
367 --disable-dependency-tracking \
368 --disable-silent-rules"
369 run "make -k dist"
370 run "make -k -j3"
371 run "make -k install DESTDIR=/tmp/pdns-install-dir"
372 run "find /tmp/pdns-install-dir -ls"
373}
374
375build_recursor() {
376 export PDNS_RECURSOR_DIR=$HOME/pdns_recursor
377 # distribution build
378 run "./build-scripts/dist-recursor"
379 run "cd pdns/recursordist"
380 run "tar xf pdns-recursor-*.tar.bz2"
381 run "rm -f pdns-recursor-*.tar.bz2"
382 run "cd pdns-recursor-*"
383 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
384 --prefix=$PDNS_RECURSOR_DIR \
385 --disable-silent-rules"
386 run "make -k -j3"
387 run "make install"
388 run "find $PDNS_RECURSOR_DIR -ls"
389 run "cd ../../.."
390}
391
392build_dnsdist(){
393 run "./build-scripts/dist-dnsdist"
394 run "cd pdns/dnsdistdist"
395 run "tar xf dnsdist*.tar.bz2"
396 run "cd dnsdist-*"
397 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
398 --enable-unit-tests \
399 --enable-libsodium \
400 --enable-dnscrypt \
401 --prefix=$HOME/dnsdist \
402 --disable-silent-rules"
403 run "make -k -j3"
404 run "./testrunner"
405 run "make install"
406 run "cd ../../.."
407 run "find $HOME/dnsdist -ls"
408 run "rm -rf pdns/dnsdistdist/dnsdist-*/"
409
410}
411
412build_docs() {
413 run "./bootstrap"
414 run "source $HOME/.venv/bin/activate"
415 run "./configure --disable-dependency-tracking --with-modules='' --with-dyn-modules=''"
416 run "make -C docs"
417 run "deactivate"
418}
419
420test_auth() {
421 run "make -j3 check"
422 run "test -f pdns/test-suite.log && cat pdns/test-suite.log || true"
423 run "test -f modules/remotebackend/test-suite.log && cat modules/remotebackend/test-suite.log || true"
424
425 #DNSName - make -k -j3 -C pdns $(grep '(EXEEXT):' pdns/Makefile | cut -f1 -d\$ | grep -E -v 'dnsdist|calidns')
426 run 'make -k -j3 -C pdns $(grep "(EXEEXT):" pdns/Makefile | cut -f1 -d\$ | grep -E -v "dnspcap2protobuf|dnsdist|calidns|speedtest")'
427
428 run "cd pdns"
429 run "./pdnsutil test-algorithms"
430 run "cd .."
431
432 run "cd regression-tests"
433
434 run "./timestamp ./start-test-stop 5300 ldap-tree"
435 run "./timestamp ./start-test-stop 5300 ldap-simple"
436 run "./timestamp ./start-test-stop 5300 ldap-strict"
437
438 run "./timestamp ./start-test-stop 5300 bind-both"
439 run "./timestamp ./start-test-stop 5300 bind-dnssec-both"
440 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-both"
441 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-optout-both"
442 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-narrow"
443 run "./timestamp ./start-test-stop 5300 bind-hybrid-nsec3"
444 #ecdsa - ./timestamp ./start-test-stop 5300 bind-dnssec-pkcs11
445
446 run "export geoipregion=oc geoipregionip=1.2.3.4"
447 run "./timestamp ./start-test-stop 5300 geoip"
448 run "./timestamp ./start-test-stop 5300 geoip-nsec3-narrow"
449
450 run "./timestamp ./start-test-stop 5300 gmysql-nodnssec-both"
451 run "./timestamp ./start-test-stop 5300 gmysql-both"
452 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-both"
453 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-optout-both"
454 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-narrow"
455
456 run "export GODBC_SQLITE3_DSN=pdns-sqlite3-1"
457 # run "./timestamp ./start-test-stop 5300 godbc_sqlite3-nsec3"
458
459 run "./timestamp ./start-test-stop 5300 gpgsql-nodnssec-both"
460 run "./timestamp ./start-test-stop 5300 gpgsql-both"
461 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-both"
462 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-optout-both"
463 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-narrow"
464
465 run "./timestamp ./start-test-stop 5300 gsqlite3-nodnssec-both"
466 run "./timestamp ./start-test-stop 5300 gsqlite3-both"
467 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-both"
468 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both"
469 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow"
470
471 run "./timestamp ./start-test-stop 5300 mydns"
472
473 run "./timestamp ./start-test-stop 5300 opendbx-sqlite3"
474
475 run "./timestamp ./start-test-stop 5300 remotebackend-pipe"
476 run "./timestamp ./start-test-stop 5300 remotebackend-pipe-dnssec"
477 run "./timestamp ./start-test-stop 5300 remotebackend-unix"
478 run "./timestamp ./start-test-stop 5300 remotebackend-unix-dnssec"
479 run "./timestamp ./start-test-stop 5300 remotebackend-http"
480 run "./timestamp ./start-test-stop 5300 remotebackend-http-dnssec"
481 run "./timestamp ./start-test-stop 5300 remotebackend-zeromq"
482 run "./timestamp ./start-test-stop 5300 remotebackend-zeromq-dnssec"
483
484 run "./timestamp ./start-test-stop 5300 tinydns"
485 run "cd .."
486
487 run "cd regression-tests.rootzone"
488 run "./timestamp ./start-test-stop 5300 bind-both"
489 run "./timestamp ./start-test-stop 5300 bind-dnssec-both"
490 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-both"
491 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-optout-both"
492 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-narrow"
493 run "./timestamp ./start-test-stop 5300 bind-hybrid-nsec3"
494
495 run "./timestamp ./start-test-stop 5300 gmysql-nodnssec-both"
496 run "./timestamp ./start-test-stop 5300 gmysql-both"
497 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-both"
498 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-optout-both"
499 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-narrow"
500
501 run "./timestamp ./start-test-stop 5300 gpgsql-nodnssec-both"
502 run "./timestamp ./start-test-stop 5300 gpgsql-both"
503 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-both"
504 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-optout-both"
505 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-narrow"
506
507 run "./timestamp ./start-test-stop 5300 gsqlite3-nodnssec-both"
508 run "./timestamp ./start-test-stop 5300 gsqlite3-both"
509 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-both"
510 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both"
511 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow"
512
513 run "cd .."
514
515 ### api ###
516 run "cd regression-tests.api"
517 run "./runtests authoritative"
518 run "cd .."
519
520 ### no backend tests ###
521 run "cd regression-tests.nobackend/"
522 run "./runtests"
523 run "test ! -s ./failed_tests"
524 run "cd .."
525
526 run "rm -f regression-tests/zones/*-slave.*" #FIXME
527}
528
529test_recursor() {
530 export PDNSRECURSOR="${PDNS_RECURSOR_DIR}/sbin/pdns_recursor"
bf6096f5
PL
531 export DNSBULKTEST="/usr/bin/dnsbulktest"
532 export RECCONTROL="${PDNS_RECURSOR_DIR}/bin/rec_control"
7568b07d
PL
533 run "./build-scripts/test-recursor"
534 export RECURSOR="${PDNSRECURSOR}"
bf6096f5
PL
535 run "cd regression-tests"
536 run "THRESHOLD=90 TRACE=no ./timestamp ./recursor-test 5300 25000"
537 run "cd .."
7568b07d 538
bf6096f5
PL
539 run "cd regression-tests.api"
540 run "./runtests recursor"
541 run "cd .."
542}
543
544test_docs() {
545 run "source $HOME/.venv/bin/activate"
546 run "make -C docs check-links"
547 run " deactivate"
548}
549
550test_dnsdist(){
551 run "cd regression-tests.dnsdist"
552 run "DNSDISTBIN=$HOME/dnsdist/bin/dnsdist ./runtests -v"
553 run "rm -f ./DNSCryptResolver.cert ./DNSCryptResolver.key"
554 run "cd .."
555}
556
557test_repo(){
558 run "git status"
559 run "git status | grep -q clean"
560}
561
562# global build requirements
563run "sudo apt-get -qq --no-install-recommends install \
564 libboost-all-dev \
565 liblua5.1-dev \
566 libedit-dev \
567 pandoc"
568
569run "cd .."
570run "wget http://ppa.launchpad.net/kalon33/gamesgiroll/ubuntu/pool/main/libs/libsodium/libsodium-dev_1.0.3-1~ppa14.04+1_amd64.deb"
571run "wget http://ppa.launchpad.net/kalon33/gamesgiroll/ubuntu/pool/main/libs/libsodium/libsodium13_1.0.3-1~ppa14.04+1_amd64.deb"
572run "sudo dpkg -i libsodium-dev_1.0.3-1~ppa14.04+1_amd64.deb libsodium13_1.0.3-1~ppa14.04+1_amd64.deb"
573run "cd pdns"
574
575install_$PDNS_BUILD_PRODUCT
576
577build_$PDNS_BUILD_PRODUCT
578
579test_$PDNS_BUILD_PRODUCT
580
d2a4a399 581if [ $PDNS_BUILD_PRODUCT == "auth" ]; then
bf6096f5
PL
582 test_repo
583fi