]>
Commit | Line | Data |
---|---|---|
cf4d037d PD |
1 | #!/usr/bin/env bash |
2 | set -e | |
9091cf89 PL |
3 | if [ "${PDNS_DEBUG}" = "YES" ]; then |
4 | set -x | |
5 | fi | |
7dbdd1e7 | 6 | |
d9c6538e PL |
7 | export PDNS=${PDNS:-${PWD}/../pdns/pdns_server} |
8 | export PDNS2=${PDNS2:-${PWD}/../pdns/pdns_server} | |
1cedb848 PL |
9 | export PDNSRECURSOR=${PDNSRECURSOR:-${PWD}/../pdns/recursordist/pdns_recursor} |
10 | export RECCONTROL=${RECCONTROL:-${PWD}/../pdns/recursordist/rec_control} | |
d9c6538e | 11 | export SDIG=${SDIG:-${PWD}/../pdns/sdig} |
a4437033 | 12 | export NOTIFY=${NOTIFY:-${PWD}/../pdns/pdns_notify} |
d9c6538e PL |
13 | export NSEC3DIG=${NSEC3DIG:-${PWD}/../pdns/nsec3dig} |
14 | export SAXFR=${SAXFR:-${PWD}/../pdns/saxfr} | |
15 | export ZONE2SQL=${ZONE2SQL:-${PWD}/../pdns/zone2sql} | |
8c907653 | 16 | export ZONE2LDAP=${ZONE2LDAP:-${PWD}/../pdns/zone2ldap} |
fd5076c8 | 17 | export PDNSUTIL=${PDNSUTIL:-${PWD}/../pdns/pdnsutil} |
d9c6538e | 18 | export PDNSCONTROL=${PDNSCONTROL:-${PWD}/../pdns/pdns_control} |
869c68a4 | 19 | export RESOLVERIP=${RESOLVERIP:-8.8.8.8} |
d9c6538e | 20 | |
a48c8a6c | 21 | |
8b8c5060 KM |
22 | ALGORITHM=${ALGORITHM:="hmac-md5"} |
23 | KEY=${KEY:="kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="} | |
24 | ||
04aaf527 PD |
25 | MAKE=${MAKE:-make} |
26 | ||
36077044 KM |
27 | export ALGORITHM |
28 | export KEY | |
29 | ||
5506c989 KM |
30 | trap "kill_process 2" EXIT INT TERM |
31 | ||
3adde0d2 | 32 | source ../regression-tests/common |
7dbdd1e7 | 33 | |
a45871d3 PD |
34 | bindwait () |
35 | { | |
a3a4cb13 | 36 | check_process |
b563f71b | 37 | configname=$1 |
00b9f06d | 38 | domcount=$(grep -c ^zone named.conf) |
d9c6538e | 39 | if [ ! -x $PDNSCONTROL ] |
e08d1e35 | 40 | then |
c823f41c | 41 | echo "No pdns_control found" |
5506c989 | 42 | exit |
2ede4134 PD |
43 | fi |
44 | loopcount=0 | |
5837ffbc | 45 | |
e08d1e35 KM |
46 | while [ $loopcount -lt 20 ] |
47 | do | |
e5da48f4 | 48 | sleep 5 |
d9c6538e | 49 | done=$( ($PDNSCONTROL --config-name=$configname --socket-dir=. --no-config bind-domain-status || true) | grep -c 'parsed into memory' || true ) |
e08d1e35 KM |
50 | if [ $done = $domcount ] |
51 | then | |
a45871d3 PD |
52 | return |
53 | fi | |
2ede4134 | 54 | let loopcount=loopcount+1 |
a45871d3 | 55 | done |
2ede4134 | 56 | |
e08d1e35 KM |
57 | if [ $done != $domcount ] |
58 | then | |
87d6c352 | 59 | echo "Domain parsing failed" >> failed_tests |
2ede4134 | 60 | fi |
a45871d3 PD |
61 | } |
62 | ||
b8adb30d KM |
63 | securezone () |
64 | { | |
65 | local zone=$1 | |
66 | local configname=$2 | |
70f0f8c4 | 67 | |
b8adb30d KM |
68 | if [ -n "$configname" ] |
69 | then | |
70 | configname="--config-name=$configname" | |
71 | fi | |
72 | if [ "${zone: 0:16}" = "secure-delegated" ] | |
73 | then | |
fd5076c8 | 74 | $PDNSUTIL --config-dir=. $configname import-zone-key $zone $zone.private ksk 2>&1 |
e65dffd2 | 75 | $PDNSUTIL --config-dir=. $configname add-zone-key $zone rsasha256 1024 zsk active 2>&1 |
fd5076c8 PL |
76 | $PDNSUTIL --config-dir=. $configname rectify-zone $zone 2>&1 |
77 | $PDNSUTIL --config-dir=. $configname set-publish-cds $zone 2>&1 | |
78 | $PDNSUTIL --config-dir=. $configname set-publish-cdnskey $zone 2>&1 | |
b8adb30d | 79 | else |
70f0f8c4 | 80 | # check if PKCS#11 should be used |
d372242f | 81 | if [ "$pkcs11" -eq 1 ]; then |
70f0f8c4 AT |
82 | if [ "$slot" == "" ]; then |
83 | slot=0 | |
84 | else | |
85 | slot=$((slot+1)) | |
86 | fi | |
70f0f8c4 | 87 | sudo softhsm --init-token --slot $slot --label label$slot --pin 123$slot --so-pin 123$slot |
d113baca | 88 | kid=`$PDNSUTIL --config-dir=. $configname hsm assign $zone ecdsa256 zsk softhsm label$slot 123$slot label$slot 2>&1 | grep softhsm | awk '{ print $NF }'` |
fd5076c8 PL |
89 | kid=`$PDNSUTIL --config-dir=. $configname show-zone $zone | grep 'ID =.*ZSK' | awk '{ print $3 }'` |
90 | $PDNSUTIL --config-dir=. $configname hsm create-key $zone $kid | |
70f0f8c4 | 91 | else |
fd5076c8 | 92 | $PDNSUTIL --config-dir=. $configname secure-zone $zone 2>&1 |
f889ab99 PL |
93 | if [ "${zone: 0:20}" = "cdnskey-cds-test.com" ]; then |
94 | $PDNSUTIL --config-dir=. $configname set-publish-cds $zone 2>&1 | |
95 | $PDNSUTIL --config-dir=. $configname set-publish-cdnskey $zone 2>&1 | |
96 | fi | |
70f0f8c4 | 97 | fi |
b8adb30d KM |
98 | fi |
99 | } | |
100 | ||
5506c989 KM |
101 | kill_process () |
102 | { | |
103 | set +e | |
104 | trap - EXIT INT TERM | |
105 | ||
5ca4f3a0 KM |
106 | if [ $1 -gt 1 ] |
107 | then | |
108 | echo "exitvalue$1" >> failed_tests | |
109 | ./toxml | |
110 | ./totar | |
111 | fi | |
112 | ||
5506c989 KM |
113 | pids=$(cat pdns*.pid) |
114 | ||
115 | if [ -n "$pids" ] | |
116 | then | |
117 | kill $pids | |
118 | # make sure they die. | |
119 | loopcount=0 | |
120 | done=0 | |
121 | while [ $loopcount -lt 10 ] && [ $done -eq 0 ] | |
122 | do | |
123 | done=1 | |
124 | for pid in $pids | |
125 | do | |
126 | kill -0 $pid > /dev/null 2>&1 | |
127 | if [ $? -eq 0 ]; | |
128 | then | |
129 | done=0 | |
130 | fi | |
131 | done | |
132 | let loopcount=loopcount+1 | |
133 | sleep 1 | |
134 | done | |
135 | ||
136 | kill -9 $pids | |
137 | fi | |
138 | ||
139 | rm pdns*.pid | |
140 | exit $1 | |
a3a4cb13 AT |
141 | } |
142 | ||
e08d1e35 KM |
143 | if [ ! -x $PDNS ] |
144 | then | |
c823f41c | 145 | echo "$PDNS is not executable binary" |
5506c989 | 146 | exit |
a3a4cb13 AT |
147 | fi |
148 | ||
e08d1e35 KM |
149 | if [ ! -x $PDNS2 ] |
150 | then | |
c823f41c | 151 | echo "$PDNS2 is not executable binary" |
5506c989 | 152 | exit |
a3a4cb13 AT |
153 | fi |
154 | ||
3293ac22 | 155 | address="${PDNS_LISTEN_ADDR:-127.0.0.1}" |
e65a021a PD |
156 | port=$1 |
157 | [ -z "$port" ] && port=5300 | |
7dbdd1e7 | 158 | context=$2 |
c5f8ef18 | 159 | [ -z "$context" ] && context=bind-dnssec |
8659dbcf | 160 | wait=$3 |
388cdf7a RA |
161 | [ -z "$wait" ] && wait=nowait |
162 | cachettl=$4 | |
163 | [ -z "$cachettl" ] && cachettl=0 | |
164 | spectest=$5 | |
7dbdd1e7 | 165 | |
905057ba | 166 | testsdir=./tests |
53f66707 | 167 | |
04676415 | 168 | if [ "$port" = help ] || [ "$context" = help ] || [ "$port" = "--help" ] || [ "$context" = "--help" ] |
99df80c6 PD |
169 | then |
170 | set +x | |
f4644dfc | 171 | grep -v '^#' << '__EOF__' |
99df80c6 | 172 | |
388cdf7a | 173 | Usage: ./start-test-stop <port> [<context>] [wait|nowait] [<cachettl>] [<specifictest>] |
99df80c6 PD |
174 | |
175 | context is one of: | |
b8adb30d | 176 | bind bind-dnssec bind-dnssec-nsec3 bind-dnssec-nsec3-optout bind-dnssec-nsec3-narrow |
54eb2cf7 | 177 | geoip geoip-nsec3-narrow |
b8adb30d | 178 | gmysql-nodnssec gmysql gmysql-nsec3 gmysql-nsec3-optout gmysql-nsec3-narrow |
4f983d1b | 179 | godbc_mssql-nodnssec godbc_mssql godbc_mssql-nsec3 godbc_mssql-nsec3-optout godbc_mssql-nsec3-narrow |
e0a407dc | 180 | goracle-nodnssec goracle goracle-nsec3 goracle-nsec3-optout goracle-nsec3-narrow |
6d8a9a25 | 181 | godbc_sqlite3-nodnssec godbc_sqlite3 godbc_sqlite3-nsec3 godbc_sqlite3-nsec3-optout godbc_sqlite3-narrow |
e0a407dc KM |
182 | gpgsql-nodnssec gpgsql gpgsql-nsec3 gpgsql-nsec3-optout gpgsql-nsec3-narrow |
183 | gsqlite3-nodnssec gsqlite3 gsqlite3-nsec3 gsqlite3-nsec3-optout gsqlite3-nsec3-narrow | |
42f1f726 | 184 | lmdb-nodnssec lmdb |
267af0fb | 185 | mydns |
e0a407dc KM |
186 | opendbx-sqlite3 |
187 | oracle-nodnssec oracle oracle-nsec3 | |
a7db8aa6 AT |
188 | remotebackend-pipe remotebackend-unix remotebackend-http remotebackend-zeromq |
189 | remotebackend-pipe-dnssec remotebackend-unix-dnssec remotebackend-http-dnssec remotebackend-zeromq-dnssec | |
f4644dfc PD |
190 | #remotebackend-pipe-nsec3 remotebackend-unix-nsec3 remotebackend-http-nsec3 |
191 | #remotebackend-pipe-nsec3-narrow remotebackend-unix-nsec3-narrow remotebackend-http-nsec3-narrow | |
e0a407dc | 192 | tinydns |
30c3104d | 193 | ldap-tree ldap-simple ldap-strict |
63c1a37c | 194 | lua2 lua2-dnssec lua2-nsec3 lua2-nsec3-narrow |
e0a407dc | 195 | #ext-nsd ext-nsd-nsec ext-nsd-nsec3 ext-bind ext-bind-nsec ext-bind-nsec3 |
99df80c6 | 196 | |
40b0c97f | 197 | * Add -presigned to any ext-nsd, ext-bind, bind, gmysql or gsqlite3 test (except narrow) |
3a68d5f4 | 198 | to test presigned operation. |
794c2f92 | 199 | |
e08d1e35 KM |
200 | * Add -both to any bind or gmysql test (except narrow) to |
201 | test normal and presigned operation. | |
202 | ||
388cdf7a RA |
203 | * Add 'wait' (literally) after the context to not kill |
204 | pdns_server immediately after testing. 'nowait' will kill it. | |
205 | ||
206 | * A cachettl can be supplied if you want to run tests with a | |
207 | ttl setting set. The default cachettl is 0. | |
208 | ||
209 | * Specifictest can be used to run only one single test. | |
99df80c6 | 210 | __EOF__ |
5506c989 | 211 | exit |
99df80c6 PD |
212 | fi |
213 | ||
6e038794 | 214 | for prog in $SDIG $SAXFR $NOTIFY $NSEC3DIG; do |
dbbaa337 | 215 | if `echo $prog | grep -q '\.\./pdns'`; then |
e55a07c9 | 216 | ${MAKE} -C ../pdns ${prog##*../pdns/} || exit |
d9c6538e PL |
217 | fi |
218 | done | |
219 | ||
d5d97c2f | 220 | # Copy original zones because the test might modify them (well only the dyndns stuff, but let's make this work for others as well) |
905057ba | 221 | for zone in $(grep 'zone ' named.conf | cut -f2 -d\") |
388cdf7a | 222 | do |
905057ba | 223 | if [ -f zones/$zone.orig ] |
d5d97c2f | 224 | then |
905057ba | 225 | cp -f zones/$zone.orig zones/$zone |
d5d97c2f | 226 | fi |
388cdf7a | 227 | done |
8e9c4415 | 228 | |
794c2f92 | 229 | rm -f pdns*.pid |
dff32e09 | 230 | rm -f *_tests |
52011cd7 | 231 | rm -f pdns-*.conf |
794c2f92 PD |
232 | |
233 | presigned=no | |
e5da48f4 | 234 | both=no |
794c2f92 | 235 | |
3a68d5f4 | 236 | if [[ "$context" =~ .+-presigned.* ]] |
794c2f92 PD |
237 | then |
238 | presigned=yes | |
239 | port=$((port-100)) | |
3a68d5f4 KM |
240 | eval "$(echo "$context" | sed -r 's/(.+)(-presigned)(-(.*))?/context=\1 presignedcontext=\4/')" |
241 | if [ -z "$presignedcontext" ] | |
242 | then | |
243 | presignedcontext=$context | |
244 | fi | |
794c2f92 PD |
245 | fi |
246 | ||
e5da48f4 KM |
247 | if [ "${context: -5}" = "-both" ] |
248 | then | |
249 | both=yes | |
250 | port=$((port-100)) | |
251 | context=${context%-both} | |
3a68d5f4 | 252 | presignedcontext=$context |
e5da48f4 KM |
253 | fi |
254 | ||
b8adb30d | 255 | optout=0 |
70f0f8c4 | 256 | pkcs11=0 |
b8adb30d KM |
257 | |
258 | if [ "${context: -13}" = "-nsec3-optout" ] | |
259 | then | |
260 | optout=1 | |
261 | fi | |
262 | ||
70f0f8c4 AT |
263 | if [ "${context: -7}" = "-pkcs11" ] |
264 | then | |
d372242f | 265 | pkcs11=1 |
70f0f8c4 AT |
266 | context=${context:0:-7} |
267 | fi | |
268 | ||
95302209 | 269 | # check for lua |
de9a69a9 | 270 | if $PDNS --version 2>&1 | grep Features: | grep -q "lua" |
95302209 AT |
271 | then |
272 | lua_prequery="--lua-prequery-script=./check_stest_source" | |
273 | skiplua=0 | |
274 | else | |
275 | lua_prequery="" | |
276 | skiplua=1 | |
277 | fi | |
278 | ||
905057ba | 279 | source backends/common |
db167258 | 280 | |
905057ba | 281 | start_master |
a3a4cb13 | 282 | |
95302209 | 283 | if [ "$skiplua" == "1" ]; then |
7eb7ac3d | 284 | skipreasons="$skipreasons nolua" |
95302209 AT |
285 | fi |
286 | ||
a3a4cb13 AT |
287 | check_process |
288 | ||
e5da48f4 KM |
289 | dotests () { |
290 | nameserver=127.0.0.1 ./runtests $spectest | |
291 | ./toxml | |
292 | ./totar | |
293 | ||
bd71d3e3 KM |
294 | cat ./trustedkeys |
295 | ||
e5da48f4 KM |
296 | if [ -s "./failed_tests" ] |
297 | then | |
298 | for t in `cat failed_tests` | |
299 | do | |
300 | echo -e "\n\n$t" | |
7c85cf48 | 301 | cat ${testsdir}/$t/diff |
e5da48f4 | 302 | done |
dcdd4fb7 KM |
303 | if [ "${!1}" -eq 0 ] |
304 | then | |
305 | eval "$1=1" | |
306 | fi | |
e5da48f4 KM |
307 | fi |
308 | } | |
794c2f92 | 309 | |
7dbdd1e7 | 310 | ## TODO: give sdig a timeout |
e5da48f4 KM |
311 | |
312 | RETVAL=0 | |
313 | ||
98e8981c | 314 | export address |
e5da48f4 KM |
315 | export port |
316 | export context | |
317 | export extracontexts | |
318 | export skipreasons | |
319 | export testsdir | |
320 | export optout | |
321 | ||
dcdd4fb7 | 322 | sleep 2 |
e5da48f4 KM |
323 | |
324 | if [ $presigned = no ] || [ $both = yes ] | |
325 | then | |
55b3da69 | 326 | dotests RETVAL |
e5da48f4 KM |
327 | fi |
328 | ||
329 | if [ $presigned = yes ] || [ $both = yes ] | |
330 | then | |
905057ba | 331 | start_slave |
e5da48f4 KM |
332 | |
333 | export port | |
334 | export context | |
335 | export skipreasons | |
336 | ||
55b3da69 | 337 | dotests RETVAL |
e5da48f4 KM |
338 | fi |
339 | ||
8659dbcf PD |
340 | if [ "$wait" = "wait" ] |
341 | then | |
c823f41c | 342 | echo tests done! push enter to terminate instance |
8659dbcf PD |
343 | read l |
344 | fi | |
e5da48f4 | 345 | |
5506c989 | 346 | trap "kill_process $RETVAL" EXIT |