add reproduction test case for bug 7160
[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        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
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/SetupUtils.robot
16 Resource          ../../../libraries/WaitForFailure.robot
17 Resource          ../../../libraries/OVSDB.robot
18
19 *** Variables ***
20 ${OVSDB_PORT}     6634
21 ${BRIDGE}         ovsdb-csit-test-5177
22 ${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
23 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
24
25 *** Test Cases ***
26 Bug 5221
27     [Documentation]    In the case that an ovs node is rebooted, or the ovs service is
28     ...    otherwise restarted, a controller initiated connection should reconnect when
29     ...    the ovs is ready and available.
30     [Setup]    Clean OVSDB Test Environment
31     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_PORT}
32     Connect Controller To OVSDB Node
33     @{list}    Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
34     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
35     Create Bridge    ${TOOLS_SYSTEM_IP}:6634    ${BRIDGE}
36     @{list}    Create List    ovsdb://${TOOLS_SYSTEM_IP}:${OVSDB_PORT}/bridge/${BRIDGE}
37     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
38     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl stop
39     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
40     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo /usr/share/openvswitch/scripts/ovs-ctl start
41     # Depending on when the retry timers are firing, it may take some 10s of seconds to reconnect, so setting to 30 to cover that.
42     Wait Until Keyword Succeeds    30s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
43     [Teardown]    Run Keywords    Clean OVSDB Test Environment
44     ...    AND    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:6634%2Fbridge%2F${BRIDGE}
45     ...    AND    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:6634
46     ...    AND    Report_Failure_Due_To_Bug    5221
47
48 Bug 5177
49     [Documentation]    This test case will recreate the bug using the same basic steps as
50     ...    provided in the bug, and noted here:
51     ...    1) create bridge in config using the UUID determined in Suite Setup
52     ...    2) connect ovs (vsctl set-manager)
53     ...    3) Fail if node is not discovered in Operational Store
54     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
55     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
56     ${ovsdb_uuid}=    Get OVSDB UUID    ${TOOLS_SYSTEM_IP}
57     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
58     # Suite teardown wants this ${ovsdb_uuid} variable for it's best effort cleanup, so making it visible at suite level.
59     Set Suite Variable    ${ovsdb_uuid}
60     ${node}    Set Variable    uuid/${ovsdb_uuid}
61     Create Bridge    ${node}    ${BRIDGE}
62     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
63     Log    ${resp.content}
64     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
65     Should Contain    ${resp.content}    ${node}/bridge/${BRIDGE}
66     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
67     @{list}    Create List    ${BRIDGE}
68     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1    ${list}
69     [Teardown]    Run Keywords    Clean OVSDB Test Environment
70     ...    AND    Report_Failure_Due_To_Bug    5177
71
72 Bug 4794
73     [Documentation]    This test is dependent on the work done in the Bug 5177 test case so should
74     ...    always be executed immediately after.
75     ...    1) delete bridge in config
76     ...    2) Poll and Fail if exception is seen in karaf.log
77     ${node}    Set Variable    ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
78     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
79     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
80     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
81     # If the exception is seen in karaf.log within 10s, the following line will FAIL, which is the point.
82     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
83     # TODO: Bug 5178
84     [Teardown]    Run Keywords    Clean OVSDB Test Environment
85     ...    AND    Report_Failure_Due_To_Bug    4794
86
87 Bug 7160
88     [Documentation]    If this bug is reproduced, it's possible that the operational store will be
89     ...    stuck with leftover nodes and further system tests could fail. It's advised to run this
90     ...    test last if possible. See the bug description for high level steps to reproduce
91     ...    https://bugs.opendaylight.org/show_bug.cgi?id=7160#c0
92     [Setup]    Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
93     ...    AND    Clean OVSDB Test Environment
94     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager ptcp:${OVSDB_PORT}
95     Connect Controller To OVSDB Node
96     ${QOS}=    Set Variable    QOS-1
97     ${QUEUE}=    Set Variable    QUEUE-1
98     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_node.json
99     ${sample1}    Replace String    ${sample}    127.0.0.1    ${TOOLS_SYSTEM_IP}
100     ${body}    Replace String    ${sample1}    61644    ${OVSDB_PORT}
101     ${resp}    RequestsLibrary.Post Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1    data=${body}
102     Log Config And Operational Topology
103     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_qos.json
104     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${QOS}/    data=${body}
105     Log Config And Operational Topology
106     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_queue.json
107     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:queues/${QUEUE}/    data=${body}
108     Log Config And Operational Topology
109     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/bug_7160/create_qoslinkedqueue.json
110     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1    data=${body}
111     Log Config And Operational Topology
112     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${QOS}/queue-list/0/
113     Log Config And Operational Topology
114     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${QOS}/
115     Log Config And Operational Topology
116     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:queues/${QUEUE}/
117     Log Config And Operational Topology
118     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1
119     Log Config And Operational Topology
120     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
121     ${node}    Set Variable    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
122     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
123     Log Config And Operational Topology
124     Wait Until Keyword Succeeds    5s    1s    Config and Operational Topology Should Be Empty
125     [Teardown]    Run Keywords    Clean OVSDB Test Environment
126     ...    AND    Report_Failure_Due_To_Bug    7160
127
128 *** Keywords ***
129 OVSDB Connection Manager Suite Setup
130     SetupUtils.Setup_Utils_For_Setup_And_Teardown
131     Open Controller Karaf Console On Background
132     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
133     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
134     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
135     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
136     Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-manager
137
138 OVSDB Connection Manager Suite Teardown
139     [Documentation]    Cleans up test environment, close existing sessions.
140     Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
141     # Best effort to clean config store, by deleting all the types of nodes that are used in this suite
142     ${node}    Set Variable    ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
143     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
144     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
145     ${node}    Set Variable    ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}
146     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}
147     RequestsLibrary.Delete Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/${node}%2Fbridge%2F${BRIDGE}
148     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
149     Log    ${resp.content}
150     Delete All Sessions
151     # TODO: both Create Bridge and Connect Controller To OVSDB Node keywords below should be moved to a library
152     #    and all the suites using this kind of work can move to using the library instead of
153     #    doing all this work each time.
154
155 Create Bridge
156     [Arguments]    ${node_string}    ${bridge}
157     [Documentation]    This will create bridge on the specified OVSDB node.
158     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
159     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://${node_string}
160     ${body}    Replace String    ${body}    tcp:127.0.0.1:6633    tcp:${ODL_SYSTEM_IP}:6633
161     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
162     ${body}    Replace String    ${body}    br01    ${bridge}
163     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
164     ${node_string}    Replace String    ${node_string}    /    %2F
165     ${uri}=    Set Variable    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${node_string}%2Fbridge%2F${bridge}
166     Log    URL is ${uri}
167     Log    data: ${body}
168     ${resp}    RequestsLibrary.Put Request    session    ${uri}    data=${body}
169     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
170
171 Connect Controller To OVSDB Node
172     [Documentation]    Initiate the connection to OVSDB node from controller
173     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/connect.json
174     ${sample1}    Replace String    ${sample}    127.0.0.1    ${TOOLS_SYSTEM_IP}
175     ${body}    Replace String    ${sample1}    61644    ${OVSDB_PORT}
176     Log    data: ${body}
177     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_PORT}    data=${body}
178     Log    ${resp.content}
179     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
180     Wait Until Keyword Succeeds    5s    1s    Verify OVS Reports Connected
181
182 Log Config And Operational Topology
183     [Documentation]    For debugging purposes, this will log both config and operational topo data stores
184     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
185     Log    ${resp.content}
186     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_TOPO_API}
187     Log    ${resp.content}
188
189 Config and Operational Topology Should Be Empty
190     [Documentation]    This will check that only the expected output is there for both operational and config
191     ...    topology data stores. Empty probably means that only ovsdb:1 is there.
192     ${config_resp}    RequestsLibrary.Get Request    session    ${CONFIG_TOPO_API}
193     ${operational_resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_TOPO_API}
194     Should Be Equal As Strings    ${config_resp.content}    {"network-topology":{"topology":[{"topology-id":"ovsdb:1"}]}}
195     Should Be Equal As Strings    ${operational_resp.content}    {"network-topology":{"topology":[{"topology-id":"ovsdb:1"}]}}