d273ed3a55e97ac67fe4f467c3833d377320d03c
[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    Delete All Sessions
5 Test Setup        Log Testcase Start To Controller Karaf
6 Library           OperatingSystem
7 Library           String
8 Library           RequestsLibrary
9 Variables         ../../../variables/Variables.py
10 Resource          ../../../libraries/Utils.robot
11
12 *** Variables ***
13 ${OVSDB_PORT}     6634
14 ${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${MININET}:${OVSDB_PORT}
15 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
16 @{node_list}      ovsdb://${MININET}:${OVSDB_PORT}    ${MININET}    ${OVSDB_PORT}    br-int
17
18 *** Test Cases ***
19 Connecting an OVS instance to the controller
20     [Tags]    Southbound
21     Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-manager
22     Run Command On Remote System    ${MININET}    sudo ovs-vsctl set-manager tcp:${CONTROLLER}:6640
23
24 Get Operational Topology to verify the ovs instance is connected to the controller
25     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
26     [Tags]    Southbound
27     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${node_list}
28
29 Get Config Topology
30     [Documentation]    This request will fetch the configuration topology from configuration data store
31     [Tags]    Southbound
32     ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
33     Log    ${resp.content}
34     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
35     Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-int
36
37 Create bridge manually
38     [Tags]    Southbound
39     Run Command On Remote System    ${MININET}    sudo ovs-vsctl add-br br-s1
40
41 Get Operational Topology to verify the bridge has been added
42     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
43     [Tags]    Southbound
44     @{list}    Create List    br-s1
45     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${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     [Tags]    Southbound
50     ${resp}    RequestsLibrary.Get    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://${MININET}:${OVSDB_PORT}/bridge/br-s1
54
55 Create a Bridge through controller
56     [Documentation]    This will create bridge on the specified OVSDB node.
57     [Tags]    Southbound
58     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
59     ${sample1}    Replace String    ${sample}    tcp:127.0.0.1:6633    tcp:${CONTROLLER}:6633
60     ${sample2}    Replace String    ${sample1}    127.0.0.1    ${MININET}
61     ${sample3}    Replace String    ${sample2}    br01    br-s2
62     ${body}    Replace String    ${sample3}    61644    ${OVSDB_PORT}
63     Log    URL is ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s2
64     ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s2    data=${body}
65     Log    ${resp.content}
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     [Tags]    Southbound
71     @{list}    Create List    br-s2
72     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${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     [Tags]    Southbound
77     ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
78     Log    ${resp.content}
79     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
80     Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s2
81
82 Create bridge of already added bridge
83     [Documentation]    This will add bridge to the config datastore
84     [Tags]    Southbound
85     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
86     ${sample1}    Replace String    ${sample}    tcp:127.0.0.1:6633    tcp:${CONTROLLER}:6633
87     ${sample2}    Replace String    ${sample1}    127.0.0.1    ${MININET}
88     ${sample3}    Replace String    ${sample2}    br01    br-s1
89     ${body}    Replace String    ${sample3}    61644    ${OVSDB_PORT}
90     Log    URL is ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1
91     ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1    data=${body}
92     Log    ${resp.content}
93     Should Be Equal As Strings    ${resp.status_code}    200
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     [Tags]    Southbound
98     ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
99     Log    ${resp.content}
100     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
101     Should Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s1
102
103 Delete bridge manually
104     [Tags]    Southbound
105     Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-br br-s2
106
107 Get Operational Topology to verify the bridge has been deleted manually
108     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
109     [Tags]    Southbound
110     @{list}    Create List    br-s2
111     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
112
113 Get Config Topology to verify the entry deleted from the config datastore
114     [Documentation]    This request will fetch the configuration topology from configuration data store
115     [Tags]    Southbound
116     ${resp}    RequestsLibrary.Get    session    ${CONFIG_TOPO_API}
117     Log    ${resp.content}
118     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
119     Should not Contain    ${resp.content}    ovsdb://${MININET}:${OVSDB_PORT}/bridge/br-s2
120
121 Delete the Bridge through rest call
122     [Documentation]    This request will delete the bridge node from the config data store.
123     [Tags]    Southbound
124     ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-s1
125     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
126
127 Get Operational Topology after Deletion of Bridge
128     [Documentation]    This request will fetch the operational topology after the Bridge is deleted
129     [Tags]    Southbound
130     @{list}    Create List    br-s1
131     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
132
133 Delete the integration Bridge
134     [Documentation]    This request will delete the bridge node from the config data store.
135     [Tags]    Southbound
136     ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}%2Fbridge%2Fbr-int
137     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
138
139 Get Operational Topology after Deletion of integration Bridge
140     [Documentation]    This request will fetch the operational topology after the Bridge is deleted
141     [Tags]    Southbound
142     @{list}    Create List    br-int    br-s1
143     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
144
145 *** Keywords ***
146 OVSDB Connection Manager Suite Setup
147     Open Controller Karaf Console On Background
148     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}