Use RFC8040 URL for OVSDB tests
[integration/test.git] / csit / suites / ovsdb / Southbound_Domain / 020__connection_manager.robot
1 *** Settings ***
2 Documentation     Test suite for Connection Manager
3 Suite Setup       OVSDB.Suite Setup
4 Suite Teardown    Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Force Tags        Southbound
7 Library           RequestsLibrary
8 Resource          ../../../libraries/SetupUtils.robot
9 Resource          ../../../libraries/Utils.robot
10 Resource          ../../../libraries/OVSDB.robot
11 Resource          ../../../variables/Variables.robot
12 Resource          ../../../variables/ovsdb/Variables.robot
13
14 *** Variables ***
15 ${BRIDGE1}        ovscon_br1
16 ${BRIDGE2}        ovscon_br2
17 @{NODE_LIST}      ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}    ${TOOLS_SYSTEM_IP}    ${OVSDB_NODE_PORT}
18 ${OVSDB_UUID}     ${EMPTY}
19
20 *** Test Cases ***
21 Connecting an OVS instance to the controller
22     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
23     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
24     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
25
26 Get Operational Topology to verify the ovs instance is connected to the controller
27     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
28     @{list} =    BuiltIn.Create List    ovsdb://uuid    "remote-ip":"${TOOLS_SYSTEM_IP}"    "local-port":${OVSDBPORT}
29     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
30     ${OVSDB_UUID} =    OVSDB.Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
31     BuiltIn.Set Suite Variable    ${OVSDB_UUID}
32
33 Verify OVS Not In Config Topology
34     [Documentation]    This request will fetch the configuration topology from configuration data store
35     Utils.Check For Elements Not At URI    ${RFC8040_CONFIG_TOPO_API}    ${NODE_LIST}    pretty_print_json=True
36
37 Create bridge manually
38     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${BRIDGE1}
39
40 Get Operational Topology to verify the bridge has been added
41     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
42     @{list} =    BuiltIn.Create List    ${BRIDGE1}
43     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
44
45 Get Config Topology to verify the manually added bridge is not added to the config datastore
46     [Documentation]    This request will fetch the configuration topology from configuration data store
47     ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_CONFIG_TOPO_API}
48     OVSDB.Log Request    ${resp.text}
49     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
50     BuiltIn.Should Not Contain    ${resp.text}    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}/bridge/${BRIDGE1}
51
52 Create a Bridge through controller
53     [Documentation]    This will create bridge on the specified OVSDB node.
54     OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID}    ${TOOLS_SYSTEM_IP}    ${BRIDGE2}    0000000000000002
55
56 Get Operational Topology to verify the bridge has been added through rest call
57     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
58     @{list} =    BuiltIn.Create List    ${BRIDGE2}
59     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
60
61 Get Config Topology to verify the entry added to the config datastore
62     [Documentation]    This request will fetch the configuration topology from configuration data store
63     ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_CONFIG_TOPO_API}
64     OVSDB.Log Request    ${resp.text}
65     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
66     BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE2}
67
68 Create bridge of already added bridge
69     [Documentation]    This will add bridge to the config datastore
70     OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID}    ${TOOLS_SYSTEM_IP}    ${BRIDGE1}    0000000000000001
71
72 Get Config Topology to verify the entry of existing bridge added to the config datastore
73     [Documentation]    This request will fetch the configuration topology from configuration data store
74     ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_CONFIG_TOPO_API}
75     OVSDB.Log Request    ${resp.text}
76     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
77     BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE1}
78
79 Delete bridge manually
80     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-br ${BRIDGE2}
81
82 Get Operational Topology to verify the bridge has been deleted manually
83     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
84     @{list} =    BuiltIn.Create List    ${BRIDGE2}
85     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements Not At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
86
87 Config Topology Still Contains Bridge
88     [Documentation]    This request will fetch the configuration topology from configuration data store
89     ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_CONFIG_TOPO_API}
90     OVSDB.Log Request    ${resp.text}
91     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
92     BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE2}
93
94 Delete the Bridge through rest call
95     [Documentation]    This request will delete the bridge node from the config data store.
96     ${resp} =    RequestsLibrary.Delete Request    session    ${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}%2Fbridge%2F${BRIDGE2}
97     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    204
98
99 Get Operational Topology after Deletion of Bridge
100     [Documentation]    This request will fetch the operational topology after the Bridge is deleted
101     @{list} =    BuiltIn.Create List    ${BRIDGE2}
102     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements Not At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
103
104 Trunk And Vlan Tag Is Removed From Operational
105     [Documentation]    Verify that when the vlan tag is added and removed from an ovs port, it should be accurately reflected
106     ...    in the operational store. Also verify that when all trunks are cleared from ovs, it's accurate in operational.
107     [Tags]    8529    bug    exclude
108     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
109     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
110     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br vlan-tag-br
111     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-port vlan-tag-br vlan-tag-port
112     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port tag=81
113     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port trunks=[181,182]
114     BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
115     OVSDB.Collect OVSDB Debugs
116     @{list}    BuiltIn.Create List    vlan-tag-br    vlan-tag-port    "ovsdb:vlan-tag":81    "trunk":181    "trunk":182
117     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
118     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port tag
119     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl remove port vlan-tag-port trunks 181
120     @{list}    BuiltIn.Create List    "ovsdb:vlan-tag":81    "trunk":181
121     OVSDB.Collect OVSDB Debugs
122     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements Not At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
123     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port trunks
124     @{list}    BuiltIn.Create List    "ovsdb:vlan-tag":81    "trunk":181    "trunk":182
125     OVSDB.Collect OVSDB Debugs
126     BuiltIn.Wait Until Keyword Succeeds    8s    2s    Utils.Check For Elements Not At URI    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}    ${list}    pretty_print_json=True
127     [Teardown]    Builtin.Run Keywords    Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
128     ...    AND    Utils.Report_Failure_Due_To_Bug    OVSDB-413
129
130 Check For Bug 4756
131     [Documentation]    bug 4756 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
132     ...    case executed.
133     Utils.Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    SimpleShardDataTreeCohort.*Unexpected failure in validation phase
134     [Teardown]    Utils.Report_Failure_Due_To_Bug    4756
135
136 Check For Bug 4794
137     [Documentation]    bug 4794 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
138     ...    case executed.
139     Utils.Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
140     [Teardown]    Utils.Report_Failure_Due_To_Bug    4794
141
142 *** Keywords ***
143 Suite Teardown
144     [Documentation]    Cleans up test environment, close existing sessions.
145     @{uris} =    Builtin.Create List    ${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}%2Fbridge%2F${BRIDGE1}    ${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}%2Fbridge%2F${BRIDGE2}
146     OVSDB.Suite Teardown    ${uris}