Skip to content

Commit a6d1c2e

Browse files
mwfarbjuagargi
authored andcommitted
[webapp] Adding network connection test (#47)
* [webapp] Adding network connection test * Revised from review: added scmp echo and correct ip * Changed test to use RemoteOverlay from topology.json * Fixes #53 * modified connection test to check all br interfaces * Addressing commnets from juan
1 parent c7a9fed commit a6d1c2e

File tree

4 files changed

+106
-17
lines changed

4 files changed

+106
-17
lines changed

webapp/tests/health/beaconstest.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ timeout_ms=20000
88
pcb_ms=10000
99

1010
# get local IA
11-
ia=`cat ~/go/src/github.com/scionproto/scion/gen/ia`
11+
iaFile=$(cat ~/go/src/github.com/scionproto/scion/gen/ia)
12+
ia=$(echo $iaFile | sed "s/_/:/g")
1213
echo "IA found: $ia"
1314

1415
# format log file and beacons grep string
15-
fsafe_ia=$(echo $ia | sed "s/:/_/g")
16-
logfile="~/go/src/github.com/scionproto/scion/logs/bs${fsafe_ia}-1.DEBUG"
16+
logfile=~/go/src/github.com/scionproto/scion/logs/bs${iaFile}-1.DEBUG
1717
echo "Log: $logfile"
1818

1919
# seek last log entry for verified PCBs
@@ -35,8 +35,7 @@ do
3535
fi
3636

3737
# seek the last pcb verified, and determine age
38-
last_pcb=$(grep "${regex_pcb}" \
39-
~/go/src/github.com/scionproto/scion/logs/bs${fsafe_ia}-1.DEBUG | tail -n 1)
38+
last_pcb=$(grep -a "${regex_pcb}" $logfile | tail -n 1)
4039
date=${last_pcb:0:32}
4140
epoch_l=$(date -d "${date}" +"%s%6N")
4241
diff=$((epoch_n-epoch_l))

webapp/tests/health/default.json

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
{
22
"tests": [
3+
{
4+
"label": "netcheck",
5+
"script": "netcheck.sh",
6+
"desc": "Border router ICMP test"
7+
},
38
{
49
"label": "timecheck",
510
"script": "timecheck.sh",
611
"desc": "Network time synchronization test"
712
},
8-
{
9-
"label": "checkbeacons",
10-
"script": "beaconstest.sh",
11-
"desc": "Receiving beacons test"
12-
},
1313
{
1414
"label": "checkdiskspace",
1515
"script": "testAvailDiskSpace.sh",
16-
"desc": "Tests for available disk space"
16+
"desc": "Available disk space tests"
1717
},
1818
{
1919
"label": "checkmemory",
2020
"script": "testTotalMem.sh",
21-
"desc": "Tests for total memory"
21+
"desc": "Total memory space tests"
2222
},
2323
{
2424
"label": "checkVPN",
2525
"script": "testVPN.sh",
26-
"desc": "Tests for VPN configuration"
26+
"desc": "VPN configuration tests"
27+
},
28+
{
29+
"label": "checkrepo",
30+
"script": "testVersion.sh",
31+
"desc": "Version tests for scion and scion-apps"
2732
},
2833
{
2934
"label": "checkrunnngstatus",
3035
"script": "testSCIONRunning.sh",
31-
"desc": "Tests for SCION Running status"
36+
"desc": "SCION running test"
3237
},
3338
{
34-
"label": "checkrepo",
35-
"script": "testVersion.sh",
36-
"desc": "Tests to check if git repo scion and scion-apps are up to date"
39+
"label": "scmpcheck",
40+
"script": "scmpcheck.sh",
41+
"desc": "Border router SCMP test"
42+
},
43+
{
44+
"label": "checkbeacons",
45+
"script": "beaconstest.sh",
46+
"desc": "Receiving beacons test"
3747
}
3848
]
3949
}

webapp/tests/health/netcheck.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# test will fail for non-zero exit and/or bytes in stderr
3+
4+
# get local IA
5+
iaFile=$(cat ~/go/src/github.com/scionproto/scion/gen/ia)
6+
ia=$(echo $iaFile | sed "s/_/:/g")
7+
echo "IA found: $ia"
8+
9+
isd=$(echo ${iaFile} | cut -d"-" -f1)
10+
as=$(echo ${iaFile} | cut -d"-" -f2)
11+
topologyFile=$SC/gen/ISD$isd/AS$as/endhost/topology.json
12+
13+
# get remote addresses from interfaces
14+
ip_dsts=$(cat $topologyFile | python -c "import sys, json
15+
brs = json.load(sys.stdin)['BorderRouters']
16+
for b in brs:
17+
for i in brs[b]['Interfaces']:
18+
print brs[b]['Interfaces'][i]['RemoteOverlay']['Addr']")
19+
20+
# test icmp ping on each interface
21+
for ip_dst in $ip_dsts
22+
do
23+
cmd="ping -c 1 -w 5 $ip_dst"
24+
echo "Running: $cmd"
25+
recv=$($cmd | grep -E -o '[0-9]+ received' | cut -f1 -d' ')
26+
if [ "$recv" != "1" ]; then
27+
echo "ICMP ping failed from $ip_dst."
28+
exit 1
29+
else
30+
echo "ICMP ping succeeded."
31+
fi
32+
done
33+
34+
exit $?

webapp/tests/health/scmpcheck.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# test will fail for non-zero exit and/or bytes in stderr
3+
4+
# get local IA
5+
iaFile=$(cat ~/go/src/github.com/scionproto/scion/gen/ia)
6+
ia=$(echo $iaFile | sed "s/_/:/g")
7+
echo "IA found: $ia"
8+
9+
# get local IP
10+
ip=$(hostname -I | cut -d" " -f1)
11+
echo "IP found: $ip"
12+
13+
isd=$(echo ${iaFile} | cut -d"-" -f1)
14+
as=$(echo ${iaFile} | cut -d"-" -f2)
15+
topologyFile=$SC/gen/ISD$isd/AS$as/endhost/topology.json
16+
17+
# get remote addresses from interfaces, return paired list
18+
dsts=($(cat $topologyFile | python -c "import sys, json
19+
brs = json.load(sys.stdin)['BorderRouters']
20+
for b in brs:
21+
for i in brs[b]['Interfaces']:
22+
print brs[b]['Interfaces'][i]['ISD_AS']
23+
print brs[b]['Interfaces'][i]['RemoteOverlay']['Addr']"))
24+
25+
# test scmp echo on each interface
26+
for ((i=0; i<${#dsts[@]}; i+=2))
27+
do
28+
# if no response under default scmp ping timeout consider connection failed
29+
ia_dst="${dsts[i]}"
30+
ip_dst="${dsts[i+1]}"
31+
cmd="$SC/bin/scmp echo -c 1 -timeout 5s -local $ia,[$ip] -remote $ia_dst,[$ip_dst]"
32+
if [ $isd -lt 16 ]; then
33+
# local tests
34+
cmd="$cmd -sciondFromIA"
35+
fi
36+
echo "Running: $cmd"
37+
recv=$($cmd | grep -E -o '[0-9]+ received' | cut -f1 -d' ')
38+
if [ "$recv" != "1" ]; then
39+
echo "SCMP echo failed from $ia_dst,[$ip_dst]."
40+
exit 1
41+
else
42+
echo "SCMP echo succeeded."
43+
fi
44+
done
45+
46+
exit $?

0 commit comments

Comments
 (0)