File: recursive

package info (click to toggle)
dq 20251001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,376 kB
  • sloc: ansic: 13,644; python: 651; makefile: 382; sh: 336
file content (134 lines) | stat: -rw-r--r-- 3,484 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh
# 20221231

set -e

dir=`dirname "$0"`

# change directory to $AUTOPKGTEST_TMP
cd "${AUTOPKGTEST_TMP}"

echo "=== running fakedns ==="
curvednspk=`grep '^uz5' /etc/curvedns/README  | cut -d' ' -f1`
${dir}/fakedns.py "${curvednspk}" 2>fakedns.log &
fakednspid=$!
echo

cleanup() {
  ex=$?
  # kill fakedns
  kill -TERM "${fakednspid}" 1>/dev/null 2>/dev/null || :
  sleep 0.1
  kill -KILL "${fakednspid}" 1>/dev/null 2>/dev/null || :
  # reconfigure curvedns
  mv -f /etc/default/curvedns.bk /etc/default/curvedns
  /etc/init.d/curvedns stop 1>/dev/null 2>/dev/null
  # reconfigure dqcache
  cat /var/lib/dqcache/root/servers/.@ > /var/lib/dqcache/root/servers/@ || :
  killall -HUP dqcache || :
  killall -INT dqcache || :
  # print logs
  if [ "${ex}" -ne 0 ]; then
    (
      exec >&2
      echo "dqcache test failed !!!"
      echo
      echo "fakedns.log:"
      cat fakedns.log || :
      echo
      echo "systemctl status curvedns:"
      systemctl status curvedns || :
      echo
      echo "systemctl status dqcache:"
      systemctl status dqcache || :
      echo
      echo "journalctl -x --no-tail --no-pager -u curvedns.service:"
      journalctl -x --no-tail --no-pager -u curvedns.service || :
    )
  fi
  echo "journalctl -x --no-tail --no-pager -u dqcache.service:"
  journalctl -x --no-tail --no-pager -u dqcache.service || :
  echo
  rm -f *.log
  exit "${ex}"
}
trap "cleanup" EXIT TERM INT

echo '=== reconfigure curvedns ==='
cp /etc/default/curvedns /etc/default/curvedns.bk
sed -i 's/IP=.*/IP=127.0.0.4/' /etc/default/curvedns
sed -i 's/REMOTEIP=.*/REMOTEIP=127.0.0.3/' /etc/default/curvedns
systemctl reset-failed curvedns.service || :
systemctl --force restart curvedns.service
echo

echo '=== reconfigure + restart dqcache  ==='
echo '127.0.0.2' > '/var/lib/dqcache/root/servers/@'
systemctl reset-failed dqcache.service || :
systemctl --force restart dqcache.service
echo

# wait for dqcache to start
sleep 1

echo '=== dq query to dqcache server ==='
dq a localhost 127.0.0.1
echo

echo '=== dq query to fakeroot server ==='
dq a a.a 127.0.0.2 1>dq.log 2>&1
grep '^answer: \|^additional: \|^authority: ' dq.log
echo

echo '=== dq query to fakedns server ==='
dq a a.a 127.0.0.3 1>dq.log 2>&1
grep '^answer: \|^additional: \|^authority: ' dq.log
echo

echo '=== dq query to curvedns server ==='
dq a a.a 127.0.0.4 1>dq.log 2>&1
grep '^answer: \|^additional: \|^authority: ' dq.log
echo

echo '=== dq encrypted query to curvedns server ==='
dq -k "${curvednspk}" a a.a 127.0.0.4 1>dq.log 2>&1
grep '^answer: \|^additional: \|^authority: ' dq.log
echo

echo '=== dq query to dqcache server ==='
dq a a.a 127.0.0.1 1>dq.log 2>&1
grep '^answer: \|^additional: \|^authority: ' dq.log
echo

echo '=== main part ==='
domainnames="a b c d e f g h i j k l m n o p q r s t u v w x y z"

# send queries
for x in ${domainnames}; do
  for y in ${domainnames}; do
    name="$x.$y.$z"
    dq a "${name}" 127.0.0.1 1>"${name}.log" 2>&1
    if ! grep '^answer: ' "${name}.log"; then
      exit 2
    fi
  done
done

# stop fakedns, dqcache should have all queries cached
kill -TERM "${fakednspid}" 1>/dev/null 2>/dev/null || :
kill -KILL "${fakednspid}" 1>/dev/null 2>/dev/null || :

# send queries again and parallel
for x in ${domainnames}; do
  for y in ${domainnames}; do
    (
      name="$x.$y.$z"
      dq a "${name}" 127.0.0.1 1>"${name}.log" 2>&1
      if ! grep '^answer: ' "${name}.log"; then
        exit 3
      fi
    ) &
  done
  wait
done
exit 0