Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
6574-inet_res-migrate-testing-from-using-nsd-to...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6574-inet_res-migrate-testing-from-using-nsd-to-knotd.patch of Package erlang
From a63c0b417833e2d4c26aa91e011e9453ab309e06 Mon Sep 17 00:00:00 2001 From: Alexander Clouter <alex@digriz.org.uk> Date: Wed, 9 Aug 2023 16:19:53 +0100 Subject: [PATCH 04/10] inet_res: migrate testing from using nsd to knotd knotd supports UPDATE which is functionality incoming in a following commit we also amend the testing here to remove the five second warmup delay --- .github/dockerfiles/Dockerfile.ubuntu-base | 2 +- lib/kernel/test/inet_res_SUITE.erl | 22 ++- .../inet_res_SUITE_data/otptest/knot_inc.conf | 4 + .../inet_res_SUITE_data/otptest/nsd_inc.conf | 11 -- .../inet_res_SUITE_data/otptest/otptest.zone | 14 +- lib/kernel/test/inet_res_SUITE_data/run-ns | 144 +++++++++++------- 6 files changed, 119 insertions(+), 78 deletions(-) create mode 100644 lib/kernel/test/inet_res_SUITE_data/otptest/knot_inc.conf delete mode 100644 lib/kernel/test/inet_res_SUITE_data/otptest/nsd_inc.conf diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl index ac147551f2..95ebeaefa1 100644 --- a/lib/kernel/test/inet_res_SUITE.erl +++ b/lib/kernel/test/inet_res_SUITE.erl @@ -69,7 +69,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}, - {timetrap,{minutes,1}}]. + {timetrap,{seconds,15}}]. all() -> [basic, resolve, name_addr_and_cached, @@ -169,14 +169,17 @@ init_per_testcase(Func, Config) -> %% dbg:p(all, c), %% dbg:tpl(inet_res, query_nss_res, cx), ?P("init_per_testcase -> done:" - "~n NsSpec: ~p" - "~n Lookup: ~p", [NsSpec, Lookup]), + "~n NsSpec: ~p" + "~n Lookup: ~p", [NsSpec, Lookup]), [{nameserver, NsSpec}, {res_lookup, Lookup} | Config] catch SkipReason -> - ?P("init_per_testcase -> caught:" - "~n SkipReason: ~p", [SkipReason]), - {skip, SkipReason} + ?P("init_per_testcase -> skip: ~p", [SkipReason]), + {skip, SkipReason}; + Class : Reason : Stacktrace -> + ?P("init_per_testcase -> ~w: ~p" + "~n ~p~n", [Class, Reason, Stacktrace]), + {fail, Reason} end. end_per_testcase(_Func, Config) -> @@ -252,11 +255,16 @@ ns_start(ZoneDir, PrivDir, NS, P) -> "Running: "++_ -> ?P("ns_start -> running"), {ZoneDir,NS,P}; + "Skip: "++Reason -> + ?P("ns_start -> skip: " + "~n ~p", [Reason]), + ns_printlog(filename:join([PrivDir,ZoneDir,?LOG_FILE])), + throw(Reason); "Error: "++Error -> ?P("ns_start -> error: " "~n ~p", [Error]), ns_printlog(filename:join([PrivDir,ZoneDir,?LOG_FILE])), - throw(Error); + error(Error); _X -> ?P("ns_start -> retry"), ns_start(ZoneDir, PrivDir, NS, P) diff --git a/lib/kernel/test/inet_res_SUITE_data/otptest/knot_inc.conf b/lib/kernel/test/inet_res_SUITE_data/otptest/knot_inc.conf new file mode 100644 index 0000000000..6dd8c6dedf --- /dev/null +++ b/lib/kernel/test/inet_res_SUITE_data/otptest/knot_inc.conf @@ -0,0 +1,4 @@ +zone: + - domain: otptest + - domain: 0.0.127.in-addr.arpa. + - domain: 0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. diff --git a/lib/kernel/test/inet_res_SUITE_data/otptest/nsd_inc.conf b/lib/kernel/test/inet_res_SUITE_data/otptest/nsd_inc.conf deleted file mode 100644 index d4a434ff77..0000000000 --- a/lib/kernel/test/inet_res_SUITE_data/otptest/nsd_inc.conf +++ /dev/null @@ -1,11 +0,0 @@ -zone: - name: otptest. - zonefile: otptest.zone - -zone: - name: 0.0.127.in-addr.arpa. - zonefile: 0.0.127.in-addr.arpa.zone - -zone: - name: 0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. - zonefile: 0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.zone diff --git a/lib/kernel/test/inet_res_SUITE_data/otptest/otptest.zone b/lib/kernel/test/inet_res_SUITE_data/otptest/otptest.zone index 98b195fd97..e94866a1f9 100644 --- a/lib/kernel/test/inet_res_SUITE_data/otptest/otptest.zone +++ b/lib/kernel/test/inet_res_SUITE_data/otptest/otptest.zone @@ -38,20 +38,24 @@ ns IN AAAA ::127.0.0.253 resolve IN A 127.0.0.28 resolve IN AAAA ::127.0.0.28 cname.resolve IN CNAME resolve -wks.resolve IN WKS 127.0.0.28 TCP ( telnet smtp ) +;wks.resolve IN WKS 127.0.0.28 TCP ( TELNET SMTP ) +wks.resolve IN TYPE11 \# 9 7f00001c 06 00000140 ; ... (23 25) resolve IN HINFO "BEAM" "Erlang/OTP" ns.resolve IN NS resolve mx.resolve IN MX 10 resolve ;; The LOC latitude and longitude is chosen to have an exact ;; decimal degrees floating point representation -loc.resolve IN LOC 42 3 45 N 13 7 30 E 17m 100m 10000m 10m +loc.resolve IN LOC 42 3 45 N 13 7 30 E 17m 100m 10000m 10m _srv._tcp.resolve IN SRV 10 3 4711 resolve naptr.resolve IN NAPTR 10 5 "S" "HTTP" "" _srv._tcp.resolve txt.resolve IN TXT "Hej " "du " "glade " txt.resolve IN TXT "ta " "en " "spade!" -mb.resolve IN MB mx.resolve -mg.resolve IN MG lsa\.mg -mr.resolve IN MR lsa\.mr +;mb.resolve IN MB mx.resolve ; .otptest. +mb.resolve IN TYPE7 \# 20 02 6d78 07 7265736f6c7665 07 6f747074657374 00 +;mg.resolve IN MG lsa\.mg ; .otptest. +mg.resolve IN TYPE8 \# 16 06 6c73612e6d67 07 6f747074657374 00 +;mr.resolve IN MR lsa\.mr ; .otptest. +mr.resolve IN TYPE9 \# 16 06 6c73612e6d72 07 6f747074657374 00 minfo.resolve IN MINFO minfo-owner.resolve minfo-bounce.resolve ;uri.resolve IN URI 10 3 "http://erlang.org" uri.resolve IN TYPE256 \# 21 000a 0003 (68747470 3a2f2f 65726c616e67 2e 6f7267) diff --git a/lib/kernel/test/inet_res_SUITE_data/run-ns b/lib/kernel/test/inet_res_SUITE_data/run-ns index 2ed7e50f85..0c35eec913 100755 --- a/lib/kernel/test/inet_res_SUITE_data/run-ns +++ b/lib/kernel/test/inet_res_SUITE_data/run-ns @@ -2,7 +2,7 @@ ## ## %CopyrightBegin% ## -## Copyright Ericsson AB 2009-2022. All Rights Reserved. +## Copyright Ericsson AB 2009-2023. All Rights Reserved. ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. @@ -37,7 +37,8 @@ ## * Terminate name server and wait for it. ## ## Prints status lines starting with tag and colon (think mail header): -## Error: have given up, no name server started +## Skip: have given up; no point in starting this name server +## Error: have given up; failed to start name server ## Running: name server is running, waiting for "quit" ## Other tags: diagnostics info # @@ -48,76 +49,95 @@ PATH=/usr/sbin:/sbin:/usr/bin:/bin SHELL=/bin/sh export PATH SHELL +NS=knotd LOG_FILE=ns.log +CONF_FILE=knot.conf +INC_FILE=knot_inc.conf -CONF_FILE=nsd.conf -INC_FILE=nsd_inc.conf - +ERROR="Error: " error () { r=$? - echo "Error: $*" + echo "$ERROR$*" + exit $r +} + +skip () { + r=$? + echo "Skip: $*" exit $r } +ME="$0" +SELF=$$ + # Check argument: IP address test :"$1" != : || \ error "Empty argument 1: IP address !" +IP="$1" # Check argument: Port number expr "0$2" + 0 '>' 0 '&' "0$2" + 0 '<' 65536 >/dev/null 2>&1 || \ error "Invalid argument 2: port number !" +PORT="$2" # Check argument: Work/Zone subdir test :"$3" != : || \ error "Empty argument 3: Work/Zone subdir!" -SRCDIR="`dirname "$0"`/$3" +SRCDIR="`dirname "$ME"`/$3" test -d "$SRCDIR" || \ - error "Missing zone directory $SRCDIR !" + error "Missing zone directory: $SRCDIR !" test -f "$SRCDIR/$INC_FILE" || \ - error "Missing file: $SRCDIR/$INC_FILE !" + error "Missing include file: $SRCDIR/$INC_FILE !" +DIR="$3" -# Locate nsd and check version. -NS=nsd -for n in /usr/sbin/nsd /usr/bin/nsd /usr/local/sbin/nsd /usr/local/bin/nsd +# Locate name server and check version. +for n in /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin do - test -x "$n" && NS="$n" && break + test -x "$n/$NS" && { NS="$n/$NS"; break; } done -NS_VER="`"$NS" -v 2>&1`" || \ - error "Name server not found!" -NS_VER=$(echo "$NS_VER" | - ( read V1 V2 V3 IGNORED && - echo "$V1 $V3" ) ) -NS_FG="-d" + +NS_VER="`"$NS" -V 2>&1`" || \ + skip "$NS: Not found!" +NS_VER="`echo "$NS_VER" | head -1`" +{ echo "$NS_VER" | + grep -q -e ' 2[.]9[.]' -e ' 2[.][1-9][0-9][0-9]*[.]' \ + -e ' [3-9][.]' -e ' [1-9][0-9][0-9]*[.]' +} || skip "$NS_VER < 2.9" # Create working directory and cd to it -mkdir "$3" >/dev/null 2>&1 -cd "$3" >/dev/null 2>&1 || \ - error "Can not cd: $3 !" +mkdir "$DIR" >/dev/null 2>&1 +cd "$DIR" >/dev/null 2>&1 || \ + error "Cannot cd: $DIR !" DIR="$(pwd)" # Create $CONF_FILE cat >"$CONF_FILE" <<CONF_FILE # # $CONF_FILE for $NS_VER -# Generated by $0. +# Generated by $ME. # -# Copyright: see $0. +# Copyright: see $ME. # server: - zonesdir: "$DIR" - port: $2 - database: "nsd.db" - zonelistfile: "zone.list" - pidfile: "nsd.pid" - xfrdfile: "xfrd.state" - xfrdir: "$DIR" - username: "$LOGNAME" - verbosity: 2 - -remote-control: - control-enable: no - -include: "$DIR/$INC_FILE" + listen: $IP@$PORT + user: "$LOGNAME" + rundir: $DIR + +log: + - target: stdout + any: info + +control: + listen: /tmp/knot.$SELF.sock + +database: + storage: "$DIR" + +template: + - id: default + storage: "$DIR" + +include: $INC_FILE CONF_FILE # Copy all subdir files @@ -125,26 +145,42 @@ CONF_FILE cp -fp "$SRCDIR/$f" . done +# Start command +set -- "$NS" -c "$CONF_FILE" + # Start nameserver -echo "Cwd: `pwd`" +echo "Cwd: $DIR" echo "Nameserver: $NS_VER" -echo "Port: $2" -echo "ZoneDir: $3" -echo "Command: $NS $NS_FG -c $CONF_FILE" -t "$3" -$NS $NS_FG -c "$CONF_FILE" >"$LOG_FILE" 2>&1 </dev/null & +echo "IP: $IP" +echo "Port: $PORT" +echo "Command: $@" +"$@" >"$LOG_FILE" 2>&1 </dev/null & NS_PID=$! echo "Pid: $NS_PID" trap "kill $NS_PID >/dev/null 2>&1; wait $NS_PID >/dev/null 2>&1" \ 0 1 2 3 15 +NS_STARTED=" info: server started .* PID $NS_PID\$" + +# Wait for nameserver to start, start timer kill sub process +{ sleep 5 && + { echo "\n$ERROR$NS failed to start" + kill $SELF + } +} & +TIMER=$! + +{ + echo $(exec /bin/sh -c 'echo $PPID') # Subshell PID + exec tail -f "$LOG_FILE" +} | { + read TAIL_PID + sed -n "/$NS_STARTED/q" + kill $TAIL_PID # Cannot trust SIGPIPE to stop tail +} +kill $TIMER -sleep 5 # Give name server time to load its zone files - -if ps -p $NS_PID >/dev/null 2>&1 || ps p $NS_PID >/dev/null 2>&1; then - echo "Running: Enter \`\`quit'' to terminate nameserver[$NS_PID]..." - while read LINE; do - test :"$LINE" = :'quit' && break - done - echo "Closing: Terminating nameserver..." -else - error "$NS failed to start" -fi +echo "Running: Enter \`\`quit'' to terminate nameserver[$NS_PID]..." +while read LINE; do + test :"$LINE" = :'quit' && break +done +echo "Closing: Terminating nameserver..." -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor