Migrate request invocations (ovsdb)
[integration/test.git] / csit / suites / ovsdb / Southbound_Domain / 020__connection_manager.robot
index 5c40a6e0a3ec102b277355ecfead26b6d7f142a2..dd737adae142636ca0319b36b08b719493ac2ed8 100644 (file)
 *** Settings ***
-Documentation     Test suite for Connection Manager
-Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
-Suite Teardown    Delete All Sessions
-Library           OperatingSystem
-Library           String
-Library           RequestsLibrary
-Variables         ../../../variables/Variables.py
-Resource          ../../../libraries/Utils.robot
+Documentation       Test suite for Connection Manager
+
+Library             RequestsLibrary
+Resource            ../../../libraries/SetupUtils.robot
+Resource            ../../../libraries/Utils.robot
+Resource            ../../../libraries/OVSDB.robot
+Resource            ../../../variables/Variables.robot
+Resource            ../../../variables/ovsdb/Variables.robot
+
+Suite Setup         OVSDB.Suite Setup
+Suite Teardown      Suite Teardown
+Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+
+Force Tags          southbound
+
 
 *** Variables ***
-${OVSDB_PORT}     6634
-${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${MININET}:${OVSDB_PORT}
-${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
-@{node_list}      ovsdb://${MININET}:${OVSDB_PORT}    ${MININET}    ${OVSDB_PORT}    br-int
+${BRIDGE1}          ovscon_br1
+${BRIDGE2}          ovscon_br2
+@{NODE_LIST}        ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}    ${TOOLS_SYSTEM_IP}    ${OVSDB_NODE_PORT}
+${OVSDB_UUID}       ${EMPTY}
+
 
 *** Test Cases ***
 Connecting an OVS instance to the controller
-    [Tags]    Southbound
-    Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-manager
-    Run Command On Remote System    ${MININET}    sudo ovs-vsctl set-manager tcp:${CONTROLLER}:6640
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
+    BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
 
 Get Operational Topology to verify the ovs instance is connected to the controller
     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
-    [Tags]    Southbound
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${node_list}
-
-Get Config Topology
+    @{list} =    BuiltIn.Create List    ovsdb://uuid    "remote-ip":"${TOOLS_SYSTEM_IP}"    "local-port":${OVSDBPORT}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+    ${OVSDB_UUID} =    OVSDB.Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
+    BuiltIn.Set Suite Variable    ${OVSDB_UUID}
+
+Verify OVS Not In Config Topology
     [Documentation]    This request will fetch the configuration topology from configuration data store
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-    Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-int
+    Utils.Check For Elements Not At URI    ${RFC8040_CONFIG_TOPO_API}    ${NODE_LIST}    pretty_print_json=True
 
 Create bridge manually
-    [Tags]    Southbound
-    Run Command On Remote System    ${MININET}    sudo ovs-vsctl add-br br-s1
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br ${BRIDGE1}
 
 Get Operational Topology to verify the bridge has been added
     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
-    [Tags]    Southbound
-    @{list}    Create List    br-s1
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+    @{list} =    BuiltIn.Create List    ${BRIDGE1}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
 
 Get Config Topology to verify the manually added bridge is not added to the config datastore
     [Documentation]    This request will fetch the configuration topology from configuration data store
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-    Should not Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s1
+    ${resp} =    RequestsLibrary.GET On Session    session    url=${RFC8040_CONFIG_TOPO_API}    expected_status=200
+    Utils.Log Content    ${resp.text}
+    BuiltIn.Should Not Contain    ${resp.text}    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}/bridge/${BRIDGE1}
 
 Create a Bridge through controller
     [Documentation]    This will create bridge on the specified OVSDB node.
-    [Tags]    Southbound
-    ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
-    ${sample1}    Replace String    ${sample}    tcp:127.0.0.1:6633    tcp:${CONTROLLER}:6633
-    ${sample2}    Replace String    ${sample1}    127.0.0.1    ${MININET}
-    ${sample3}    Replace String    ${sample2}    br01    br-s2
-    ${body}    Replace String    ${sample3}    61644    ${OVSDB_PORT}
-    Log    URL is ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s2
-    ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s2    data=${body}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200
+    OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID}    ${TOOLS_SYSTEM_IP}    ${BRIDGE2}    0000000000000002
 
 Get Operational Topology to verify the bridge has been added through rest call
     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
-    [Tags]    Southbound
-    @{list}    Create List    br-s2
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+    @{list} =    BuiltIn.Create List    ${BRIDGE2}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
 
 Get Config Topology to verify the entry added to the config datastore
     [Documentation]    This request will fetch the configuration topology from configuration data store
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-    Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s2
+    ${resp} =    RequestsLibrary.GET On Session    session    url=${RFC8040_CONFIG_TOPO_API}    expected_status=200
+    Utils.Log Content    ${resp.text}
+    BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE2}
 
 Create bridge of already added bridge
     [Documentation]    This will add bridge to the config datastore
