Integration tests for GBP
[integration/test.git] / csit / suites / groupbasedpolicy / GBP / 3-node / gbp1 / 020_http.robot
1 *** Settings ***
2 Documentation     Tests for HTTP flow
3 Default Tags      single-tenant    http    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 *** Testcases ***
22
23 # Same subnet tests are not supported by current topology configuration;
24 # clients and webservers are put in two different subnets
25
26 Same switch, start SimpleHttpServer on h36_4
27     [Documentation]  Same Switch (sw1)
28     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
29     DockerUtils.Start HTTP Service on Docker    ${SAME_WEBSERVER_DOCKER}    80
30     SSHLibrary.Close Connection
31
32 Same switch, curl once from h35_2 to h36_4
33     [Documentation]    Test HTTP req/resp from h35_2 to h36_4.
34     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
35     DockerUtils.Curl from Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}    80
36     SSHLibrary.Close Connection
37
38 Same switch, start endless curl from h35_2 to h36_4
39     [Documentation]    Init of endless HTTP session for purposes of traffic inspection.
40     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
41     DockerUtils.Start Endless Curl from Docker    ${CLIENT_DOCKER}    ${SAME_WEBSERVER_IP}    80
42     SSHLibrary.Close Connection
43
44 Same switch, HTTP request ovs-dpctl output check on sw1
45     [Documentation]  Assert matches and actions on megaflow of HTTP request from h35_2 to h36_4
46     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
47
48     @{matches}    Create List
49     @{actions}    Create List
50     Append In Port Check      ${matches}    4
51     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
52     Append Ether-Type Check   ${matches}    0x0800
53     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
54     Append Proto Check        ${matches}    6
55
56     Append Inner MAC Check    ${actions}    dst_addr=${SAME_WEBSERVER_MAC}
57     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${SAME_WEBSERVER_IP}
58     Append Proto Check        ${actions}    6
59     Append Out Port Check     ${actions}    6
60
61     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
62
63     SSHLibrary.Close Connection
64
65 Same switch, HTTP reply ovs-dpctl output check on sw1
66     [Documentation]  Assert matches and actions on megaflow of HTTP reply from h36_4 to h35_2
67     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
68
69     @{matches}    Create List
70     @{actions}    Create List
71     Append In Port Check      ${matches}    6
72     Append Inner MAC Check    ${matches}    src_addr=${SAME_WEBSERVER_MAC}
73     Append Ether-Type Check   ${matches}    0x0800
74     Append Inner IPs Check    ${matches}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
75     Append Proto Check        ${matches}    6
76
77     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
78     Append Inner IPs Check    ${actions}    ${SAME_WEBSERVER_IP}    ${CLIENT_IP}
79     Append Proto Check        ${actions}    6
80     Append Out Port Check     ${actions}    4
81
82     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
83
84     SSHLibrary.Close Connection
85
86 Same switch, stop endless curl from h35_2 to h36_4
87     [Documentation]    Stopping endless HTTP session when traffic inspection finishes.
88     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
89     DockerUtils.Stop Endless Curl from Docker    ${CLIENT_DOCKER}
90     SSHLibrary.Close Connection
91
92 Same switch, stop SimpleHttpServer on h36_4
93     [Documentation]    Shutting down HTTP service on h36_4.
94     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
95     DockerUtils.Stop HTTP Service on Docker    ${SAME_WEBSERVER_DOCKER}
96     SSHLibrary.Close Connection
97
98 Different switches, start SimpleHttpServer on h36_3
99     [Documentation]  Different switches (sw1 -> sw3)
100     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
101     DockerUtils.Start HTTP Service on Docker    ${DIFF_WEBSERVER_DOCKER}    80
102     SSHLibrary.Close Connection
103
104 Different switches, curl once from h35_2 to h36_3
105     [Documentation]    Test HTTP req/resp from h35_2 to h36_3.
106     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
107     DockerUtils.Curl from Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}    80
108     SSHLibrary.Close Connection
109
110 Different switches, start endless curl from h35_2 to h36_3
111     [Documentation]    Init of endless HTTP session for purposes of traffic inspection.
112     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
113     DockerUtils.Start Endless Curl from Docker    ${CLIENT_DOCKER}    ${DIFF_WEBSERVER_IP}    80
114     SSHLibrary.Close Connection
115
116 Different switches, HTTP request ovs-dpctl output check on sw1
117     [Documentation]  Assert matches and actions on megaflow of HTTP request from h35_2 to h36_3
118     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
119
120     @{matches}    Create List
121     @{actions}    Create List
122
123     Append In Port Check      ${matches}    4
124     Append Inner MAC Check    ${matches}    src_addr=${CLIENT_MAC}
125     Append Ether-Type Check   ${matches}    0x0800
126     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
127     Append Proto Check        ${matches}    6
128
129     Append Tunnel Set Check   ${actions}
130     Append Inner MAC Check    ${actions}    dst_addr=${DIFF_WEBSERVER_MAC}
131     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
132     Append Proto Check        ${actions}    6
133     Append Out Port Check     ${actions}    3
134
135     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
136
137     SSHLibrary.Close Connection
138
139 Different switches, HTTP request ovs-dpctl output check on sw3
140     [Documentation]  Assert matches and actions on megaflow of HTTP request from h35_2 to h36_3
141     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
142
143     @{matches}    Create List
144     @{actions}    Create List
145     Append Tunnel Set Check   ${matches}
146     Append Outer IPs Check    ${matches}    src_ip=${CLIENT_SWITCH_IP}
147     Append Outer IPs Check    ${matches}    dst_ip=${DIFF_WEBSERVER_SWITCH_IP}
148     Append In Port Check      ${matches}    3
149     Append Inner MAC Check    ${matches}    dst_addr=${DIFF_WEBSERVER_MAC}
150     Append Ether-Type Check   ${matches}    0x0800
151     Append Inner IPs Check    ${matches}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
152     Append Proto Check        ${matches}    6
153
154     Append Inner IPs Check    ${actions}    ${CLIENT_IP}    ${DIFF_WEBSERVER_IP}
155     Append Proto Check        ${actions}    6
156     Append Out Port Check     ${actions}    5
157
158     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
159
160     SSHLibrary.Close Connection
161
162 Different switches, HTTP reply ovs-dpctl output check on sw3
163     [Documentation]  Assert matches and actions on megaflow of HTTP reply from h36_3 to h35_2
164     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
165
166     @{matches}    Create List
167     @{actions}    Create List
168
169     Append In Port Check      ${matches}    5
170     Append Inner MAC Check    ${matches}    src_addr=${DIFF_WEBSERVER_MAC}
171     Append Ether-Type Check   ${matches}    0x0800
172     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
173     Append Proto Check        ${matches}    6
174
175     Append Tunnel Set Check   ${actions}
176     Append Inner MAC Check    ${actions}    dst_addr=${CLIENT_MAC}
177     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
178     Append Proto Check        ${actions}    6
179     Append Out Port Check     ${actions}    3
180
181     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
182
183     SSHLibrary.Close Connection
184
185 Different switches, HTTP reply ovs-dpctl output check on sw1
186     [Documentation]  Assert matches and actions on megaflow of HTTP request from h36_3 to h35_2
187     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
188
189     @{matches}    Create List
190     @{actions}    Create List
191     Append Tunnel Set Check   ${matches}
192     Append Outer IPs Check    ${matches}    src_ip=${DIFF_WEBSERVER_SWITCH_IP}
193     Append Outer IPs Check    ${matches}    dst_ip=${CLIENT_SWITCH_IP}
194     Append In Port Check      ${matches}    3
195     Append Inner MAC Check    ${matches}    dst_addr=${CLIENT_MAC}
196     Append Ether-Type Check   ${matches}    0x0800
197     Append Inner IPs Check    ${matches}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
198     Append Proto Check        ${matches}    6
199
200     Append Inner IPs Check    ${actions}    ${DIFF_WEBSERVER_IP}    ${CLIENT_IP}
201     Append Proto Check        ${actions}    6
202     Append Out Port Check     ${actions}    4
203
204     ${output}    Find Flow in DPCTL Output    ${matches}    ${actions}
205
206     SSHLibrary.Close Connection
207
208 Different switches, stop endless curl from h35_2 to h36_3
209     [Documentation]    Stopping endless HTTP session when traffic inspection finishes.
210     ConnUtils.Connect and Login    ${CLIENT_SWITCH_IP}    timeout=${timeout}
211     DockerUtils.Stop Endless Curl from Docker    ${CLIENT_DOCKER}
212     SSHLibrary.Close Connection
213
214 Different switches, stop SimpleHttpServer on h36_3
215     [Documentation]    Shutting down HTTP service on h36_3.
216     ConnUtils.Connect and Login    ${DIFF_WEBSERVER_SWITCH_IP}    timeout=${timeout}
217     DockerUtils.Stop HTTP Service on Docker    ${DIFF_WEBSERVER_DOCKER}
218     SSHLibrary.Close Connection