Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / ovsdb / Southbound_Domain / Bug_Validation.robot
1 *** Settings ***
2 Documentation       Collection of test cases to validate OVSDB projects bugs.
3 ...
4 ...                 TODO: there seems to be some thoughts around never having one-off bug reproduction
5 ...                 test cases, but rather they should exist as another test case in some appropriate
6 ...                 suite. Also it was suggested that using bug ids for test case names was not ideal
7 ...                 this to-do is written in case it's decided to refactor all of these test cases out
8 ...                 of this suite and/or to rename the test cases at a later time.
9
10 Library             OperatingSystem
11 Library             RequestsLibrary
12 Library             String
13 Resource            ../../../libraries/KarafKeywords.robot
14 Resource            ../../../libraries/OVSDB.robot
15 Resource            ../../../libraries/SetupUtils.robot
16 Resource            ../../../libraries/Utils.robot
17 Resource            ../../../libraries/WaitForFailure.robot
18 Resource            ../../../variables/Variables.robot
19 Resource            ../../../variables/ovsdb/Variables.robot
20
21 Suite Setup         Suite Setup
22 Suite Teardown      Suite Teardown
23 Test Setup          Test Setup
24 Test Teardown       Test Teardown
25
26 Force Tags          southbound
27
28
29 *** Variables ***
30 ${BRIDGE}           ovsbug_br
31 ${OVSDB_UUID}       ${EMPTY}
32 ${OVSDB_UUID2}      ${EMPTY}
33
34
35 *** Test Cases ***
36 Bug 7414 Same Endpoint Name
37     [Documentation]    To help validate bug 7414, this test case will send a single rest request to create two
38     ...    ports (one for each of two OVS instances connected). The port names will be the same.
39     ...    If the bug happens, the request would be accepted, but internally the two creations are seen as the
40     ...    same and there is a conflict such that neither ovs will receive the port create.
41     [Tags]    7414
42     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_7414
43     # connect two ovs
44     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
45     Utils.Run Command On Mininet
46     ...    ${TOOLS_SYSTEM_2_IP}
47     ...    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
48     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
49     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_2_IP}
50     # add brtest to both
51     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${bridge}
52     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl add-br ${bridge}
53     # send one rest request to create a TP endpoint on each ovs (same name)
54     ${body} =    OVSDB.Modify Multi Port Body    vtep1    vtep1    ${bridge}
55     # check that each ovs has the correct endpoint
56     BuiltIn.Wait Until Keyword Succeeds
57     ...    60s
58     ...    10s
59     ...    Verify TEP Creation on OVS
60     ...    ${TOOLS_SYSTEM_IP}
61     ...    ${TOOLS_SYSTEM_2_IP}
62     BuiltIn.Wait Until Keyword Succeeds
63     ...    60s
64     ...    10s
65     ...    Verify TEP Creation on OVS
66     ...    ${TOOLS_SYSTEM_2_IP}
67     ...    ${TOOLS_SYSTEM_IP}
68     [Teardown]    BuiltIn.Run Keywords    Test Teardown
69     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_TOPO_API}    data=${body}    expected_status=anything
70
71 Bug 7414 Different Endpoint Name
72     [Documentation]    This test case is supplemental to the other test case for bug 7414. Even when the other
73     ...    test case would fail and no ovs would receive a port create because the port names are the same, this
74     ...    case should still be able to create ports on the ovs since the port names are different. However,
75     ...    another symptom of this bug is that multiple creations in the same request would end up creating
76     ...    all the ports on all of the ovs, which is incorrect. Both test cases check for this, but in the
77     ...    case where the other test case were to fail this would also help understand if this symptom is still
78     ...    happening
79     [Tags]    7414
80     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_7414
81     # connect two ovs
82     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
83     Utils.Run Command On Mininet
84     ...    ${TOOLS_SYSTEM_2_IP}
85     ...    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
86     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
87     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_2_IP}
88     # add brtest to both
89     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${bridge}
90     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl add-br ${bridge}
91     # send one rest request to create a TP endpoint on each ovs (different name)
92     ${body} =    OVSDB.Modify Multi Port Body    vtep1    vtep2    ${bridge}
93     # check that each ovs has the correct endpoint
94     BuiltIn.Wait Until Keyword Succeeds
95     ...    60s
96     ...    10s
97     ...    Verify TEP Creation on OVS
98     ...    ${TOOLS_SYSTEM_IP}
99     ...    ${TOOLS_SYSTEM_2_IP}
100     BuiltIn.Wait Until Keyword Succeeds
101     ...    60s
102     ...    10s
103     ...    Verify TEP Creation on OVS
104     ...    ${TOOLS_SYSTEM_2_IP}
105     ...    ${TOOLS_SYSTEM_IP}
106     [Teardown]    BuiltIn.Run Keywords    Test Teardown
107     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_TOPO_API}    data=${body}    expected_status=anything
108
109 Bug 5221
110     [Documentation]    In the case that an ovs node is rebooted, or the ovs service is
111     ...    otherwise restarted, a controller initiated connection should reconnect when
112     ...    the ovs is ready and available.
113     [Tags]    5221
114     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_5221
115     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_NODE_PORT}
116     OVSDB.Connect To OVSDB Node    ${TOOLS_SYSTEM_IP}
117     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
118     @{list} =    BuiltIn.Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
119     BuiltIn.Wait Until Keyword Succeeds
120     ...    8s
121     ...    2s
122     ...    Utils.Check For Elements At URI
123     ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
124     ...    ${list}
125     ...    pretty_print_json=True
126     OVSDB.Add Bridge To Ovsdb Node
127     ...    ${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
128     ...    ${TOOLS_SYSTEM_IP}
129     ...    ${bridge}
130     ...    0000000000005221
131     @{list} =    BuiltIn.Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}/bridge/${bridge}
132     BuiltIn.Wait Until Keyword Succeeds
133     ...    8s
134     ...    2s
135     ...    Utils.Check For Elements At URI
136     ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
137     ...    ${list}
138     ...    pretty_print_json=True
139     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl stop
140     BuiltIn.Wait Until Keyword Succeeds
141     ...    8s
142     ...    2s
143     ...    Utils.Check For Elements Not At URI
144     ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
145     ...    ${list}
146     ...    pretty_print_json=True
147     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl start
148     # Depending on when the retry timers are firing, it may take some 10s of seconds to reconnect, so setting to 30 to cover that.
149     BuiltIn.Wait Until Keyword Succeeds
150     ...    30s
151     ...    2s
152     ...    Utils.Check For Elements At URI
153     ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
154     ...    ${list}
155     ...    pretty_print_json=True
156     [Teardown]    BuiltIn.Run Keywords    Test Teardown
157     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_TOOLS_API}%2Fbridge%2F${bridge}    expected_status=anything
158     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_TOOLS_API}    expected_status=anything
159
160 Bug 5177
161     [Documentation]    This test case will recreate the bug using the same basic steps as
162     ...    provided in the bug, and noted here:
163     ...    1) create bridge in config using the UUID determined in Suite Setup
164     ...    2) connect ovs (vsctl set-manager)
165     ...    3) Fail if node is not discovered in Operational Store
166     [Tags]    5177
167     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
168     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
169     ${OVSDB_UUID} =    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
170     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
171     # Suite teardown wants this ${OVSDB_UUID} variable for it's best effort cleanup, so making it visible at suite level.
172     BuiltIn.Set Suite Variable    ${OVSDB_UUID}
173     ${node} =    BuiltIn.Set Variable    uuid/${OVSDB_UUID}
174     OVSDB.Add Bridge To Ovsdb Node    ${node}    ${TOOLS_SYSTEM_IP}    ${BRIDGE}    0000000000005177
175     ${resp} =    RequestsLibrary.GET On Session    session    url=${RFC8040_CONFIG_TOPO_API}    expected_status=200
176     Utils.Log Content    ${resp.text}
177     BuiltIn.Should Contain    ${resp.text}    ${node}/bridge/${BRIDGE}
178     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
179     @{list} =    BuiltIn.Create List    ${BRIDGE}
180     BuiltIn.Wait Until Keyword Succeeds
181     ...    8s
182     ...    2s
183     ...    Utils.Check For Elements At URI
184     ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
185     ...    ${list}
186     ...    pretty_print_json=True
187     # Do not cleanup as the next test requires the steps done in this test
188     [Teardown]    BuiltIn.Run Keywords    Utils.Report_Failure_Due_To_Bug    5177
189     ...    AND    OVSDB.Log Config And Operational Topology
190
191 Bug 4794
192     [Documentation]    This test is dependent on the work done in the Bug 5177 test case so should
193     ...    always be executed immediately after.
194     ...    1) delete bridge in config
195     ...    2) Poll and Fail if exception is seen in karaf.log
196     [Tags]    4794
197     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
198     ${node_id} =    BuiltIn.Set Variable    uuid%2F${OVSDB_UUID}
199     Delete Bridge From Ovsdb Node    ${node_id}    ${BRIDGE}
200     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
201     # If the exception is seen in karaf.log within 10s, the following line will FAIL, which is the point.
202     Verify_Keyword_Does_Not_Fail_Within_Timeout
203     ...    10s
204     ...    1s
205     ...    Utils.Check Karaf Log File Does Not Have Messages
206     ...    ${ODL_SYSTEM_IP}
207     ...    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
208     # TODO: Bug 5178
209     [Teardown]    BuiltIn.Run Keywords    Test Teardown
210     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_API}${node_id}%2Fbridge%2F${BRIDGE}    expected_status=anything
211     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_API}${node_id}    expected_status=anything
212
213 Bug 8280
214     [Documentation]    Any config created for a bridge (e.g. added ports) should be reconciled when a bridge is
215     ...    reconnected. This test case will create two ports via REST and validate that the bridge has those
216     ...    ports. At that point, the bridge will be disconnected from the controller and the 2nd created port
217     ...    will be manually removed. The bridge will be reconnected and the 2nd port should be re-added to the
218     ...    bridge. If not, then bug 8280 will be found and the test case will fail
219     [Tags]    8280
220     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
221     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
222     ${OVSDB_UUID2} =    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
223     BuiltIn.Set Suite Variable    ${OVSDB_UUID2}
224     OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID2}    ${TOOLS_SYSTEM_IP}    ${BRIDGE}    0000000000008280
225     OVSDB.Add Termination Point    uuid/${OVSDB_UUID2}    ${BRIDGE}    port1
226     OVSDB.Add Termination Point    uuid/${OVSDB_UUID2}    ${BRIDGE}    port2
227     ${config_store_elements} =    BuiltIn.Create List    ${BRIDGE}    port1    port2
228     Utils.Check For Elements At URI    ${RFC8040_CONFIG_TOPO_API}    ${config_store_elements}    pretty_print_json=True
229     ${ovs_output} =    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl show
230     BuiltIn.Log    ${ovs_output}
231     ${ovs_output} =    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
232     ${ovs_output} =    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-port ${BRIDGE} port2
233     OVSDB.Verify Ovs-vsctl Output    show    Port "port2"    ${TOOLS_SYSTEM_IP}    False
234     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
235     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
236     Utils.Check For Elements At URI    ${RFC8040_CONFIG_TOPO_API}    ${config_store_elements}    pretty_print_json=True
237     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Ovs-vsctl Output    show    Port "port2"
238     [Teardown]    BuiltIn.Run Keywords    Test Teardown
239     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID2}%2Fbridge%2F${BRIDGE}    expected_status=anything
240     ...    AND    RequestsLibrary.DELETE On Session    session    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID2}    expected_status=anything
241
242 Bug 7160
243     [Documentation]    If this bug is reproduced, it's possible that the operational store will be
244     ...    stuck with leftover nodes and further system tests could fail. It's advised to run this
245     ...    test last if possible. See the bug description for high level steps to reproduce
246     ...    https://bugs.opendaylight.org/show_bug.cgi?id=7160#c0
247     [Tags]    7160
248     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_NODE_PORT}
249     OVSDB.Connect To OVSDB Node    ${TOOLS_SYSTEM_IP}
250     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
251     ${qos} =    BuiltIn.Set Variable    QOS-1
252     ${queue} =    BuiltIn.Set Variable    QUEUE-1
253     OVSDB.Create Ovsdb Node    ${TOOLS_SYSTEM_IP}
254     OVSDB.Log Config And Operational Topology
255     OVSDB.Create Qos    ${qos}
256     OVSDB.Log Config And Operational Topology
257     OVSDB.Create Qos Linked Queue
258     OVSDB.Log Config And Operational Topology
259     RequestsLibrary.DELETE On Session
260     ...    session
261     ...    url=${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${qos}/queue-list=0
262     OVSDB.Log Config And Operational Topology
263     RequestsLibrary.DELETE On Session
264     ...    session
265     ...    url=${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${qos}
266     OVSDB.Log Config And Operational Topology
267     RequestsLibrary.DELETE On Session
268     ...    session
269     ...    url=${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:queues=${queue}
270     OVSDB.Log Config And Operational Topology
271     RequestsLibrary.DELETE On Session
272     ...    session
273     ...    url=${RFC8040_SOUTHBOUND_NODE_HOST1_API}
274     OVSDB.Log Config And Operational Topology
275     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
276     RequestsLibrary.DELETE On Session
277     ...    session
278     ...    url=${RFC8040_SOUTHBOUND_NODE_TOOLS_API}
279     OVSDB.Log Config And Operational Topology
280     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Config and Operational Topology Should Be Empty
281
282
283 *** Keywords ***
284 Suite Setup
285     SetupUtils.Setup_Utils_For_Setup_And_Teardown
286     KarafKeywords.Open Controller Karaf Console On Background
287     RequestsLibrary.Create Session
288     ...    session
289     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
290     ...    auth=${AUTH}
291     ...    headers=${HEADERS}
292     Clean All Ovs Nodes
293     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
294     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
295     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
296     OVSDB.Log Config And Operational Topology
297
298 Suite Teardown
299     [Documentation]    Cleans up test environment, close existing sessions.
300     Clean All Ovs Nodes
301     # Best effort to clean config store, by deleting all the types of nodes that are used in this suite
302     RequestsLibrary.DELETE On Session
303     ...    session
304     ...    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}%2Fbridge%2F${BRIDGE}
305     ...    expected_status=anything
306     RequestsLibrary.DELETE On Session
307     ...    session
308     ...    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}
309     ...    expected_status=anything
310     RequestsLibrary.DELETE On Session
311     ...    session
312     ...    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID2}%2Fbridge%2F${BRIDGE}
313     ...    expected_status=anything
314     RequestsLibrary.DELETE On Session
315     ...    session
316     ...    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID2}
317     ...    expected_status=anything
318     RequestsLibrary.DELETE On Session
319     ...    session
320     ...    url=${RFC8040_SOUTHBOUND_NODE_TOOLS_API}%2Fbridge%2F${BRIDGE}
321     ...    expected_status=anything
322     RequestsLibrary.DELETE On Session
323     ...    session
324     ...    url=${RFC8040_SOUTHBOUND_NODE_TOOLS_API}
325     ...    expected_status=anything
326     OVSDB.Log Config And Operational Topology
327     Delete All Sessions
328
329 Test Setup
330     SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
331
332 Test Teardown
333     OVSDB.Log Config And Operational Topology
334     Clean All Ovs Nodes
335     Utils.Report_Failure_Due_To_Bug    ${TEST_TAGS}
336
337 Clean All Ovs Nodes
338     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
339     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_2_IP}
340
341 Verify TEP Creation on OVS
342     [Arguments]    ${local_ip}    ${remote_ip}
343     ${ovs_output} =    Utils.Run Command On Mininet    ${local_ip}    sudo ovs-vsctl show
344     BuiltIn.Log    ${ovs_output}
345     BuiltIn.Should Contain    ${ovs_output}    local_ip="${local_ip}", remote_ip="${remote_ip}"
346     BuiltIn.Should Not Contain    ${ovs_output}    local_ip="${remote_ip}", remote_ip="${local_ip}"