Fix OVSDB Test Teardown
[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 Suite Setup       Suite Setup
10 Suite Teardown    Suite Teardown
11 Test Setup        Test Setup
12 Test Teardown     Test Teardown
13 Force Tags        Southbound
14 Library           OperatingSystem
15 Library           RequestsLibrary
16 Library           String
17 Resource          ../../../libraries/KarafKeywords.robot
18 Resource          ../../../libraries/OVSDB.robot
19 Resource          ../../../libraries/SetupUtils.robot
20 Resource          ../../../libraries/Utils.robot
21 Resource          ../../../libraries/WaitForFailure.robot
22 Resource          ../../../variables/Variables.robot
23
24 *** Variables ***
25 ${BRIDGE}         ovsbug_br
26 ${OVSDB_UUID}     ${EMPTY}
27 ${OVSDB_UUID2}    ${EMPTY}
28
29 *** Test Cases ***
30 Bug 7414 Same Endpoint Name
31     [Documentation]    To help validate bug 7414, this test case will send a single rest request to create two
32     ...    ports (one for each of two OVS instances connected). The port names will be the same.
33     ...    If the bug happens, the request would be accepted, but internally the two creations are seen as the
34     ...    same and there is a conflict such that neither ovs will receive the port create.
35     [Tags]    7414
36     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_7414
37     # connect two ovs
38     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
39     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
40     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
41     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_2_IP}
42     # add brtest to both
43     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${bridge}
44     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl add-br ${bridge}
45     # send one rest request to create a TP endpoint on each ovs (same name)
46     ${body} =    OVSDB.Modify Multi Port Body    vtep1    vtep1    ${bridge}
47     # check that each ovs has the correct endpoint
48     ${ovs_1_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl show
49     BuiltIn.Log    ${ovs_1_output}
50     ${ovs_2_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl show
51     BuiltIn.Log    ${ovs_2_output}
52     BuiltIn.Should Contain    ${ovs_1_output}    local_ip="${TOOLS_SYSTEM_IP}", remote_ip="${TOOLS_SYSTEM_2_IP}"
53     BuiltIn.Should Not Contain    ${ovs_1_output}    local_ip="${TOOLS_SYSTEM_2_IP}", remote_ip="${TOOLS_SYSTEM_IP}"
54     BuiltIn.Should Contain    ${ovs_2_output}    local_ip="${TOOLS_SYSTEM_2_IP}", remote_ip="${TOOLS_SYSTEM_IP}"
55     BuiltIn.Should Not Contain    ${ovs_2_output}    local_ip="${TOOLS_SYSTEM_IP}", remote_ip="${TOOLS_SYSTEM_2_IP}"
56     [Teardown]    BuiltIn.Run Keywords    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}    data=${body}
57     ...    AND    Test Teardown
58
59 Bug 7414 Different Endpoint Name
60     [Documentation]    This test case is supplemental to the other test case for bug 7414. Even when the other
61     ...    test case would fail and no ovs would receive a port create because the port names are the same, this
62     ...    case should still be able to create ports on the ovs since the port names are different. However,
63     ...    another symptom of this bug is that multiple creations in the same request would end up creating
64     ...    all the ports on all of the ovs, which is incorrect. Both test cases check for this, but in the
65     ...    case where the other test case were to fail this would also help understand if this symptom is still
66     ...    happening
67     [Tags]    7414
68     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_7414
69     # connect two ovs
70     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
71     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
72     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
73     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_2_IP}
74     # add brtest to both
75     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${bridge}
76     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl add-br ${bridge}
77     # send one rest request to create a TP endpoint on each ovs (different name)
78     ${body} =    OVSDB.Modify Multi Port Body    vtep1    vtep2    ${bridge}
79     # check that each ovs has the correct endpoint
80     ${ovs_1_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl show
81     BuiltIn.Log    ${ovs_1_output}
82     ${ovs_2_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-vsctl show
83     BuiltIn.Log    ${ovs_2_output}
84     BuiltIn.Should Contain    ${ovs_1_output}    local_ip="${TOOLS_SYSTEM_IP}", remote_ip="${TOOLS_SYSTEM_2_IP}"
85     BuiltIn.Should Not Contain    ${ovs_1_output}    local_ip="${TOOLS_SYSTEM_2_IP}", remote_ip="${TOOLS_SYSTEM_IP}"
86     BuiltIn.Should Contain    ${ovs_2_output}    local_ip="${TOOLS_SYSTEM_2_IP}", remote_ip="${TOOLS_SYSTEM_IP}"
87     BuiltIn.Should Not Contain    ${ovs_2_output}    local_ip="${TOOLS_SYSTEM_IP}", remote_ip="${TOOLS_SYSTEM_2_IP}"
88     [Teardown]    BuiltIn.Run Keywords    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}    data=${body}
89     ...    AND    Test Teardown
90
91 Bug 5221
92     [Documentation]    In the case that an ovs node is rebooted, or the ovs service is
93     ...    otherwise restarted, a controller initiated connection should reconnect when
94     ...    the ovs is ready and available.
95     [Tags]    5221
96     ${bridge} =    BuiltIn.Set Variable    ovsbug_br_5221
97     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_NODE_PORT}
98     OVSDB.Connect To OVSDB Node    ${TOOLS_SYSTEM_IP}
99     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
100     @{list} =    BuiltIn.Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
101     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}    pretty_print_json=True
102     OVSDB.Add Bridge To Ovsdb Node    ${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}    ${TOOLS_SYSTEM_IP}    ${bridge}    0000000000005221
103     @{list} =    BuiltIn.Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}/bridge/${bridge}
104     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}    pretty_print_json=True
105     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl stop
106     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}    pretty_print_json=True
107     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl start
108     # Depending on when the retry timers are firing, it may take some 10s of seconds to reconnect, so setting to 30 to cover that.
109     BuiltIn.Wait Until Keyword Succeeds    30s    2s    Utils.Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}    pretty_print_json=True
110     [Teardown]    BuiltIn.Run Keywords    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:6634%2Fbridge%2F${bridge}
111     ...    AND    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:6634
112     ...    AND    Test Teardown
113
114 Bug 5177
115     [Documentation]    This test case will recreate the bug using the same basic steps as
116     ...    provided in the bug, and noted here:
117     ...    1) create bridge in config using the UUID determined in Suite Setup
118     ...    2) connect ovs (vsctl set-manager)
119     ...    3) Fail if node is not discovered in Operational Store
120     [Tags]    5177
121     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
122     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
123     ${OVSDB_UUID} =    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
124     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
125     # Suite teardown wants this ${OVSDB_UUID} variable for it's best effort cleanup, so making it visible at suite level.
126     BuiltIn.Set Suite Variable    ${OVSDB_UUID}
127     ${node} =    BuiltIn.Set Variable    uuid/${OVSDB_UUID}
128     OVSDB.Add Bridge To Ovsdb Node    ${node}    ${TOOLS_SYSTEM_IP}    ${BRIDGE}    0000000000005177
129     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
130     OVSDB.Log Request    ${resp.content}
131     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
132     BuiltIn.Should Contain    ${resp.content}    ${node}/bridge/${BRIDGE}
133     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
134     @{list} =    BuiltIn.Create List    ${BRIDGE}
135     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}    pretty_print_json=True
136     # Do not cleanup as the next test requires the steps done in this test
137     [Teardown]    BuiltIn.Run Keywords    Utils.Report_Failure_Due_To_Bug    5177
138     ...    AND    OVSDB.Log Config And Operational Topology
139
140 Bug 4794
141     [Documentation]    This test is dependent on the work done in the Bug 5177 test case so should
142     ...    always be executed immediately after.
143     ...    1) delete bridge in config
144     ...    2) Poll and Fail if exception is seen in karaf.log
145     [Tags]    4794
146     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
147     ${node_id} =    BuiltIn.Set Variable    uuid%2F${OVSDB_UUID}
148     Delete Bridge From Ovsdb Node    ${node_id}    ${BRIDGE}
149     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
150     # If the exception is seen in karaf.log within 10s, the following line will FAIL, which is the point.
151     Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Utils.Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
152     # TODO: Bug 5178
153     [Teardown]    BuiltIn.Run Keywords    RequestsLibrary.Delete Request    session    ${SOUTHBOUND_CONFIG_API}${node_id}%2Fbridge%2F${BRIDGE}
154     ...    AND    RequestsLibrary.Delete Request    session    ${SOUTHBOUND_CONFIG_API}${node_id}
155     ...    AND    Test Teardown
156
157 Bug 8280
158     [Documentation]    Any config created for a bridge (e.g. added ports) should be reconciled when a bridge is
159     ...    reconnected. This test case will create two ports via REST and validate that the bridge has those
160     ...    ports. At that point, the bridge will be disconnected from the controller and the 2nd created port
161     ...    will be manually removed. The bridge will be reconnected and the 2nd port should be re-added to the
162     ...    bridge. If not, then bug 8280 will be found and the test case will fail
163     [Tags]    8280
164     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
165     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
166     ${OVSDB_UUID2} =    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
167     BuiltIn.Set Suite Variable    ${OVSDB_UUID2}
168     OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID2}    ${TOOLS_SYSTEM_IP}    ${BRIDGE}    0000000000008280
169     OVSDB.Add Termination Point    uuid/${OVSDB_UUID2}    ${BRIDGE}    port1
170     OVSDB.Add Termination Point    uuid/${OVSDB_UUID2}    ${BRIDGE}    port2
171     ${config_store_elements} =    BuiltIn.Create List    ${BRIDGE}    port1    port2
172     Utils.Check For Elements At URI    ${CONFIG_TOPO_API}    ${config_store_elements}    pretty_print_json=True
173     ${ovs_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl show
174     BuiltIn.Log    ${ovs_output}
175     ${ovs_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
176     ${ovs_output} =    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-port ${BRIDGE} port2
177     OVSDB.Verify Ovs-vsctl Output    show    Port "port2"    ${TOOLS_SYSTEM_IP}    False
178     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
179     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected    ${TOOLS_SYSTEM_IP}
180     Utils.Check For Elements At URI    ${CONFIG_TOPO_API}    ${config_store_elements}    pretty_print_json=True
181     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Ovs-vsctl Output    show    Port "port2"
182     [Teardown]    BuiltIn.Run Keywords    RequestsLibrary.Delete Request    session    ${SOUTHBOUND_CONFIG_API}uuid%2F${OVSDB_UUID2}%2Fbridge%2F${BRIDGE}
183     ...    AND    RequestsLibrary.Delete Request    session    ${SOUTHBOUND_CONFIG_API}uuid%2F${OVSDB_UUID2}
184     ...    AND    Test Teardown
185
186 Bug 7160
187     [Documentation]    If this bug is reproduced, it's possible that the operational store will be
188     ...    stuck with leftover nodes and further system tests could fail. It's advised to run this
189     ...    test last if possible. See the bug description for high level steps to reproduce
190     ...    https://bugs.opendaylight.org/show_bug.cgi?id=7160#c0
191     [Tags]    7160
192     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_NODE_PORT}
193     OVSDB.Connect To OVSDB Node    ${TOOLS_SYSTEM_IP}
194     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
195     ${qos} =    BuiltIn.Set Variable    QOS-1
196     ${queue} =    BuiltIn.Set Variable    QUEUE-1
197     OVSDB.Create Ovsdb Node    ${TOOLS_SYSTEM_IP}
198     OVSDB.Log Config And Operational Topology
199     OVSDB.Create Qos    ${qos}
200     OVSDB.Log Config And Operational Topology
201     OVSDB.Create Qos Linked Queue
202     OVSDB.Log Config And Operational Topology
203     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${qos}/queue-list/0/
204     OVSDB.Log Config And Operational Topology
205     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${qos}/
206     OVSDB.Log Config And Operational Topology
207     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:queues/${queue}/
208     OVSDB.Log Config And Operational Topology
209     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1
210     OVSDB.Log Config And Operational Topology
211     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
212     ${node}    BuiltIn.Set Variable    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
213     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
214     OVSDB.Log Config And Operational Topology
215     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Config and Operational Topology Should Be Empty
216
217 *** Keywords ***
218 Suite Setup
219     SetupUtils.Setup_Utils_For_Setup_And_Teardown
220     KarafKeywords.Open Controller Karaf Console On Background
221     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
222     Clean All Ovs Nodes
223     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
224     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
225     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
226     OVSDB.Log Config And Operational Topology
227
228 Suite Teardown
229     [Documentation]    Cleans up test environment, close existing sessions.
230     Clean All Ovs Nodes
231     # Best effort to clean config store, by deleting all the types of nodes that are used in this suite
232     ${node} =    BuiltIn.Set Variable    ovsdb:%2F%2Fuuid%2F${OVSDB_UUID}
233     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
234     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
235     ${node} =    BuiltIn.Set Variable    ovsdb:%2F%2Fuuid%2F${OVSDB_UUID2}
236     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
237     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
238     ${node} =    BuiltIn.Set Variable    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
239     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
240     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
241     OVSDB.Log Config And Operational Topology
242     Delete All Sessions
243
244 Test Setup
245     SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
246
247 Test Teardown
248     OVSDB.Log Config And Operational Topology
249     Clean All Ovs Nodes
250     Utils.Report_Failure_Due_To_Bug    ${TEST_TAGS}
251
252 Clean All Ovs Nodes
253     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
254     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_2_IP}