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