-
Notifications
You must be signed in to change notification settings - Fork 48
/
port_forward.txt
193 lines (149 loc) · 6.28 KB
/
port_forward.txt
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Tests for port forward connectivity between applications
{{$test_msg := "Port forward tests"}}
{{$devmodel := EdenConfig "eve.devmodel"}}
{{define "ssh"}}ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -i {{EdenConfig "eden.tests"}}/eclient/image/cert/id_rsa root@FWD_IP -p FWD_PORT{{end}}
{{define "eclient_image"}}docker://{{EdenConfig "eden.eclient.image"}}:{{EdenConfig "eden.eclient.tag"}}{{end}}
[!exec:bash] stop
[!exec:sleep] stop
[!exec:ssh] stop
[!exec:chmod] stop
[!exec:timeout] stop
exec chmod 600 {{EdenConfig "eden.tests"}}/eclient/image/cert/id_rsa
# Starting of reboot detector with 1 reboots limit
! test eden.reboot.test -test.v -timewait=0 -reboot=0 -count=1 &
message 'Resetting of EVE'
eden eve reset
exec sleep 30
############################## TEST SCENARIO 1 ################################
# Hairpin connectivity test between two apps connected to the same network instance
message 'SCENARIO 1: Creating networks'
eden network create 10.11.12.0/24 -n n1
test eden.network.test -test.v -timewait 10m ACTIVATED n1
exec sleep 10
message 'SCENARIO 1: Starting with both application attached to same network instance'
eden pod deploy -v debug -n app1 {{template "eclient_image"}} -p 2223:22 --networks=n1 --memory=512MB
eden pod deploy -v debug -n app2 {{template "eclient_image"}} -p 2224:22 --networks=n1 --memory=512MB
message 'SCENARIO 1: Waiting for apps to enter RUNNING state'
test eden.app.test -test.v -timewait 20m RUNNING app1 app2
message 'SCENARIO 1: Checking accessibility'
exec -t 5m bash wait_ssh.sh eth0 2223
exec -t 5m bash wait_ssh.sh eth0 2224
eden eve status
cp stdout eve_status
message 'SCENARIO 1: Testing port map connectivity between apps'
exec sleep 20
exec -t 1m bash test_connectivity.sh eth0 2223 eth0 2224
stdout 'Ubuntu'
{{if or (eq $devmodel "ZedVirtual-4G") (eq $devmodel "VBox") }}
message 'SCENARIO 1: Simulating network outage'
eden eve link down
# keep link down long enough for EVE to notice and un-configure port maps
exec sleep 60
! exec -t 1m bash check_ssh.sh eth0 2223
! exec -t 1m bash check_ssh.sh eth1 2224
eden eve link up
# give EVE some time to recover (largely depends on the DHCP server)
exec sleep 20
exec -t 5m bash wait_ssh.sh eth0 2223
exec -t 5m bash wait_ssh.sh eth0 2224
exec -t 1m bash test_connectivity.sh eth0 2223 eth0 2224
stdout 'Ubuntu'
{{end}}
message 'SCENARIO 1: Resource cleaning'
eden pod delete app1
eden pod delete app2
test eden.app.test -test.v -timewait 10m - app1 app2
eden network delete n1
test eden.network.test -test.v -timewait 10m - n1
stdout 'no network with n1 found'
eden network ls
! stdout '^n1\s'
############################## TEST SCENARIO 2 ################################
# Hairpin connectivity test between two apps connected to two different network instances.
# These two network instances have different uplink adapters attached to them. And these adapters
# get different IP addresses from the same subnet with DHCP.
{{$osruntime := EdenOSRuntime}}
{{$allowSlirpRouting := EdenCheckSlirpSupportRouting}}
{{if (eq $osruntime "linux")}}
{{if or (and (eq $devmodel "ZedVirtual-4G") $allowSlirpRouting) (eq $devmodel "VBox") }}
message 'SCENARIO 2: Creating networks'
eden network create 10.11.12.0/24 -n n1
eden network create 10.11.13.0/24 -n n2 --uplink eth1
test eden.network.test -test.v -timewait 10m ACTIVATED n1 n2
message 'SCENARIO 2: Starting with each application attached to a different network instance'
eden pod deploy -v debug -n app1 {{template "eclient_image"}} -p 2223:22 --networks=n1 --memory=512MB
eden pod deploy -v debug -n app2 {{template "eclient_image"}} -p 2234:22 --networks=n2 --memory=512MB
message 'SCENARIO 2: Waiting for apps to enter RUNNING state'
test eden.app.test -test.v -timewait 20m RUNNING app1 app2
message 'SCENARIO 2: Checking accessibility'
exec -t 5m bash wait_ssh.sh eth0 2223
exec -t 5m bash wait_ssh.sh eth1 2234
eden eve status
cp stdout eve_status
message 'SCENARIO 2: Testing port map connectivity between apps'
exec sleep 20
exec -t 1m bash test_connectivity.sh eth0 2223 eth1 2234
stdout 'Ubuntu'
message 'SCENARIO 2: Simulating network outage'
eden eve link down
# keep link down long enough for EVE to notice and un-configure port maps
exec sleep 60
! exec -t 1m bash check_ssh.sh eth0 2223
! exec -t 1m bash check_ssh.sh eth1 2234
eden eve link up
# give EVE some time to recover (largely depends on the DHCP server)
exec sleep 20
exec -t 5m bash wait_ssh.sh eth0 2223
exec -t 5m bash wait_ssh.sh eth1 2234
exec -t 1m bash test_connectivity.sh eth0 2223 eth1 2234
stdout 'Ubuntu'
message 'SCENARIO 2: Resource cleaning'
eden pod delete app1
eden pod delete app2
test eden.app.test -test.v -timewait 10m - app1 app2
eden network delete n1
eden network delete n2
test eden.network.test -test.v -timewait 10m - n1 n2
stdout 'no network with n1 found'
stdout 'no network with n2 found'
eden network ls
! stdout '^n1\s'
! stdout '^n2\s'
{{end}}
{{end}}
-- wait_ssh.sh --
EDEN={{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{EdenConfig "eden.eden-bin"}}
IFNAME=$1
PORT=$2
for i in `seq 20`
do
sleep 20
# Test SSH-access to container
echo $EDEN sdn fwd $IFNAME $PORT -- timeout 30s {{template "ssh"}} grep -q Ubuntu /etc/issue
$EDEN sdn fwd $IFNAME $PORT -- timeout 30s {{template "ssh"}} grep -q Ubuntu /etc/issue && break
done
-- check_ssh.sh --
EDEN={{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{EdenConfig "eden.eden-bin"}}
IFNAME=$1
PORT=$2
echo $EDEN sdn fwd $IFNAME $PORT -- {{template "ssh"}} grep -q Ubuntu /etc/issue
$EDEN sdn fwd $IFNAME $PORT -- {{template "ssh"}} grep -q Ubuntu /etc/issue || exit
-- test_connectivity.sh --
EDEN={{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{EdenConfig "eden.eden-bin"}}
IFNAME1=$1
PORT1=$2
IFNAME2=$3
PORT2=$4
EVE_IP=$($EDEN sdn fwd $IFNAME2 $PORT2 -- {{template "ssh"}} sh /root/get_eve_ip.sh)
echo "$EVE_IP"
echo $EDEN sdn fwd $IFNAME1 $PORT1 -- {{template "ssh"}} sh /root/portmap_test.sh $EVE_IP $PORT2
$EDEN sdn fwd $IFNAME1 $PORT1 -- {{template "ssh"}} sh /root/portmap_test.sh $EVE_IP $PORT2
-- eden-config.yml --
{{/* Test's config. file */}}
test:
controller: adam://{{EdenConfig "adam.ip"}}:{{EdenConfig "adam.port"}}
eve:
{{EdenConfig "eve.name"}}:
onboard-cert: {{EdenConfigPath "eve.cert"}}
serial: "{{EdenConfig "eve.serial"}}"
model: {{EdenConfig "eve.devmodel"}}