e9b38a1c8d82896a7840a508d871d4ff742c0bd3
[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 Connection Manager Suite Setup
4 Suite Teardown    OVSDB Connection Manager Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Force Tags        Southbound
7 Library           OperatingSystem
8 Library           String
9 Library           RequestsLibrary
10 Variables         ../../../variables/Variables.py
11 Resource          ../../../libraries/SetupUtils.robot
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/OVSDB.robot
14
15 *** Variables ***
16 ${OVSDB_PORT}     6634
17 ${BRIDGE1}        ovsdb-csit-test-bridge1
18 ${BRIDGE2}        ovsdb-csit-test-bridge2
19 ${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
20 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
21 @{node_list}      ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}    ${TOOLS_SYSTEM_IP}    ${OVSDB_PORT}
22
23 *** Test Cases ***
24 Connecting an OVS instance to the controller
25     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
26     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
27     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
28
29 Get Operational Topology to verify the ovs instance is connected to the controller
30     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
31     @{list}    Create List    ovsdb://uuid    "remote-ip":"${TOOLS_SYSTEM_IP}"    "local-port":6640
32     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
33     ${ovsdb_uuid}=    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
34     Set Suite Variable    ${ovsdb_uuid}
35
36 Verify OVS Not In Config Topology
37     [Documentation]    This request will fetch the configuration topology from configuration data store
38     Check For Elements Not At URI    ${CONFIG_TOPO_API}    ${node_list}
39
40 Create bridge manually
41     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${BRIDGE1}
42
43 Get Operational Topology to verify the bridge has been added
44     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
45     @{list}    Create List    ${BRIDGE1}
46     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
47
48 Get Config Topology to verify the manually added bridge is not added to the config datastore
49     [Documentation]    This request will fetch the configuration topology from configuration data store
50     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
51     Log    ${resp.content}
52     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
53     Should not Contain    ${resp.content}    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}/bridge/${BRIDGE1}
54
55 Create a Bridge through controller
56     [Documentation]    This will create bridge on the specified OVSDB node.
57     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
58     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://uuid/${ovsdb_uuid}
59     ${body}    Replace String    ${body}    tcp:127.0.0.1:6633    tcp:${ODL_SYSTEM_IP}:6633
60     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
61     ${body}    Replace String    ${body}    br01    ${BRIDGE2}
62     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
63     ${uri}=    Set Variable    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE2}
64     Log    URL is ${uri}
65     Log    data: ${body}
66     ${resp}    RequestsLibrary.Put Request    session    ${uri}    data=${body}
67     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
68
69 Get Operational Topology to verify the bridge has been added through rest call
70     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
71     @{list}    Create List    ${BRIDGE2}
72     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
73
74 Get Config Topology to verify the entry added to the config datastore
75     [Documentation]    This request will fetch the configuration topology from configuration data store
76     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
77     Log    ${resp.content}
78     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
79     Should Contain    ${resp.content}    ovsdb://uuid/${ovsdb_uuid}/bridge/${BRIDGE2}
80
81 Create bridge of already added bridge
82     [Documentation]    This will add bridge to the config datastore
83     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
84     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://uuid/${ovsdb_uuid}
85     ${body}    Replace String    ${body}    tcp:127.0.0.1:6633    tcp:${ODL_SYSTEM_IP}:6633
86     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
87     ${body}    Replace String    ${body}    br01    ${BRIDGE1}
88     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
89     ${uri}=    Set Variable    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE1}
90     Log    URL is ${uri}
91     Log    data: ${body}
92     ${resp}    RequestsLibrary.Put Request    session    ${uri}    data=${body}
93     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
94
95 Get Config Topology to verify the entry of existing bridge added to the config datastore
96     [Documentation]    This request will fetch the configuration topology from configuration data store
97     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
98     Log    ${resp.content}
99     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
100     Should Contain    ${resp.content}    ovsdb://uuid/${ovsdb_uuid}/bridge/${BRIDGE1}
101
102 Delete bridge manually
103     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-br ${BRIDGE2}
104
105 Get Operational Topology to verify the bridge has been deleted manually
106     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
107     @{list}    Create List    ${BRIDGE2}
108     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
109
110 Config Topology Still Contains Bridge
111     [Documentation]    This request will fetch the configuration topology from configuration data store
112     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
113     Log    ${resp.content}
114     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
115     Should Contain    ${resp.content}    ovsdb://uuid/${ovsdb_uuid}/bridge/${BRIDGE2}
116
117 Delete the Bridge through rest call
118     [Documentation]    This request will delete the bridge node from the config data store.
119     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE2}
120     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
121
122 Get Operational Topology after Deletion of Bridge
123     [Documentation]    This request will fetch the operational topology after the Bridge is deleted
124     @{list}    Create List    ${BRIDGE2}
125     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
126
127 Trunk And Vlan Tag Is Removed From Operational
128     [Documentation]    Verify that when the vlan tag is added and removed from an ovs port, it should be accurately reflected
129     ...    in the operational store. Also verify that when all trunks are cleared from ovs, it's accurate in operational.
130     [Tags]    bug 8529    bug
131     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
132     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
133     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br vlan-tag-br
134     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-port vlan-tag-br vlan-tag-port
135     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port tag=81
136     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port trunks=[181,182]
137     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
138     Collect OVSDB Debugs
139     @{list}    Create List    vlan-tag-br    vlan-tag-port    "ovsdb:vlan-tag":81    "trunk":181    "trunk":182
140     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
141     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port tag
142     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl remove port vlan-tag-port trunks 181
143     @{list}    Create List    "ovsdb:vlan-tag":81    "trunk":181
144     Collect OVSDB Debugs
145     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
146     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port trunks
147     @{list}    Create List    "ovsdb:vlan-tag":81    "trunk":181    "trunk":182
148     Collect OVSDB Debugs
149     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
150     [Teardown]    Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
151
152 Check For Bug 4756
153     [Documentation]    bug 4756 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
154     ...    case executed.
155     Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    SimpleShardDataTreeCohort.*Unexpected failure in validation phase
156     [Teardown]    Report_Failure_Due_To_Bug    4756
157
158 Check For Bug 4794
159     [Documentation]    bug 4794 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
160     ...    case executed.
161     Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
162     [Teardown]    Report_Failure_Due_To_Bug    4794
163
164 *** Keywords ***
165 OVSDB Connection Manager Suite Setup
166     SetupUtils.Setup_Utils_For_Setup_And_Teardown
167     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
168
169 OVSDB Connection Manager Suite Teardown
170     [Documentation]    Cleans up test environment, close existing sessions.
171     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
172     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE1}
173     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE2}
174     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
175     Log    ${resp.content}
176     Delete All Sessions