-
Notifications
You must be signed in to change notification settings - Fork 162
/
test
executable file
·119 lines (98 loc) · 5.56 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
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
#!/bin/bash
# This test checks whether path failover in SIG works as expected.
# It sets up two ASes connected by two paths. It disables one path
# and checks whether IP traffic is still going through. Then it
# enables the first path and disables the other one. It tries to pass
# IP packets between the ASes again.
# Docker topology:
#
# +---------------------------+ +---------------------------+
# | dispatcher1 network stack | | dispatcher2 network stack |
# | +-----------------+ | | +-----------------+ |
# | | tester1 | | | | tester2 | |
# | +-----------------+ | | +-----------------+ |
# | | | |
# | +-----------------+ | | +-----------------+ |
# | | sig1 | | | | sig2 | |
# | +-----------------+ | | +-----------------+ |
# | | | |
# | +-----------------+ | | +-----------------+ |
# | | dispatcher1 | | | | dispatcher2 | |
# | | :30041 | | | | :30041 | |
# | +-----------------+ | | +-----------------+ |
# | | | |
# | (route via dev sig) | | (route via dev sig) |
# | | | |
# | 242.254.100.2/24 | | 242.254.200.2/24 |
# +------------+--------------+ +-------------+-------------+
# | |
# +----------+------------+ +-----------+-----------+
# | bridge1 | | bridge2 |
# | 242.254.100.1/24 | | 242.254.200.1/24 |
# +-+-+-------------------+ +-------------------+-+-+
# | | | |
# | | +---------------------------------------------+ | |
# | +-+ patha +-+ |
# | | 242.254.100.3:50000 <-> 242.254.200.3:50000 | |
# | +---------------------------------------------+ |
# | |
# | +---------------------------------------------+ |
# +---+ pathb +----
# | 242.254.100.3:50000 <-> 242.254.200.4:50000 |
# +---------------------------------------------+
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
run_test() {(set -e
bash "$(rlocation __main__/go/tools/udpproxy/udpproxy)" --norun
bash "$(rlocation __main__/acceptance/sig_failover/dispatcher1)"
bash "$(rlocation __main__/acceptance/sig_failover/dispatcher2)"
bash "$(rlocation __main__/acceptance/sig_failover/sig1)"
bash "$(rlocation __main__/acceptance/sig_failover/sig2)"
docker-compose -f acceptance/sig_failover/docker-compose.yml up -d dispatcher1 dispatcher2 sig1 sig2
# Set up forward route on network stack 1 and 2 through sig tunnel device
# If this fails, the test is not stopped.
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester1 ip route add 242.254.200.2/32 dev sig || true
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester2 ip route add 242.254.100.2/32 dev sig || true
echo "Initial ping tests"
docker-compose -f acceptance/sig_failover/docker-compose.yml up -d patha pathb
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester1 ping -c 3 242.254.200.2
echo "Shutting down path A"
docker-compose -f acceptance/sig_failover/docker-compose.yml stop patha
echo "Check pings still work"
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester1 ping -c 3 242.254.200.2
echo "Shutting down path B, bringing up path A"
docker-compose -f acceptance/sig_failover/docker-compose.yml stop pathb
docker-compose -f acceptance/sig_failover/docker-compose.yml start patha
echo "Check pings still work"
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester1 ping -c 3 242.254.200.2
echo "Bringing up bath B"
docker-compose -f acceptance/sig_failover/docker-compose.yml start pathb
echo "Check pings still work"
docker-compose -f acceptance/sig_failover/docker-compose.yml run --rm tester1 ping -c 3 242.254.200.2
)}
set +e
run_test
RC=$?
ACCEPTANCE_ARTIFACTS=${ACCEPTANCE_ARTIFACTS:-./logs/}
mkdir -p $ACCEPTANCE_ARTIFACTS
echo "ls -la $ACCEPTANCE_ARTIFACTS"
ls -la $ACCEPTANCE_ARTIFACTS
echo "ls -la $ACCEPTANCE_ARTIFACTS/.."
ls -la $ACCEPTANCE_ARTIFACTS/..
echo "whoami"
whoami
echo "===="
for FILE in sig1-ff00_0_110.log sig1-ff00_0_111.log disp_1-ff00_0_110.log disp_1-ff00_0_111.log; do
docker-compose -f acceptance/sig_failover/docker-compose.yml run log_exporter cat /share/logs/$FILE > $ACCEPTANCE_ARTIFACTS/$FILE
done
docker-compose -f acceptance/sig_failover/docker-compose.yml down
find $ACCEPTANCE_ARTIFACTS
exit $RC