7fb7f87f4961086c3b4ee9465ebcff577113e266
[integration/test.git] / csit / suites / groupbasedpolicy / GBP / 3-node / gbp1 / 010_icmp.robot
1 *** Settings ***
2 Documentation     Tests for ICMP flow
3 Default Tags      single-tenant    icmp    single-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 Suite Setup       Set Test Variables  client_switch_ip=${GBP1}    client_docker=h35_2    client_ip=10.0.35.2
12     ...    client_mac=00:00:00:00:35:02  same_webserver_docker=h36_4  same_webserver_ip=10.0.36.4
13     ...    same_webserver_mac=00:00:00:00:36:04  diff_webserver_switch_ip=${GBP3}
14     ...    diff_webserver_docker=h36_3  diff_webserver_ip=10.0.36.3
15     ...    diff_webserver_mac=00:00:00:00:36:03
16
17
18 *** Variables ***
19 ${timeout} =     10s
20
21
22 *** Testcases ***
23
24 Same switch, ping once from h35_2 to h36_4
25     [Documentation]  Ping between endpoints located on the same switch "sw1".
26     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
27     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
28     SSHLibrary.Close Connection
29
30 Same switch, start endless ping from h35_2 to h36_4
31     [Documentation]  Start endless ping from h35_2 to h36_4 so that icmp traffic
32     ...    can be inspected.
33     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
34     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
35     SSHLibrary.Close Connection
36
37 Same switch, ICMP request ovs-dpctl output check on sw1
38     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_4
39     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
40
41     @{matches}    Create List
42     @{actions}    Create List
43     Append In Port Check      ${matches}    4
44     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
45     Append Ether-Type Check   ${matches}    0x0800
46     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
47     Append Proto Check        ${matches}    1
48
49     Append Inner MAC Check    ${actions}    dst_addr=${SAME_WEBSERVER_MAC}
50     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
51     Append Proto Check        ${actions}    1
52     Append Out Port Check     ${actions}    6
53
54     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
55
56     SSHLibrary.Close Connection
57
58 Same switch, ICMP reply ovs-dpctl output check on sw1
59     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h36_4 to h35_2
60     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
61
62     Set Suite Variable    @{matches}    @{EMPTY}
63     Set Suite Variable    @{actions}    @{EMPTY}
64
65     Append In Port Check      ${matches}    6
66     Append Inner MAC Check    ${matches}    src_addr=${SAME_WEBSERVER_MAC}
67     Append Ether-Type Check   ${matches}    0x0800
68     Append Inner IPs Check    ${matches}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
69     Append Proto Check        ${matches}    1
70
71     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
72     Append Inner IPs Check    ${actions}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
73     Append Proto Check        ${actions}    1
74     Append Out Port Check     ${actions}    4
75
76     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
77
78     SSHLibrary.Close Connection
79
80 Same switch, stop endless ping from h35_2 to h36_4
81     [Documentation]    Stops endless pinging from h35_2 to h36_4 when traffic inspection finishes.
82     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
83     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}
84     SSHLibrary.Close Connection
85
86
87 Different switches, ping once from h35_2 to h36_3
88     [Documentation]  Different switches (sw1 -> sw3)
89     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
90     DockerUtils.Ping From Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
91     SSHLibrary.Close Connection
92
93 Different switches, start endless ping from h35_2 to h36_3
94     [Documentation]  Starting icmp session for traffic inspection between endpoints located
95     ...    on different switches.
96     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
97     DockerUtils.Start Endless Ping from Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
98     SSHLibrary.Close Connection
99
100 Different switches, ICMP request ovs-dpctl output check on sw1
101     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_3
102     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
103
104     @{matches}    Create List
105     @{actions}    Create List
106     Append In Port Check      ${matches}    4
107     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
108     Append Ether-Type Check   ${matches}    0x0800
109     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
110     Append Proto Check        ${matches}    1
111
112     Append Tunnel Set Check   ${actions}
113     Append Inner MAC Check    ${actions}    dst_addr=${DIFF_WEBSERVER_MAC}
114     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
115     Append Proto Check        ${actions}    1
116     Append Out Port Check     ${actions}    3
117
118     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
119
120     SSHLibrary.Close Connection
121
122 Different switches, ICMP request ovs-dpctl output check on sw3
123     [Documentation]  Assert matches and actions on megaflow of ICMP request from h35_2 to h36_3
124     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
125
126     @{matches}    Create List
127     @{actions}    Create List
128     Append Tunnel Set Check   ${matches}
129     Append Outer IPs Check    ${matches}    src_ip=${CLIENT_SWITCH_IP}
130     Append Outer IPs Check    ${matches}    dst_ip=${DIFF_WEBSERVER_SWITCH_IP}
131     Append In Port Check      ${matches}    3
132     Append Inner MAC Check    ${matches}    dst_addr=${DIFF_WEBSERVER_MAC}
133     Append Ether-Type Check   ${matches}    0x0800
134     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
135     Append Proto Check        ${matches}    1
136
137     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
138     Append Proto Check        ${actions}    1
139     Append Out Port Check     ${actions}    5
140
141     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
142
143     SSHLibrary.Close Connection
144
145 Different switches, ICMP reply ovs-dpctl output check on sw3
146     [Documentation]  assert matches and actions on megaflow of ICMP reply from h36_3 to h35_2
147     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
148
149     @{matches}    Create List
150     @{actions}    Create List
151     Append In Port Check      ${matches}    5
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
157     Append Tunnel Set Check   ${actions}
158     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
159     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
160     Append Proto Check        ${actions}    1
161     Append Out Port Check     ${actions}    3
162
163     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
164
165     SSHLibrary.Close Connection
166
167 Different switches, ICMP reply ovs-dpctl output check on sw1
168     [Documentation]  Assert matches and actions on megaflow of ICMP reply from h36_3 to h35_2
169     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
170
171     @{matches}    Create List
172     @{actions}    Create List
173     Append Tunnel Set Check   ${matches}
174     Append Outer IPs Check    ${matches}    src_ip=${DIFF_WEBSERVER_SWITCH_IP}
175     Append Outer IPs Check    ${matches}    dst_ip=${CLIENT_SWITCH_IP}
176     Append In Port Check      ${matches}    3
177     Append Inner MAC Check    ${matches}    dst_addr=${CLIENT_MAC}
178     Append Ether-Type Check   ${matches}    0x0800
179     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
180     Append Proto Check        ${matches}    1
181
182     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
183     Append Proto Check        ${actions}    1
184     Append Out Port Check     ${actions}    4
185
186     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
187
188     SSHLibrary.Close Connection
189
190 Different switches, stop endless ping from h35_2 to h36_3
191     [Documentation]    Stops endless pinging from h35_2 to h36_3 when traffic inspection finishes.
192     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
193     DockerUtils.Stop Endless Ping from Docker to Address    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}
194     SSHLibrary.Close Connection