-    [Tags]    Southbound
-    ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
-    ${sample1}    Replace String    ${sample}    tcp:127.0.0.1:6633    tcp:${CONTROLLER}:6633
-    ${sample2}    Replace String    ${sample1}    127.0.0.1    ${MININET}
-    ${sample3}    Replace String    ${sample2}    br01    br-s1
-    ${body}    Replace String    ${sample3}    61644    ${OVSDB_PORT}
-    Log    URL is ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1
-    ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1    data=${body}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200
+    OVSDB.Add Bridge To Ovsdb Node    uuid/${OVSDB_UUID}    ${TOOLS_SYSTEM_IP}    ${BRIDGE1}    0000000000000001
 
 Get Config Topology to verify the entry of existing bridge added to the config datastore
     [Documentation]    This request will fetch the configuration topology from configuration data store
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-    Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s1
+    ${resp} =    RequestsLibrary.GET On Session    session    url=${RFC8040_CONFIG_TOPO_API}    expected_status=200
+    Utils.Log Content    ${resp.text}
+    BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE1}
 
 Delete bridge manually
-    [Tags]    Southbound
-    Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-br br-s2
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-br ${BRIDGE2}
 
 Get Operational Topology to verify the bridge has been deleted manually
     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
-    [Tags]    Southbound
-    @{list}    Create List    br-s2
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
-
-Get Config Topology to verify the entry deleted from the config datastore
+    @{list} =    BuiltIn.Create List    ${BRIDGE2}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements Not At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+
+Config Topology Still Contains Bridge
     [Documentation]    This request will fetch the configuration topology from configuration data store
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-    Should not Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s2
+    ${resp} =    RequestsLibrary.GET On Session    session    url=${RFC8040_CONFIG_TOPO_API}    expected_status=200
+    Utils.Log Content    ${resp.text}
+    BuiltIn.Should Contain    ${resp.text}    ovsdb://uuid/${OVSDB_UUID}/bridge/${BRIDGE2}
 
 Delete the Bridge through rest call
     [Documentation]    This request will delete the bridge node from the config data store.
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
+    RequestsLibrary.DELETE On Session
+    ...    session
+    ...    url=${RFC8040_SOUTHBOUND_NODE_API}uuid%2F${OVSDB_UUID}%2Fbridge%2F${BRIDGE2}
+    ...    expected_status=204
 
 Get Operational Topology after Deletion of Bridge
     [Documentation]    This request will fetch the operational topology after the Bridge is deleted
-    [Tags]    Southbound
-    @{list}    Create List    br-s1
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
-
-Delete the integration Bridge
-    [Documentation]    This request will delete the bridge node from the config data store.
-    [Tags]    Southbound
-    ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-int
-    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
-
-Get Operational Topology after Deletion of integration Bridge
-    [Documentation]    This request will fetch the operational topology after the Bridge is deleted
-    [Tags]    Southbound
-    @{list}    Create List    br-int    br-s1
-    Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
+    @{list} =    BuiltIn.Create List    ${BRIDGE2}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements Not At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+
+Trunk And Vlan Tag Is Removed From Operational
+    [Documentation]    Verify that when the vlan tag is added and removed from an ovs port, it should be accurately reflected
+    ...    in the operational store. Also verify that when all trunks are cleared from ovs, it's accurate in operational.
+    [Tags]    8529    bug    exclude
+    OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br vlan-tag-br
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-port vlan-tag-br vlan-tag-port
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port tag=81
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set port vlan-tag-port trunks=[181,182]
+    BuiltIn.Wait Until Keyword Succeeds    5s    1s    OVSDB.Verify OVS Reports Connected
+    OVSDB.Collect OVSDB Debugs
+    @{list} =    BuiltIn.Create List
+    ...    vlan-tag-br
+    ...    vlan-tag-port
+    ...    "ovsdb:vlan-tag":81
+    ...    "trunk":181
+    ...    "trunk":182
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port tag
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl remove port vlan-tag-port trunks 181
+    @{list} =    BuiltIn.Create List    "ovsdb:vlan-tag":81    "trunk":181
+    OVSDB.Collect OVSDB Debugs
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements Not At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+    Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl clear port vlan-tag-port trunks
+    @{list} =    BuiltIn.Create List    "ovsdb:vlan-tag":81    "trunk":181    "trunk":182
+    OVSDB.Collect OVSDB Debugs
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    8s
+    ...    2s
+    ...    Utils.Check For Elements Not At URI
+    ...    ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
+    ...    ${list}
+    ...    pretty_print_json=True
+    [Teardown]    Builtin.Run Keywords    Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
+    ...    AND    Utils.Report_Failure_Due_To_Bug    OVSDB-413
+
+Check For Bug 4756
+    [Documentation]    bug 4756 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
+    ...    case executed.
+    Utils.Check Karaf Log File Does Not Have Messages
+    ...    ${ODL_SYSTEM_IP}
+    ...    SimpleShardDataTreeCohort.*Unexpected failure in validation phase
+    [Teardown]    Utils.Report_Failure_Due_To_Bug    4756
+
+Check For Bug 4794
+    [Documentation]    bug 4794 has been seen in the OVSDB Southbound suites. This test case should be one of the last test
+    ...    case executed.
+    Utils.Check Karaf Log File Does Not Have Messages
+    ...    ${ODL_SYSTEM_IP}
+    ...    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
+    [Teardown]    Utils.Report_Failure_Due_To_Bug    4794
+
+
+*** Keywords ***
+Suite Teardown
+    [Documentation]    Cleans up test environment, close existing sessions.
+    @{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}
+    OVSDB.Suite Teardown    ${uris}