adding automation around bug 5221
[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 ...               - https://bugs.opendaylight.org/show_bug.cgi?id=5221
4 ...               - https://bugs.opendaylight.org/show_bug.cgi?id=5177
5 ...               - https://bugs.opendaylight.org/show_bug.cgi?id=4794
6 Suite Setup       OVSDB Connection Manager Suite Setup
7 Suite Teardown    OVSDB Connection Manager Suite Teardown
8 Test Setup        Log Testcase Start To Controller Karaf
9 Force Tags        Southbound
10 Library           OperatingSystem
11 Library           String
12 Library           RequestsLibrary
13 Variables         ../../../variables/Variables.py
14 Resource          ../../../libraries/Utils.robot
15 Resource          ../../../libraries/WaitForFailure.robot
16 Resource          ../../../libraries/OVSDB.robot
17
18 *** Variables ***
19 ${OVSDB_PORT}     6634
20 ${BRIDGE}         ovsdb-csit-test-5177
21 ${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
22 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
23
24 *** Test Cases ***
25 Bug 5221
26     [Documentation]    In the case that an ovs node is rebooted, or the ovs service is
27     ...    otherwise restarted, a controller initiated connection should reconnect when
28     ...    the ovs is ready and available.
29     [Setup]    Clean OVSDB Test Environment
30     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_PORT}
31     Connect Controller To OVSDB Node
32     @{list}    Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
33     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
34     Create Bridge    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}    ${BRIDGE}
35     @{list}    Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}/bridge/${BRIDGE}
36     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
37     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl stop
38     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
39     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl start
40     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
41     [Teardown]    Run Keywords    Clean OVSDB Test Environment
42     ...    AND    Report_Failure_Due_To_Bug    5221
43
44 Bug 5177
45     [Documentation]    This test case will recreate the bug using the same basic steps as
46     ...    provided in the bug, and noted here:
47     ...    1) create bridge in config using the UUID determined in Suite Setup
48     ...    2) connect ovs (vsctl set-manager)
49     ...    3) Fail if node is not discovered in Operational Store
50     ${node}    Set Variable    ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
51     Create Bridge    ${node}    ${BRIDGE}
52     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
53     Log    ${resp.content}
54     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
55     Should Contain    ${resp.content}    ${node}/bridge/${BRIDGE}
56     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
57     @{list}    Create List    ${BRIDGE}
58     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
59     [Teardown]    Run Keywords    Clean OVSDB Test Environment
60     ...    AND    Report_Failure_Due_To_Bug    5177
61
62 Bug 4794
63     [Documentation]    This test is dependent on the work done in the Bug 5177 test case so should
64     ...    always be executed immediately after.
65     ...    1) delete bridge in config
66     ...    2) Poll and Fail if exception is seen in karaf.log
67     ${node}    Set Variable    ovsdb://uuid/${ovsdb_uuid}
68     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
69     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
70     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
71     # If the exception is seen in karaf.log within 10s, the following line will FAIL, which is the point.
72     Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Check Karaf Log File Does Not Have Messages    ${ODL_SYSTEM_IP}    Shard.*shard-topology-operational An exception occurred while preCommitting transaction
73     # TODO: Bug 5178
74     [Teardown]    Run Keywords    Clean OVSDB Test Environment
75     ...    AND    Report_Failure_Due_To_Bug    4794
76
77 *** Keywords ***
78 OVSDB Connection Manager Suite Setup
79     Open Controller Karaf Console On Background
80     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
81     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
82     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
83     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
84     ${ovsdb_uuid}=    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
85     Set Suite Variable    ${ovsdb_uuid}
86     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
87
88 OVSDB Connection Manager Suite Teardown
89     [Documentation]    Cleans up test environment, close existing sessions.
90     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
91     # Best effort to clean config store, by deleting all the types of nodes that are used in this suite
92     ${node}    Set Variable    ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
93     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
94     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
95     ${node}    Set Variable    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
96     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
97     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
98     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
99     Log    ${resp.content}
100     Delete All Sessions
101     # TODO: both Create Bridge and Connect Controller To OVSDB Node keywords below should be moved to a library
102     #    and all the suites using this kind of work can move to using the library instead of
103     #    doing all this work each time.
104
105 Create Bridge
106     [Arguments]    ${node}    ${bridge}
107     [Documentation]    This will create bridge on the specified OVSDB node.
108     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
109     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://209.132.179.50:6634
110     ${body}    Replace String    ${body}    tcp:127.0.0.1:6633    tcp:${ODL_SYSTEM_IP}:6640
111     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
112     ${body}    Replace String    ${body}    br01    ${bridge}
113     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
114     ${uri}=    Set Variable    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${bridge}
115     Log    URL is ${uri}
116     Log    data: ${body}
117     ${resp}    RequestsLibrary.Put Request    session    ${uri}    data=${body}
118     Should Be Equal As Strings    ${resp.status_code}    200
119
120 Connect Controller To OVSDB Node
121     [Documentation]    Initiate the connection to OVSDB node from controller
122     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/connect.json
123     ${sample1}    Replace String    ${sample}    127.0.0.1    ${TOOLS_SYSTEM_IP}
124     ${body}    Replace String    ${sample1}    61644    ${OVSDB_PORT}
125     Log    data: ${body}
126     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}    data=${body}
127     Log    ${resp.content}
128     Should Be Equal As Strings    ${resp.status_code}    200
129     Wait Until Keyword Succeeds    3s    1s    Verify OVS Reports Connected
130