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