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