-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathtest
executable file
·88 lines (73 loc) · 2.24 KB
/
test
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
#!/bin/bash
# Whenever immutable fields in the topology file of an infra element is
# changed, if the process receives a SIGHUP it will fail to reload the config.
. acceptance/common.sh
TEST_NAME="topo_invalid_reloads"
TEST_TOPOLOGY="topology/Tiny.topo"
IA=${IA:-1-ff00:0:112}
IA_FILE="$(ia_file $IA)"
SRC_AS_FILE="$(as_file $IA)"
TOPO="gen/ISD1/AS$SRC_AS_FILE/topology.json"
test_setup() {
set -e
./scion.sh topology zkclean -c $TEST_TOPOLOGY -d -sd=go -ps=go
for sd in gen/ISD1/*/*/*.toml; do
sed -i '/\[logging\.file\]/a FlushInterval = 1' "$sd"
done
./tools/dc start scion_ps$IA_FILE-1 scion_sd$IA_FILE
docker_status
}
test_run() {
set -e
cp "gen/ISD1/AS$SRC_AS_FILE/ps$IA_FILE-1/topology.json" "gen/ISD1/AS$SRC_AS_FILE/"
test_ps_immutable "ps1-ff00_0_111-1" "gen/ISD1/AS$SRC_AS_FILE/ps$IA_FILE-1/topology.json"
test_immutable "sd1-ff00_0_111" "gen/ISD1/AS$SRC_AS_FILE/endhost/topology.json"
}
test_ps_immutable() {
test_immutable $1 $2
jq '.PathService[].Addrs.IPv4.Public.Addr = "242.42.42.42"' $TOPO | sponge $2
check_no_reload $1 "Addr"
jq '.PathService[].Addrs.IPv4.Public.L4Port = 42424' $TOPO | sponge $2
check_no_reload $1 "L4Port"
}
test_immutable() {
jq '.ISD_AS = "1-ff00:0:111"' $TOPO | sponge $2
check_no_reload "$1" "ISD_AS"
jq '.Core = true' $TOPO | sponge $2
check_no_reload "$1" "Core"
jq '.Overlay = "IPv6"' $TOPO | sponge $2
check_no_reload "$1" "Overlay"
jq '.MTU = 42' $TOPO | sponge $2
check_no_reload "$1" "MTU"
}
check_no_reload() {
./tools/dc scion kill -s HUP scion_"$1"
sleep 1
grep -q "Reloaded topology" "logs/$1.log" || local failed=$?
if [ -z ${failed+x} ]; then
echo "FAIL: Successful reload should not be possible. step=( $2 )"
return 1
fi
}
print_help() {
echo
cat <<-_EOF
$PROGRAM name
return the name of this test
$PROGRAM setup
execute only the setup phase.
$PROGRAM run
execute only the run phase.
$PROGRAM teardown
execute only the teardown phase.
_EOF
}
PROGRAM=`basename "$0"`
COMMAND="$1"
case "$COMMAND" in
name)
echo $TEST_NAME ;;
setup|run|teardown)
"test_$COMMAND" ;;
*) print_help; exit 1 ;;
esac