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