]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests/start-test-stop
Merge branch 'rfc2136' of https://github.com/mind04/pdns into rfc2136
[thirdparty/pdns.git] / regression-tests / start-test-stop
1 #!/bin/bash -ex
2
3 PDNS=${PDNS:-../pdns/pdns_server}
4 PDNS2=${PDNS2:-../pdns/pdns_server}
5
6 tosql ()
7 {
8 make -C ../pdns/backends/bind zone2sql > /dev/null
9 ../pdns/backends/bind/zone2sql --transactions --$1 --named-conf=./named.conf
10
11 }
12
13 bindwait ()
14 {
15 check_process
16 configname=$1
17 domcount=$(grep -c zone named.conf)
18 if [ ! -x ../pdns/pdns_control ]; then
19 echo "No pdns_control found"
20 exit 1
21 fi
22 loopcount=0
23
24 while [ $loopcount -lt 20 ]; do
25 sleep 10
26 done=$( (../pdns/pdns_control --config-name=$configname --socket-dir=. --no-config bind-domain-status || true) | grep -c 'parsed into memory' || true )
27 if [ $done = $domcount ]; then
28 return
29 fi
30 let loopcount=loopcount+1
31 done
32
33 if [ $done != $domcount ]; then
34 echo "Domain parsing failed" >> failed_tests
35 fi
36 }
37
38 securezone ()
39 {
40 local zone=$1
41 local configname=$2
42 if [ -n "$configname" ]
43 then
44 configname="--config-name=$configname"
45 fi
46 if [ "${zone: 0:16}" = "secure-delegated" ]
47 then
48 ../pdns/pdnssec --config-dir=. $configname import-zone-key $zone $zone.key ksk 2>&1
49 ../pdns/pdnssec --config-dir=. $configname add-zone-key $zone 1024 zsk 2>&1
50 keyid=`../pdns/pdnssec --config-dir=. $configname show-zone $zone | grep ZSK | cut -d' ' -f3`
51 ../pdns/pdnssec --config-dir=. $configname activate-zone-key $zone $keyid 2>&1
52 ../pdns/pdnssec --config-dir=. $configname add-zone-key $zone 1024 zsk 2>&1
53 ../pdns/pdnssec --config-dir=. $configname rectify-zone $zone 2>&1
54 else
55 ../pdns/pdnssec --config-dir=. $configname secure-zone $zone 2>&1
56 fi
57 }
58
59 check_process ()
60 {
61 set +e
62 loopcount=0
63 while [ $loopcount -lt 5 ]; do
64 sleep 1
65 pids=$(cat pdns*.pid 2>/dev/null)
66 if [ ! -z "$pids" ]; then
67 kill -0 $pids >/dev/null 2>&1
68 if [ $? -eq 0 ]; then
69 set -e
70 return
71 fi
72 fi
73 let loopcount=loopcount+1
74 done
75 echo "PowerDNS did not start"
76 exit 1
77 }
78
79 if [ ! -x $PDNS ]; then
80 echo "$PDNS is not executable binary"
81 exit 1
82 fi
83
84 if [ ! -x $PDNS2 ]; then
85 echo "$PDNS2 is not executable binary"
86 exit 1
87 fi
88
89 port=$1
90 [ -z "$port" ] && port=5300
91 context=$2
92 [ -z "$context" ] && context=bind-dnssec
93 wait=$3
94 [ -z "$wait" ] && wait=nowait
95 cachettl=$4
96 [ -z "$cachettl" ] && cachettl=0
97 spectest=$5
98
99 testsdir=.
100
101 if [ "$port" = help ] || [ "$context" = help ]
102 then
103 set +x
104 grep -v '^#' << '__EOF__'
105
106 Usage: ./start-test-stop <port> [<context>] [wait|nowait] [<cachettl>] [<specifictest>]
107
108 context is one of:
109 bind bind-dnssec bind-dnssec-nsec3 bind-dnssec-nsec3-optout bind-dnssec-nsec3-narrow
110 gmysql-nodnssec gmysql gmysql-nsec3 gmysql-nsec3-optout gmysql-nsec3-narrow
111 gpgsql-nodnssec gpgsql gpgsql-nsec3
112 gsqlite3-nodnssec gsqlite3 gsqlite3-nsec3
113 opendbx-sqlite3
114 tinydns
115 mydns
116 remotebackend-pipe remotebackend-unix remotebackend-http
117 remotebackend-pipe-dnssec remotebackend-unix-dnssec remotebackend-http-dnssec
118 #remotebackend-pipe-nsec3 remotebackend-unix-nsec3 remotebackend-http-nsec3
119 #remotebackend-pipe-nsec3-narrow remotebackend-unix-nsec3-narrow remotebackend-http-nsec3-narrow
120
121 * Add -presigned to any gmysql test (except narrow) to
122 test presigned operation
123
124 * Add 'wait' (literally) after the context to not kill
125 pdns_server immediately after testing. 'nowait' will kill it.
126
127 * A cachettl can be supplied if you want to run tests with a
128 ttl setting set. The default cachettl is 0.
129
130 * Specifictest can be used to run only one single test.
131 __EOF__
132 exit 1
133 fi
134
135 make -C ../pdns sdig nsec3dig || exit 1
136 # Copy zones because the test might modify them (well only the dyndns stuff, but let's make this work for others as well)
137 for zone in $(grep zone named.conf | cut -f2 -d\")
138 do
139 cp $zone $zone.backup
140 done
141
142 rm -f pdns*.pid
143 rm -f *_tests
144
145 presigned=no
146
147 if [ "${context: -10}" = "-presigned" ]
148 then
149 presigned=yes
150 port=$((port-100))
151 context=${context%-presigned}
152 fi
153
154 optout=0
155
156 if [ "${context: -13}" = "-nsec3-optout" ]
157 then
158 optout=1
159 fi
160
161
162 case $context in
163 bind)
164 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
165 --no-shuffle --launch=bind --bind-config=./named.conf \
166 --send-root-referral \
167 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
168 --cache-ttl=$cachettl --no-config &
169 skipreasons="nodnssec nodyndns"
170 bindwait
171 ;;
172
173 bind-dnssec | bind-dnssec-nsec3 | bind-dnssec-nsec3-optout | bind-dnssec-nsec3-narrow)
174 rm -f dnssec.sqlite3
175 ../pdns/pdnssec --config-dir=. create-bind-db dnssec.sqlite3
176 for zone in $(grep zone named.conf | cut -f2 -d\")
177 do
178 securezone $zone
179 if [ $context = bind-dnssec-nsec3 ] || [ $context = bind-dnssec-nsec3-optout ]
180 then
181 ../pdns/pdnssec --config-dir=. set-nsec3 $zone "1 $optout 1 abcd" 2>&1
182 elif [ $context = bind-dnssec-nsec3-narrow ]
183 then
184 ../pdns/pdnssec --config-dir=. set-nsec3 $zone '1 1 1 abcd' narrow 2>&1
185 fi
186 done
187
188 if [ $context = bind-dnssec-nsec3 ]
189 then
190 extracontexts="bind dnssec nsec3"
191 skipreasons="nsec3 nodyndns"
192 elif [ $context = bind-dnssec-nsec3-optout ]
193 then
194 extracontexts="bind dnssec nsec3 nsec3-optout"
195 skipreasons="optout nodyndns"
196 elif [ $context = bind-dnssec-nsec3-narrow ]
197 then
198 extracontexts="bind dnssec narrow"
199 skipreasons="narrow nodyndns"
200 else
201 extracontexts="bind dnssec"
202 skipreasons="nodyndns"
203 fi
204
205 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
206 --no-shuffle --launch=bind --bind-config=./named.conf \
207 --bind-dnssec-db=./dnssec.sqlite3 \
208 --send-root-referral \
209 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes --experimental-direct-dnskey=yes \
210 --cache-ttl=$cachettl --no-config &
211 bindwait
212 ;;
213
214 gmysql-nodnssec)
215 [ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
216 [ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
217 [ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
218 [ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
219
220 mysqladmin --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" --force drop "$GMYSQLDB" \
221 || echo ignoring mysqladmin drop failure
222 mysqladmin --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" create "$GMYSQLDB"
223 mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
224 "$GMYSQLDB" < ../pdns/no-dnssec.schema.mysql.sql
225
226 tosql gmysql | mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
227 "$GMYSQLDB"
228
229 cat > pdns-gmysql.conf << __EOF__
230 launch=gmysql
231 gmysql-dbname=$GMYSQLDB
232 gmysql-user=$GMYSQLUSER
233 gmysql-host=$GMYSQLHOST
234 gmysql-password=$GMYSQLPASSWD
235 __EOF__
236
237 for zone in $(grep zone named.conf | cut -f2 -d\")
238 do
239 ../pdns/pdnssec --config-dir=. --config-name=gmysql rectify-zone $zone 2>&1
240 done
241
242 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
243 --no-shuffle --launch=gmysql \
244 --master --send-root-referral \
245 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes --experimental-direct-dnskey=yes \
246 --cache-ttl=$cachettl --no-config \
247 --gmysql-dbname="$GMYSQLDB" \
248 --gmysql-user="$GMYSQLUSER" \
249 --gmysql-host="$GMYSQLHOST" \
250 --gmysql-password="$GMYSQLPASSWD" &
251 skipreasons=nodnssec
252 ;;
253 mydns)
254 [ -z "$MYDNSDB" ] && MYDNSDB=pdnstest
255 [ -z "$MYDNSUSER" ] && MYDNSUSER=root
256 [ -z "$MYDNSHOST" ] && MYDNSHOST=localhost
257 [ -z "$MYDNSPASSWD" ] && MYDNSPASSWD=''
258
259 mysqladmin --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" --force drop "$MYDNSDB" \
260 || echo ignoring mysqladmin drop failure
261 mysqladmin --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" create "$MYDNSDB"
262 mysql --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" \
263 "$MYDNSDB" < ../modules/mydnsbackend/schema.sql
264
265 tosql mydns | grep -v 'double\.example\.com' | mysql --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" \
266 "$MYDNSDB"
267
268 cat > pdns-mydns.conf << __EOF__
269 launch=mydns
270 mydns-dbname=$MYDNSDB
271 mydns-user=$MYDNSUSER
272 mydns-host=$MYDNSHOST
273 mydns-password=$MYDNSPASSWD
274 __EOF__
275 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
276 --no-shuffle --launch=mydns \
277 --master --send-root-referral \
278 --cache-ttl=0 --no-config \
279 --mydns-rr-active=no --mydns-soa-active=no --mydns-use-minimal-ttl=no \
280 --mydns-dbname="$MYDNSDB" \
281 --mydns-user="$MYDNSUSER" \
282 --mydns-host="$MYDNSHOST" \
283 --mydns-password="$MYDNSPASSWD" &
284 skipreasons="nodnssec noent nodyndns"
285 ;;
286
287 gmysql | gmysql-nsec3 | gmysql-nsec3-optout |gmysql-nsec3-narrow)
288 [ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
289 [ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
290 [ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
291 [ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
292
293 mysqladmin --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" --force drop "$GMYSQLDB" \
294 || echo ignoring mysqladmin drop failure
295 mysqladmin --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" create "$GMYSQLDB"
296 mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
297 "$GMYSQLDB" < ../pdns/no-dnssec.schema.mysql.sql
298 mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
299 "$GMYSQLDB" < ../pdns/dnssec.schema.mysql.sql
300
301 tosql gmysql | mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
302 "$GMYSQLDB"
303
304 cat > pdns-gmysql.conf << __EOF__
305 launch=gmysql
306 gmysql-dbname=$GMYSQLDB
307 gmysql-user=$GMYSQLUSER
308 gmysql-host=$GMYSQLHOST
309 gmysql-password=$GMYSQLPASSWD
310 gmysql-dnssec
311 __EOF__
312 for zone in $(grep zone named.conf | cut -f2 -d\")
313 do
314 securezone $zone gmysql
315 if [ $context = gmysql-nsec3 ] || [ $context = gmysql-nsec3-optout ]
316 then
317 ../pdns/pdnssec --config-dir=. --config-name=gmysql set-nsec3 $zone "1 $optout 1 abcd" 2>&1
318 ../pdns/pdnssec --config-dir=. --config-name=gmysql rectify-zone $zone 2>&1
319 elif [ $context = gmysql-nsec3-narrow ]
320 then
321 ../pdns/pdnssec --config-dir=. --config-name=gmysql set-nsec3 $zone '1 1 1 abcd' narrow 2>&1
322 ../pdns/pdnssec --config-dir=. --config-name=gmysql rectify-zone $zone 2>&1
323 fi
324
325
326 done
327
328 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
329 --no-shuffle --launch+=random --launch+=gmysql --gmysql-dnssec \
330 --send-root-referral \
331 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes --experimental-direct-dnskey=yes \
332 --cache-ttl=$cachettl --no-config \
333 --gmysql-dbname="$GMYSQLDB" \
334 --gmysql-user="$GMYSQLUSER" \
335 --gmysql-host="$GMYSQLHOST" \
336 --gmysql-password="$GMYSQLPASSWD" &
337 if [ $context = gmysql-nsec3 ]
338 then
339 extracontexts="dnssec nsec3"
340 skipreasons="nsec3"
341 elif [ $context = gmysql-nsec3-optout ]
342 then
343 extracontexts="dnssec nsec3 nsec3-optout"
344 skipreasons="optout"
345 elif [ $context = gmysql-nsec3-narrow ]
346 then
347 extracontexts="dnssec narrow"
348 skipreasons="narrow"
349 else
350 extracontexts="dnssec"
351 fi
352
353 ;;
354 gpgsql | gpgsql-nsec3 | gpgsql-nsec3-optout)
355 [ -z "$GPGSQLDB" ] && GPGSQLDB=pdnstest
356 [ -z "$GPGSQLUSER" ] && GPGSQLUSER=$(whoami)
357
358 dropdb --user="$GPGSQLUSER" "$GPGSQLDB" || echo ignoring dropdb failure
359 createdb --user="$GPGSQLUSER" "$GPGSQLDB" || echo ignoring createdb failure # FIXME
360 psql --user="$GPGSQLUSER" "$GPGSQLDB" < ../pdns/no-dnssec.schema.pgsql.sql
361 psql --user="$GPGSQLUSER" "$GPGSQLDB" < ../pdns/dnssec.schema.pgsql.sql
362
363 tosql gpgsql | psql --user="$GPGSQLUSER" "$GPGSQLDB" 2>&1 | uniq -c
364
365 cat > pdns-gpgsql.conf << __EOF__
366 launch=gpgsql
367 gpgsql-dbname=$GPGSQLDB
368 gpgsql-user=$GPGSQLUSER
369 gpgsql-dnssec
370 __EOF__
371 for zone in $(grep zone named.conf | cut -f2 -d\")
372 do
373 securezone $zone gpgsql
374 if [ $context = gpgsql-nsec3 ] || [ $context = gpgsql-nsec3-optout ]
375 then
376 ../pdns/pdnssec --config-dir=. --config-name=gpgsql set-nsec3 $zone "1 $optout 1 abcd" 2>&1
377 ../pdns/pdnssec --config-dir=. --config-name=gpgsql rectify-zone $zone 2>&1
378 fi
379 done
380
381 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
382 --no-shuffle --launch=gpgsql --gpgsql-dnssec \
383 --send-root-referral \
384 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
385 --cache-ttl=$cachettl --no-config \
386 --gpgsql-dbname="$GPGSQLDB" \
387 --gpgsql-user="$GPGSQLUSER" &
388 if [ $context = gpgsql-nsec3 ]
389 then
390 extracontexts="dnssec nsec3"
391 elif [ $context = gpgsql-nsec3-optout ]
392 then
393 extracontexts="dnssec nsec3 nsec3-optout"
394 elif [ $context = gpgsql-nsec3-narrow ]
395 then
396 extracontexts="dnssec narrow"
397 else
398 extracontexts="dnssec"
399 fi
400
401 ;;
402 gpgsql-nodnssec)
403 [ -z "$GPGSQLDB" ] && GPGSQLDB=pdnstest
404 [ -z "$GPGSQLUSER" ] && GPGSQLUSER=$(whoami)
405
406 dropdb --user="$GPGSQLUSER" "$GPGSQLDB" || echo ignoring mysqladmin drop failure
407 createdb --user="$GPGSQLUSER" "$GPGSQLDB" || echo ignoring mysqladmin drop failure
408 psql --user="$GPGSQLUSER" "$GPGSQLDB" < ../pdns/no-dnssec.schema.pgsql.sql
409
410 tosql gpgsql | psql --user="$GPGSQLUSER" "$GPGSQLDB" 2>&1 | uniq -c
411
412 cat > pdns-gpgsql.conf << __EOF__
413 launch=gpgsql
414 gpgsql-dbname=$GPGSQLDB
415 gpgsql-user=$GPGSQLUSER
416 __EOF__
417
418 for zone in $(grep zone named.conf | cut -f2 -d\")
419 do
420 ../pdns/pdnssec --config-dir=. --config-name=gpgsql rectify-zone $zone 2>&1
421 done
422
423 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
424 --no-shuffle --launch=gpgsql \
425 --send-root-referral \
426 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
427 --cache-ttl=$cachettl --no-config \
428 --gpgsql-dbname="$GPGSQLDB" \
429 --gpgsql-user="$GPGSQLUSER" &
430 skipreasons=nodnssec
431 ;;
432
433
434 gsqlite3-nodnssec)
435 rm -f pdns.sqlite3
436 sqlite3 pdns.sqlite3 < ../pdns/no-dnssec.schema.sqlite3.sql
437 tosql gsqlite | sqlite3 pdns.sqlite3
438 echo ANALYZE\; | sqlite3 pdns.sqlite3
439
440 cat > pdns-gsqlite3.conf << __EOF__
441 launch=gsqlite3
442 gsqlite3-database=pdns.sqlite3
443 __EOF__
444 for zone in $(grep zone named.conf | cut -f2 -d\")
445 do
446 ../pdns/pdnssec --config-dir=. --config-name=gsqlite3 rectify-zone $zone 2>&1
447 done
448
449 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
450 --no-shuffle --launch=gsqlite3 \
451 --send-root-referral \
452 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
453 --cache-ttl=$cachettl --no-config \
454 --gsqlite3-database=pdns.sqlite3 &
455 skipreasons=nodnssec
456
457 ;;
458 opendbx-sqlite3)
459 rm -f pdns-opendbx.sqlite3
460 sqlite3 pdns-opendbx.sqlite3 < ../pdns/no-dnssec.schema.sqlite3.sql
461 tosql gsqlite | sqlite3 pdns-opendbx.sqlite3
462 sqlite3 pdns-opendbx.sqlite3 "ALTER TABLE domains ADD status CHARACTER(1) NOT NULL DEFAULT 'A'; \
463 ALTER TABLE domains ADD auto_serial INTEGER DEFAULT 0;"
464 echo ANALYZE\; | sqlite3 pdns-opendbx.sqlite3
465
466 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
467 --no-shuffle --launch=opendbx \
468 --send-root-referral \
469 --cache-ttl=$cachettl --no-config \
470 --opendbx-backend=sqlite3 --opendbx-host-read=./ --opendbx-host-write=./ \
471 --opendbx-database=pdns-opendbx.sqlite3 &
472 skipreasons="nodnssec noent nodyndns"
473
474 ;;
475 gsqlite3 | gsqlite3-nsec3 | gsqlite3-nsec3-optout)
476 rm -f pdns.sqlite3
477 sqlite3 pdns.sqlite3 < ../pdns/no-dnssec.schema.sqlite3.sql
478 sqlite3 pdns.sqlite3 < ../pdns/dnssec.schema.sqlite3.sql
479 tosql gsqlite | sqlite3 pdns.sqlite3
480 echo ANALYZE\; | sqlite3 pdns.sqlite3
481
482 cat > pdns-gsqlite3.conf << __EOF__
483 launch=gsqlite3
484 gsqlite3-database=pdns.sqlite3
485 gsqlite3-dnssec
486 __EOF__
487 for zone in $(grep zone named.conf | cut -f2 -d\")
488 do
489 securezone $zone gsqlite3
490 if [ $context = gsqlite3-nsec3 ] || [ $context = gsqlite3-nsec3-optout ]
491 then
492 ../pdns/pdnssec --config-dir=. --config-name=gsqlite3 set-nsec3 $zone "1 $optout 1 abcd" 2>&1
493 ../pdns/pdnssec --config-dir=. --config-name=gsqlite3 rectify-zone $zone 2>&1
494 fi
495 done
496
497 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
498 --no-shuffle --launch=gsqlite3 --gsqlite3-dnssec \
499 --send-root-referral \
500 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
501 --cache-ttl=$cachettl --no-config \
502 --gsqlite3-database=pdns.sqlite3 &
503 if [ $context = gsqlite3-nsec3 ]
504 then
505 extracontexts="dnssec nsec3"
506 elif [ $context = gsqlite3-nsec3-optout ]
507 then
508 extracontexts="dnssec nsec3 nsec3-optout"
509 else
510 extracontexts="dnssec"
511 fi
512 ;;
513 tinydns)
514 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
515 --no-shuffle --launch=tinydns \
516 --cache-ttl=$cachettl --no-config \
517 --send-root-referral \
518 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
519 --tinydns-dbfile=../modules/tinydnsbackend/data.cdb &
520 skipreasons="nodnssec noent nodyndns"
521 ;;
522 remotebackend-*)
523 remotetype=$(echo $context | cut -d- -f 2)
524 remotesec=$(echo $context | cut -d- -f 3)
525 narrow=$(echo $context | cut -d- -f 4)
526 testsdir=../modules/remotebackend/regression-tests/
527
528 # cleanup unbound-host.conf to avoid failures
529 rm -f unbound-host.conf
530
531 case $remotetype in
532 http)
533 connstr="http:url=http://localhost:62434/dns"
534 rm -f remotebackend-server.log
535 rm -f remotebackend-access.log
536 $testsdir/http-backend.rb &
537 echo $! > pdns-remotebackend.pid
538 set +e
539 # make sure it runs before continuing
540 loopcount=0
541 while [ $loopcount -lt 20 ]; do
542 res=$(curl http://localhost:62434/ping 2>/dev/null)
543 if [ "x$res" == "xpong" ]; then break; fi
544 sleep 1
545 let loopcount=loopcount+1
546 done
547 set -e
548 ;;
549 unix)
550 connstr="unix:path=/tmp/remote.socket"
551 socat unix-listen:/tmp/remote.socket,fork exec:$testsdir/unix-backend.rb &
552 echo $! > pdns-remotebackend.pid
553 ;;
554 pipe)
555 connstr="pipe:command=$testsdir/pipe-backend.rb"
556 ;;
557 *)
558 echo "Invalid usage"
559 exit 1
560 ;;
561 esac
562
563 skipreasons="nodnssec nodyndns"
564
565 if [ "$remotesec" = "nsec3" ]; then
566 remotedosec="yes"
567 if [ "$narrow" = "narrow" ]; then
568 extracontexts="dnssec nsec3 narrow"
569 skipreasons="narrow nsec3 nodyndns"
570 else
571 extracontexts="dnssec nsec3"
572 skipreasons="nsec3 nodyndns"
573 fi
574 remote_add_param="--remote-dnssec=yes"
575 else
576 if [ "$remotesec" = "dnssec" ]; then
577 remotedosec="yes"
578 remote_add_param="--remote-dnssec=yes"
579 extracontexts="dnssec"
580 skipreasons="nonsec3 nonarrow nodyndns"
581 fi
582 fi
583
584 # generate pdns.conf for pdnssec
585 cat > pdns-remote.conf <<EOF
586 launch=remote
587 remote-connection-string=$connstr
588 EOF
589
590 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
591 --no-shuffle --launch=remote \
592 --query-logging --loglevel=9 --cache-ttl=$cachettl --no-config \
593 --send-root-referral \
594 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
595 --remote-connection-string="$connstr" $remote_add_param &
596
597 echo "Setting up test database..."
598 # setup test database
599 rm -f $testsdir/remote.sqlite3
600 sqlite3 $testsdir/remote.sqlite3 < $testsdir/test-schema.sql
601 chmod 0666 $testsdir/remote.sqlite3
602 if [ "$remotedosec" = "yes" ]; then
603 echo "remote-dnssec=yes" >> pdns-remote.conf
604 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key example.com $testsdir/example.com.ksk ksk
605 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key example.com $testsdir/example.com.zsk.1 zsk
606 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key example.com $testsdir/example.com.zsk.2 zsk
607 ../pdns/pdnssec --config-dir=. --config-name=remote activate-zone-key example.com 1
608 ../pdns/pdnssec --config-dir=. --config-name=remote activate-zone-key example.com 2
609 ../pdns/pdnssec --config-dir=. --config-name=remote deactivate-zone-key example.com 3
610
611 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key up.example.com $testsdir/up.example.com.ksk ksk
612 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key up.example.com $testsdir/up.example.com.zsk.1 zsk
613 ../pdns/pdnssec --config-dir=. --config-name=remote import-zone-key up.example.com $testsdir/up.example.com.zsk.2 zsk
614 ../pdns/pdnssec --config-dir=. --config-name=remote activate-zone-key example.com 4
615 ../pdns/pdnssec --config-dir=. --config-name=remote activate-zone-key example.com 5
616 ../pdns/pdnssec --config-dir=. --config-name=remote deactivate-zone-key example.com 6
617
618 if [ "$remotesec" = "nsec3" ]; then
619 ../pdns/pdnssec --config-dir=. --config-name=remote set-nsec3 example.com
620 ../pdns/pdnssec --config-dir=. --config-name=remote set-nsec3 up.example.com
621 fi
622
623 fi
624
625 ;;
626 *)
627 echo unknown context $context
628 : > passed_tests
629 echo 'unknown-context-'"$context" > failed_tests
630 ./toxml $context
631 exit 1
632 esac
633
634 check_process
635
636 export port
637 export context
638 export extracontexts
639 export skipreasons
640 export testsdir
641 export optout
642
643 if [ $presigned = yes ]
644 then
645 skipreasons="$skipreasons nodyndns"
646
647 if [ ${context:0:6} = gmysql ]
648 then
649 context=${context}-presigned
650 [ -z "$GMYSQL2DB" ] && GMYSQL2DB=pdnstest2
651 [ -z "$GMYSQL2USER" ] && GMYSQL2USER=root
652 [ -z "$GMYSQL2HOST" ] && GMYSQL2HOST=localhost
653 [ -z "$GMYSQL2PASSWD" ] && GMYSQL2PASSWD=''
654
655 mysqladmin --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQL2HOST" --force drop "$GMYSQL2DB" \
656 || echo ignoring mysqladmin drop failure
657 mysqladmin --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQL2HOST" create "$GMYSQL2DB"
658 mysql --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQL2HOST" \
659 "$GMYSQL2DB" < ../pdns/no-dnssec.schema.mysql.sql
660 mysql --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQL2HOST" \
661 "$GMYSQL2DB" < ../pdns/dnssec.schema.mysql.sql
662
663 for zone in $(grep zone named.conf | cut -f2 -d\" | tac)
664 do
665 mysql --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQL2HOST" \
666 "$GMYSQL2DB" \
667 -e "INSERT INTO domains (name, type, master) VALUES('$zone','SLAVE','127.0.0.1:$port')"
668 done
669
670 port=$((port+100))
671
672 $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --socket-dir=./ \
673 --no-shuffle --launch=gmysql --gmysql-dnssec \
674 --send-root-referral \
675 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
676 --cache-ttl=$cachettl --query-cache-ttl=$cachettl --no-config --slave --retrieval-threads=4 \
677 --gmysql-dbname="$GMYSQL2DB" \
678 --gmysql-user="$GMYSQL2USER" \
679 --gmysql-host="$GMYSQL2HOST" \
680 --gmysql-password="$GMYSQL2PASSWD" \
681 --config-name=gmysql2 |& egrep -v "update records set ordername|insert into records" &
682 echo 'waiting for zones to be slaved'
683 loopcount=0
684 while [ $loopcount -lt 20 ]
685 do
686 sleep 10
687 todo=$(mysql --user="$GMYSQL2USER" --password="$GMYSQL2PASSWD" --host="$GMYSQl2HOST" \
688 "$GMYSQL2DB" -ss -e 'SELECT COUNT(id) FROM domains WHERE last_check IS NULL')
689 if [ $todo = 0 ]
690 then
691 break
692 fi
693 let loopcount=loopcount+1
694 done
695 if [ $todo -ne 0 ]; then
696 echo "AXFR FAILED" >> failed_tests
697 fi
698 elif [ ${context:0:8} = gsqlite3 ]
699 then
700 context=${context}-presigned
701 rm -f pdns.sqlite31
702 sqlite3 pdns.sqlite31 < ../pdns/no-dnssec.schema.sqlite3.sql
703 sqlite3 pdns.sqlite31 < ../pdns/dnssec.schema.sqlite3.sql
704
705 for zone in $(grep zone named.conf | cut -f2 -d\" | tac)
706 do
707 sqlite3 pdns.sqlite31 "INSERT INTO domains (name, type, master) VALUES('$zone','SLAVE','127.0.0.1:$port');"
708 done
709
710 port=$((port+100))
711
712 $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --socket-dir=./ \
713 --no-shuffle --launch=gsqlite3 --gsqlite3-dnssec \
714 --fancy-records --send-root-referral \
715 --cache-ttl=0 --query-cache-ttl=0 --no-config --slave --retrieval-threads=4 \
716 --gsqlite3-database=pdns.sqlite31 --gsqlite3-pragma-synchronous=0 \
717 --config-name=gsqlite32 |& egrep -v "update records set ordername|insert into records" &
718 echo 'waiting for zones to be slaved'
719 set +e
720 loopcount=0
721 while [ $loopcount -lt 20 ]
722 do
723 sleep 10
724 todo=$(sqlite3 pdns.sqlite31 'SELECT COUNT(id) FROM domains WHERE last_check IS NULL')
725 if [ $todo -eq 0 ]
726 then
727 if [ $todo = 0 ]
728 then
729 break
730 fi
731 fi
732 let loopcount=loopcount+1
733 done
734 if [ $todo -ne 0 ]; then
735 echo "AXFR FAILED" >> failed_tests
736 fi
737 set -e
738 sqlite3 pdns.sqlite31 ANALYZE;
739 elif [ ${context:0:4} = bind ]
740 then
741 context=${context}-presigned
742 sed -e 's/type master;/type slave;\n\tmasters { 127.0.0.1:'$port'; };/' -e 's/file "\([^"]\+\)/file "\1-slave/' < named.conf > named-slave.conf
743
744 for zone in $(grep zone named.conf | cut -f2 -d\")
745 do
746 rm -rf $zone-slave
747 done
748
749 rm -f dnssec-slave.sqlite3
750 ../pdns/pdnssec --config-dir=. create-bind-db dnssec-slave.sqlite3
751 port=$((port+100))
752
753 $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --socket-dir=./ \
754 --no-shuffle --launch=bind --bind-config=./named-slave.conf --slave \
755 --send-root-referral --retrieval-threads=1 --config-name=bind-slave \
756 --allow-2136-from=127.0.0.0/8 --experimental-rfc2136=yes \
757 --cache-ttl=$cachettl --no-config --bind-dnssec-db=./dnssec-slave.sqlite3 &
758 echo 'waiting for zones to be loaded'
759 bindwait bind-slave
760 fi
761 fi
762
763 ## TODO: give pdns a few seconds to startup or fail, then check if it did not fail
764 ## TODO: give sdig a timeout
765 nameserver=127.0.0.1 ./runtests $spectest
766 ./toxml
767 ./totar
768 if [ "$wait" = "wait" ]
769 then
770 echo tests done! push enter to terminate instance
771 read l
772 fi
773 kill $(cat pdns*.pid)
774 rm pdns*.pid
775
776 for zone in $(grep zone named.conf | cut -f2 -d\")
777 do
778 mv $zone.backup $zone
779 done
780
781 failed_tests=`wc -l failed_tests | cut -f 1 -d ' '`
782 if [ $failed_tests = 0 ];
783 then
784 exit 0;
785 else
786 for t in `cat failed_tests`
787 do
788 echo $t
789 cat $t/diff
790 done
791 exit 1;
792 fi