]> git.ipfire.org Git - thirdparty/pdns.git/blob - build-scripts/travis.sh
Split travis between the products
[thirdparty/pdns.git] / build-scripts / travis.sh
1 #!/bin/bash
2
3 ## "upstream" travis functions
4 ANSI_RED="\033[31;1m"
5 ANSI_GREEN="\033[32;1m"
6 ANSI_RESET="\033[0m"
7 ANSI_CLEAR="\033[0K"
8
9 TRAVIS_TEST_RESULT=
10 TRAVIS_CMD=
11
12 function 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
56 travis_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
62 travis_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
70 function 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
84 travis_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
92 travis_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
103 travis_terminate() {
104 pkill -9 -P $$ &> /dev/null || true
105 exit $1
106 }
107
108 travis_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
147 travis_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
168 travis_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
189 travis_fold() {
190 local action=$1
191 local name=$2
192 echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
193 }
194
195 decrypt() {
196 echo $1 | base64 -d | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa.repo
197 }
198
199
200 run() {
201 travis_cmd "$1" --echo --assert
202 }
203
204 install_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
314 install_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"
323 run "pip install -q pandocfilters==1.2.3 mkdocs==0.14 linkchecker==9.3 click==5.1"
324 run "deactivate"
325 }
326
327 install_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 \
333 liblua5.2-0 \
334 moreutils \
335 jq"
336 run "cd .."
337 run "wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip"
338 run "unzip top-1m.csv.zip -d ./pdns/regression-tests"
339 PDNS_SERVER_VERSION="0.0.880gcb54743-1pdns"
340 run "wget https://downloads.powerdns.com/autobuilt/auth/deb/$PDNS_SERVER_VERSION.trusty-amd64/pdns-server_$PDNS_SERVER_VERSION.trusty_amd64.deb"
341 run "wget https://downloads.powerdns.com/autobuilt/auth/deb/$PDNS_SERVER_VERSION.trusty-amd64/pdns-tools_$PDNS_SERVER_VERSION.trusty_amd64.deb"
342 run "sudo dpkg -i pdns-server_$PDNS_SERVER_VERSION.trusty_amd64.deb pdns-tools_$PDNS_SERVER_VERSION.trusty_amd64.deb"
343 run 'for suffix in {1..40}; do sudo /sbin/ip addr add 10.0.3.$suffix/32 dev lo; done'
344 run "sudo touch /etc/authbind/byport/53"
345 run "sudo chmod 755 /etc/authbind/byport/53"
346 run "cd pdns"
347 }
348
349 install_dnsdist() {
350 printf ""
351 }
352
353 build_auth() {
354 run "./bootstrap"
355 # Build without --enable-botan1.10 option, Botan/SoftHSM conflict #2496
356 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
357 --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 ldap lua mydns opendbx pipe random remote tinydns' \
358 --with-modules='' \
359 --with-sqlite3 \
360 --enable-libsodium \
361 --enable-experimental-pkcs11 \
362 --enable-remotebackend-zeromq \
363 --enable-tools \
364 --enable-unit-tests \
365 --enable-backend-unit-tests \
366 --disable-dependency-tracking \
367 --disable-silent-rules"
368 run "make -k dist"
369 run "make -k -j3"
370 run "make -k install DESTDIR=/tmp/pdns-install-dir"
371 run "find /tmp/pdns-install-dir -ls"
372 }
373
374 build_recursor() {
375 export PDNS_RECURSOR_DIR=$HOME/pdns_recursor
376 # distribution build
377 run "./build-scripts/dist-recursor"
378 run "cd pdns/recursordist"
379 run "tar xf pdns-recursor-*.tar.bz2"
380 run "rm -f pdns-recursor-*.tar.bz2"
381 run "cd pdns-recursor-*"
382 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
383 --prefix=$PDNS_RECURSOR_DIR \
384 --disable-silent-rules"
385 run "make -k -j3"
386 run "make install"
387 run "find $PDNS_RECURSOR_DIR -ls"
388 run "cd ../../.."
389 }
390
391 build_dnsdist(){
392 run "./build-scripts/dist-dnsdist"
393 run "cd pdns/dnsdistdist"
394 run "tar xf dnsdist*.tar.bz2"
395 run "cd dnsdist-*"
396 run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
397 --enable-unit-tests \
398 --enable-libsodium \
399 --enable-dnscrypt \
400 --prefix=$HOME/dnsdist \
401 --disable-silent-rules"
402 run "make -k -j3"
403 run "./testrunner"
404 run "make install"
405 run "cd ../../.."
406 run "find $HOME/dnsdist -ls"
407 run "rm -rf pdns/dnsdistdist/dnsdist-*/"
408
409 }
410
411 build_docs() {
412 run "./bootstrap"
413 run "source $HOME/.venv/bin/activate"
414 run "./configure --disable-dependency-tracking --with-modules='' --with-dyn-modules=''"
415 run "make -C docs"
416 run "deactivate"
417 }
418
419 test_auth() {
420 run "make -j3 check"
421 run "test -f pdns/test-suite.log && cat pdns/test-suite.log || true"
422 run "test -f modules/remotebackend/test-suite.log && cat modules/remotebackend/test-suite.log || true"
423
424 #DNSName - make -k -j3 -C pdns $(grep '(EXEEXT):' pdns/Makefile | cut -f1 -d\$ | grep -E -v 'dnsdist|calidns')
425 run 'make -k -j3 -C pdns $(grep "(EXEEXT):" pdns/Makefile | cut -f1 -d\$ | grep -E -v "dnspcap2protobuf|dnsdist|calidns|speedtest")'
426
427 run "cd pdns"
428 run "./pdnsutil test-algorithms"
429 run "cd .."
430
431 run "cd regression-tests"
432
433 run "./timestamp ./start-test-stop 5300 ldap-tree"
434 run "./timestamp ./start-test-stop 5300 ldap-simple"
435 run "./timestamp ./start-test-stop 5300 ldap-strict"
436
437 run "./timestamp ./start-test-stop 5300 bind-both"
438 run "./timestamp ./start-test-stop 5300 bind-dnssec-both"
439 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-both"
440 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-optout-both"
441 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-narrow"
442 run "./timestamp ./start-test-stop 5300 bind-hybrid-nsec3"
443 #ecdsa - ./timestamp ./start-test-stop 5300 bind-dnssec-pkcs11
444
445 run "export geoipregion=oc geoipregionip=1.2.3.4"
446 run "./timestamp ./start-test-stop 5300 geoip"
447 run "./timestamp ./start-test-stop 5300 geoip-nsec3-narrow"
448
449 run "./timestamp ./start-test-stop 5300 gmysql-nodnssec-both"
450 run "./timestamp ./start-test-stop 5300 gmysql-both"
451 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-both"
452 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-optout-both"
453 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-narrow"
454
455 run "export GODBC_SQLITE3_DSN=pdns-sqlite3-1"
456 # run "./timestamp ./start-test-stop 5300 godbc_sqlite3-nsec3"
457
458 run "./timestamp ./start-test-stop 5300 gpgsql-nodnssec-both"
459 run "./timestamp ./start-test-stop 5300 gpgsql-both"
460 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-both"
461 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-optout-both"
462 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-narrow"
463
464 run "./timestamp ./start-test-stop 5300 gsqlite3-nodnssec-both"
465 run "./timestamp ./start-test-stop 5300 gsqlite3-both"
466 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-both"
467 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both"
468 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow"
469
470 run "./timestamp ./start-test-stop 5300 mydns"
471
472 run "./timestamp ./start-test-stop 5300 opendbx-sqlite3"
473
474 run "./timestamp ./start-test-stop 5300 remotebackend-pipe"
475 run "./timestamp ./start-test-stop 5300 remotebackend-pipe-dnssec"
476 run "./timestamp ./start-test-stop 5300 remotebackend-unix"
477 run "./timestamp ./start-test-stop 5300 remotebackend-unix-dnssec"
478 run "./timestamp ./start-test-stop 5300 remotebackend-http"
479 run "./timestamp ./start-test-stop 5300 remotebackend-http-dnssec"
480 run "./timestamp ./start-test-stop 5300 remotebackend-zeromq"
481 run "./timestamp ./start-test-stop 5300 remotebackend-zeromq-dnssec"
482
483 run "./timestamp ./start-test-stop 5300 tinydns"
484 run "cd .."
485
486 run "cd regression-tests.rootzone"
487 run "./timestamp ./start-test-stop 5300 bind-both"
488 run "./timestamp ./start-test-stop 5300 bind-dnssec-both"
489 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-both"
490 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-optout-both"
491 run "./timestamp ./start-test-stop 5300 bind-dnssec-nsec3-narrow"
492 run "./timestamp ./start-test-stop 5300 bind-hybrid-nsec3"
493
494 run "./timestamp ./start-test-stop 5300 gmysql-nodnssec-both"
495 run "./timestamp ./start-test-stop 5300 gmysql-both"
496 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-both"
497 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-optout-both"
498 run "./timestamp ./start-test-stop 5300 gmysql-nsec3-narrow"
499
500 run "./timestamp ./start-test-stop 5300 gpgsql-nodnssec-both"
501 run "./timestamp ./start-test-stop 5300 gpgsql-both"
502 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-both"
503 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-optout-both"
504 run "./timestamp ./start-test-stop 5300 gpgsql-nsec3-narrow"
505
506 run "./timestamp ./start-test-stop 5300 gsqlite3-nodnssec-both"
507 run "./timestamp ./start-test-stop 5300 gsqlite3-both"
508 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-both"
509 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both"
510 run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow"
511
512 run "cd .."
513
514 ### api ###
515 run "cd regression-tests.api"
516 run "./runtests authoritative"
517 run "cd .."
518
519 ### no backend tests ###
520 run "cd regression-tests.nobackend/"
521 run "./runtests"
522 run "test ! -s ./failed_tests"
523 run "cd .."
524
525 run "rm -f regression-tests/zones/*-slave.*" #FIXME
526 }
527
528 test_recursor() {
529 export PDNSRECURSOR="${PDNS_RECURSOR_DIR}/sbin/pdns_recursor"
530 run "./build-scripts/test-recursor"
531 export RECURSOR="${PDNSRECURSOR}"
532 export DNSBULKTEST="/usr/bin/dnsbulktest"
533 export RECCONTROL="${PDNS_RECURSOR_DIR}/bin/rec_control"
534 run "cd regression-tests"
535 run "THRESHOLD=90 TRACE=no ./timestamp ./recursor-test 5300 25000"
536 run "cd .."
537 run "cd regression-tests.api"
538 run "./runtests recursor"
539 run "cd .."
540 }
541
542 test_docs() {
543 run "source $HOME/.venv/bin/activate"
544 run "make -C docs check-links"
545 run " deactivate"
546 }
547
548 test_dnsdist(){
549 run "cd regression-tests.dnsdist"
550 run "DNSDISTBIN=$HOME/dnsdist/bin/dnsdist ./runtests -v"
551 run "rm -f ./DNSCryptResolver.cert ./DNSCryptResolver.key"
552 run "cd .."
553 }
554
555 test_repo(){
556 run "git status"
557 run "git status | grep -q clean"
558 }
559
560 # global build requirements
561 run "sudo apt-get -qq --no-install-recommends install \
562 libboost-all-dev \
563 liblua5.1-dev \
564 libedit-dev \
565 pandoc"
566
567 run "cd .."
568 run "wget http://ppa.launchpad.net/kalon33/gamesgiroll/ubuntu/pool/main/libs/libsodium/libsodium-dev_1.0.3-1~ppa14.04+1_amd64.deb"
569 run "wget http://ppa.launchpad.net/kalon33/gamesgiroll/ubuntu/pool/main/libs/libsodium/libsodium13_1.0.3-1~ppa14.04+1_amd64.deb"
570 run "sudo dpkg -i libsodium-dev_1.0.3-1~ppa14.04+1_amd64.deb libsodium13_1.0.3-1~ppa14.04+1_amd64.deb"
571 run "cd pdns"
572
573 install_$PDNS_BUILD_PRODUCT
574
575 build_$PDNS_BUILD_PRODUCT
576
577 test_$PDNS_BUILD_PRODUCT
578
579 if [ $PDNS_BUILD_PRODUCT == "auth"]; then
580 test_repo
581 fi