Integration tests for GBP
[integration/test.git] / csit / suites / groupbasedpolicy / GBP / 3-node / gbp2-multitenant / 010_icmp.robot
1 *** Settings ***
2 Documentation     Tests for ICMP flow
3 Force Tags      multi-tenant    icmp    multi-tenant-main
4 Library           SSHLibrary
5 Resource          ../../../../../libraries/Utils.robot
6 Resource          ../../../../../libraries/GBP/ConnUtils.robot
7 Resource          ../../../../../libraries/GBP/DockerUtils.robot
8 Resource          ../../../../../libraries/GBP/OpenFlowUtils.robot
9 Variables         ../../../../../variables/Variables.py
10 Resource          ../Variables.robot
11
12 *** Variables ***
13 ${timeout} =     10s
14
15
16 *** Testcases ***
17 Setting Variables For Tenant 1
18     [Documentation]    Setting variables for tenant 1 related test cases.
19     Set Test Variables  client_switch_ip=${GBP1}    client_docker=h35_2    client_ip=10.0.35.2
20     ...    client_mac=00:00:00:00:35:02  same_webserver_docker=h36_3  same_webserver_ip=10.0.36.3
21     ...    same_webserver_mac=00:00:00:00:36:03  diff_webserver_switch_ip=${GBP3}
22     ...    diff_webserver_docker=h36_2  diff_webserver_ip=10.0.36.2
23     ...    diff_webserver_mac=00:00:00:00:36:02
24
25 Tenant 1 Same switch, ping once from h35_2 to h36_3
26     [Tags]    tenant1
27     [Documentation]  Ping between endpoints located on the same switch "sw1".
28     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
29     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
30     SSHLibrary.Close Connection
31
32 Tenant 1 Same switch, start endless ping from h35_2 to h36_3
33     [Tags]    tenant1
34     [Documentation]  Start endless ping from h35_2 to h36_4 so that icmp traffic
35     ...    can be inspected.
36     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
37     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
38     SSHLibrary.Close Connection
39
40 Tenant 1 Same switch, ICMP request ovs-dpctl output check on sw1
41     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_3
42     [Tags]    tenant1
43     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
44
45     @{matches}    Create List
46     @{actions}    Create List
47     Append In Port Check      ${matches}    4
48     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
49     Append Ether-Type Check   ${matches}    0x0800
50     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
51     Append Proto Check        ${matches}    1
52
53     Append Inner MAC Check    ${actions}    dst_addr=${SAME_WEBSERVER_MAC}
54     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
55     Append Proto Check        ${actions}    1
56     Append Out Port Check     ${actions}    7
57
58     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
59
60     SSHLibrary.Close Connection
61
62 Tenant 1 Same switch, ICMP reply ovs-dpctl output check on sw1
63     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h36_3 to h35_2.
64     [Tags]    tenant1
65     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
66
67     @{matches}    Create List
68     @{actions}    Create List
69     Append In Port Check      ${matches}    7
70     Append Inner MAC Check    ${matches}    src_addr=${SAME_WEBSERVER_MAC}
71     Append Ether-Type Check   ${matches}    0x0800
72     Append Inner IPs Check    ${matches}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
73     Append Proto Check        ${matches}    1
74
75     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
76     Append Inner IPs Check    ${actions}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
77     Append Proto Check        ${actions}    1
78     Append Out Port Check     ${actions}    4
79
80     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
81
82     SSHLibrary.Close Connection
83
84 Tenant 1 Same switch, stop endless ping from h35_2 to h36_3
85     [Tags]    tenant1
86     [Documentation]    Stops endless pinging from h35_8 to h36_6 when traffic inspection finishes.
87     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
88     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
89     SSHLibrary.Close Connection
90
91
92 Tenant 1 Different switches, ping once from h35_2 to h36_2
93     [Documentation]  Different switches (sw1 -> sw3)
94     [Tags]    tenant1
95     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
96     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
97     SSHLibrary.Close Connection
98
99 Tenant 1 Different switches, start endless ping from h35_2 to h36_2
100     [Documentation]  Different switches (sw1 -> sw3)
101     [Tags]    tenant1
102     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
103     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
104     SSHLibrary.Close Connection
105
106 Tenant 1 Different switches, ICMP request ovs-dpctl output check on sw1
107     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_2
108     [Tags]    tenant1
109     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
110
111     @{matches}    Create List
112     @{actions}    Create List
113     Append In Port Check      ${matches}    4
114     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
115     Append Ether-Type Check   ${matches}    0x0800
116     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
117     Append Proto Check        ${matches}    1
118
119     Append Tunnel Set Check   ${actions}
120     Append Inner MAC Check    ${actions}    dst_addr=${DIFF_WEBSERVER_MAC}
121     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
122     Append Proto Check        ${actions}    1
123     Append Out Port Check     ${actions}    3
124
125     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
126
127     SSHLibrary.Close Connection
128
129 Tenant 1 Different switches, ICMP request ovs-dpctl output check on sw3
130     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_2
131     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
132
133     @{matches}    Create List
134     @{actions}    Create List
135     Append Tunnel Set Check   ${matches}
136     Append Outer IPs Check    ${matches}    src_ip=${CLIENT_SWITCH_IP}
137     Append Outer IPs Check    ${matches}    dst_ip=${DIFF_WEBSERVER_SWITCH_IP}
138     Append In Port Check      ${matches}    3
139     Append Inner MAC Check    ${matches}    dst_addr=${DIFF_WEBSERVER_MAC}
140     Append Ether-Type Check   ${matches}    0x0800
141     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
142     Append Proto Check        ${matches}    1
143
144     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
145     Append Proto Check        ${actions}    1
146     Append Out Port Check     ${actions}    6
147
148     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
149
150     SSHLibrary.Close Connection
151
152 Tenant 1 Different switches, ICMP reply ovs-dpctl output check on sw3
153     [Documentation]  Assert matches and actions on megaflow of ICMP request from h36_2 to h35_2
154     [Tags]    tenant1
155     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
156
157     @{matches}    Create List
158     @{actions}    Create List
159     Append In Port Check      ${matches}    6
160     Append Inner MAC Check    ${matches}    src_addr=${DIFF_WEBSERVER_MAC}
161     Append Ether-Type Check   ${matches}    0x0800
162     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
163     Append Proto Check        ${matches}    1
164
165     Append Tunnel Set Check   ${actions}
166     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
167     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
168     Append Proto Check        ${actions}    1
169     Append Out Port Check     ${actions}    3
170
171     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
172
173     SSHLibrary.Close Connection
174
175 Tenant 1 Different switches, ICMP reply ovs-dpctl output check on sw1
176     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h36_2 to h35_2
177     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
178
179     @{matches}    Create List
180     @{actions}    Create List
181     Append Tunnel Set Check   ${matches}
182     Append Outer IPs Check    ${matches}    src_ip=${DIFF_WEBSERVER_SWITCH_IP}
183     Append Outer IPs Check    ${matches}    dst_ip=${CLIENT_SWITCH_IP}
184     Append In Port Check      ${matches}    3
185     Append Inner MAC Check    ${matches}    dst_addr=${CLIENT_MAC}
186     Append Ether-Type Check   ${matches}    0x0800
187     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
188     Append Proto Check        ${matches}    1
189
190     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
191     Append Proto Check        ${actions}    1
192     Append Out Port Check     ${actions}    4
193
194     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
195
196     SSHLibrary.Close Connection
197
198 Tenant 1 Different switches, stop endless ping from h35_2 to h36_2
199     [Tags]    tenant1
200     [Documentation]    Stops endless pinging from h35_2 to h36_2 when traffic inspection finishes.
201     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
202     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
203     SSHLibrary.Close Connection
204
205 Setting Variables For Tenant 2
206     [Documentation]    Setting variables for tenant 2 related test cases.
207     Set Test Variables  client_switch_ip=${GBP1}    client_docker=h35_8    client_ip=10.0.35.8
208     ...    client_mac=00:00:00:00:35:08  same_webserver_docker=h36_6  same_webserver_ip=10.0.36.6
209     ...    same_webserver_mac=00:00:00:00:36:06  diff_webserver_switch_ip=${GBP2}
210     ...    diff_webserver_docker=h36_7  diff_webserver_ip=10.0.36.7
211     ...    diff_webserver_mac=00:00:00:00:36:07
212
213 Tenant 2 Same switch, ping once from h35_8 to h36_6
214     [Documentation]  Same switch (sw1)
215     [Tags]    tenant2
216     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
217     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
218     SSHLibrary.Close Connection
219
220 Tenant 2 Same switch, start endless ping from h35_8 to h36_6
221     [Tags]    tenant2
222     [Documentation]    Starting icmp between hosts on the same switch so that
223     ...    traffic can be inspected.
224     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
225     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
226     SSHLibrary.Close Connection
227
228 Tenant 2 Same switch, ICMP request ovs-dpctl output check on sw1
229     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_8 to h36_6
230     [Tags]    tenant2
231     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
232
233     @{matches}    Create List
234     @{actions}    Create List
235     Append In Port Check      ${matches}    6
236     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
237     Append Ether-Type Check   ${matches}    0x0800
238     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
239     Append Proto Check        ${matches}    1
240
241     Append Inner MAC Check    ${actions}    dst_addr=${SAME_WEBSERVER_MAC}
242     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
243     Append Proto Check        ${actions}    1
244     Append Out Port Check     ${actions}    8
245
246     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
247
248     SSHLibrary.Close Connection
249
250 Tenant 2 Same switch, ICMP reply ovs-dpctl output check on sw1
251     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h35_8 to h36_6
252     [Tags]    tenant2
253     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
254
255     @{matches}    Create List
256     @{actions}    Create List
257     Append In Port Check      ${matches}    8
258     Append Inner MAC Check    ${matches}    src_addr=${SAME_WEBSERVER_MAC}
259     Append Ether-Type Check   ${matches}    0x0800
260     Append Inner IPs Check    ${matches}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
261     Append Proto Check        ${matches}    1
262
263     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
264     Append Inner IPs Check    ${actions}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
265     Append Proto Check        ${actions}    1
266     Append Out Port Check     ${actions}    6
267
268     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
269
270     SSHLibrary.Close Connection
271
272 Tenant 2 Same switch, stop endless ping from h35_8 to h36_6
273     [Tags]    tenant2
274     [Documentation]    Stops endless pinging from h35_8 to h36_6 when traffic inspection finishes.
275     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
276     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
277     SSHLibrary.Close Connection
278
279
280 Tenant 2 Different switches, ping once from h35_8 to h36_7
281     [Documentation]  Different switches (sw1 -> sw3)
282     [Tags]    tenant2
283     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
284     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
285     SSHLibrary.Close Connection
286
287 Tenant 2 Different switches, start endless ping from h35_8 to h36_7
288     [Documentation]  Different switches (sw1 -> sw3)
289     [Tags]    tenant2
290     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
291     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
292     SSHLibrary.Close Connection
293
294 Tenant 2 Different switches, ICMP request ovs-dpctl output check on sw1
295     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_8 to h36_7
296     [Tags]    tenant2
297     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
298
299     @{matches}    Create List
300     @{actions}    Create List
301     Append In Port Check      ${matches}    6
302     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
303     Append Ether-Type Check   ${matches}    0x0800
304     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
305     Append Proto Check        ${matches}    1
306
307     Append Tunnel Set Check   ${actions}
308     Append Inner MAC Check    ${actions}    dst_addr=${DIFF_WEBSERVER_MAC}
309     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
310     Append Proto Check        ${actions}    1
311     Append Out Port Check     ${actions}    3
312
313     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
314
315     SSHLibrary.Close Connection
316
317 Tenant 2 Different switches, ICMP request ovs-dpctl output check on sw3
318     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_8 to h36_7
319     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
320
321     @{matches}    Create List
322     @{actions}    Create List
323     Append Tunnel Set Check   ${matches}
324     Append Outer IPs Check    ${matches}    src_ip=${CLIENT_SWITCH_IP}
325     Append Outer IPs Check    ${matches}    dst_ip=${DIFF_WEBSERVER_SWITCH_IP}
326     Append In Port Check      ${matches}    3
327     Append Inner MAC Check    ${matches}    dst_addr=${DIFF_WEBSERVER_MAC}
328     Append Ether-Type Check   ${matches}    0x0800
329     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
330     Append Proto Check        ${matches}    1
331
332     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
333     Append Proto Check        ${actions}    1
334     Append Out Port Check     ${actions}    8
335
336     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
337
338     SSHLibrary.Close Connection
339
340 Tenant 2 Different switches, ICMP reply ovs-dpctl output check on sw3
341     [Documentation]  Assert matches and actions on megaflow of ICMP request from h36_7 to h35_8
342     [Tags]    tenant2
343     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
344
345     @{matches}    Create List
346     @{actions}    Create List
347     Append In Port Check      ${matches}    8
348     Append Inner MAC Check    ${matches}    src_addr=${DIFF_WEBSERVER_MAC}
349     Append Ether-Type Check   ${matches}    0x0800
350     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
351     Append Proto Check        ${matches}    1
352
353     Append Tunnel Set Check   ${actions}
354     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
355     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
356     Append Proto Check        ${actions}    1
357     Append Out Port Check     ${actions}    3
358
359     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
360
361     SSHLibrary.Close Connection
362
363 Tenant 2 Different switches, ICMP reply ovs-dpctl output check on sw1
364     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h36_7 to h35_8
365     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
366
367     @{matches}    Create List
368     @{actions}    Create List
369     Append Tunnel Set Check   ${matches}
370     Append Outer IPs Check    ${matches}    src_ip=${DIFF_WEBSERVER_SWITCH_IP}
371     Append Outer IPs Check    ${matches}    dst_ip=${CLIENT_SWITCH_IP}
372     Append In Port Check      ${matches}    3
373     Append Inner MAC Check    ${matches}    dst_addr=${CLIENT_MAC}
374     Append Ether-Type Check   ${matches}    0x0800
375     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
376     Append Proto Check        ${matches}    1
377
378     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
379     Append Proto Check        ${actions}    1
380     Append Out Port Check     ${actions}    6
381
382     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
383
384     SSHLibrary.Close Connection
385
386 Tenant 2 Different switches, stop endless ping from h35_8 to h36_7
387     [Documentation]    Stops endless pinging from h35_8 to h36_7 when traffic inspection finishes.
388     [Tags]    tenant2
389     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
390     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
391     SSHLibrary.Close Connection