Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / suites / openflowplugin / AD_SAL_NSF_OF13 / 010__switch_manager.robot
1 *** Settings ***
2 Documentation     Test suite for Switch Manager
3 Suite Setup       Create Session    ${ODL_CONTROLLER_SESSION}    http://${CONTROLLER}:${RESTPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           Collections
6 Library           RequestsLibrary
7 Library           ../../../libraries/Common.py
8 Library           ../../../libraries/SwitchManager.py
9 Variables         ../../../variables/Variables.py
10 Library           ../../../libraries/Topology.py
11
12 *** Variables ***
13 ${REST_CONTEXT}    /controller/nb/v2/switchmanager
14
15 *** Test Cases ***
16 List all nodes
17     [Documentation]    List all nodes and their properties in the network.
18     [Tags]    adsal
19     Log    ${TOPO_TREE_LEVEL}
20     ${topo_nodes}    Get Nodes From Topology    ${TOPO_TREE_LEVEL}
21     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/default/nodes
22     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
23     ${jsondata}=    To JSON    ${resp.content}
24     ${nodes}    Extract All Nodes    ${jsondata}
25     List Should Contain Sublist    ${nodes}    ${topo_nodes}
26
27 Check node 1 connectors
28     [Documentation]    List node connectors and verify all connectors are there
29     [Tags]    adsal
30     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/default/node/OF/00:00:00:00:00:00:00:01
31     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
32     Should Contain    ${resp.content}    s1-eth1
33     Should Contain    ${resp.content}    s1-eth2
34
35 Check node 2 connectors
36     [Documentation]    List node connectors and verify all connectors are there
37     [Tags]    adsal
38     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/default/node/OF/00:00:00:00:00:00:00:02
39     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
40     Should Contain    ${resp.content}    s2-eth1
41     Should Contain    ${resp.content}    s2-eth2
42     Should Contain    ${resp.content}    s2-eth3
43
44 Check node 3 connectors
45     [Documentation]    List node connectors and verify all connectors are there
46     [Tags]    adsal
47     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/default/node/OF/00:00:00:00:00:00:00:03
48     Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
49     Should Contain    ${resp.content}    s3-eth1
50     Should Contain    ${resp.content}    s3-eth2
51     Should Contain    ${resp.content}    s3-eth3
52
53 Add property to node
54     [Documentation]    Add a property to node
55     [Tags]    adsal
56     Add property to node    OF    00:00:00:00:00:00:00:02    description    Switch2
57     Node property should exist    OF    00:00:00:00:00:00:00:02    description    Switch2
58     #Remove property from node
59     #    [Documentation]    Remove a property from node
60     #    Remove property from node    OF    00:00:00:00:00:00:00:02    description
61     #    Node property should not exist    OF    00:00:00:00:00:00:00:02    description    Switch2
62
63 Add property to nodeconnector
64     [Documentation]    Add a property to nodeconnector
65     [Tags]    adsal
66     Add property to nodeconnector    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    1000
67     Nodeconnector property should exist    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    ${1000}
68
69 Remove property from nodeconnector
70     [Documentation]    Remove a property from nodeconnector
71     [Tags]    adsal
72     Remove property from nodeconnector    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth
73     Nodeconnector property should not exist    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    ${1000}
74
75 *** Keywords ***
76 Get node
77     [Arguments]    ${node_id}    ${node_type}
78     [Documentation]    Get a specific node
79     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
80     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
81     ${result}    TO JSON    ${resp.content}
82     ${node}    Create Dictionary    id=${node_id}    type={node_type}
83     ${content}    Extract All Nodes    ${result}
84     Log    ${content}
85     List Should Contain Value    ${content}    ${node}
86
87 Add property to node
88     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
89     [Documentation]    Add property to node
90     ${resp}    RequestsLibrary.Put    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}/property/${property}/${value}
91     Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
92
93 Remove property from node
94     [Arguments]    ${node_type}    ${node_id}    ${property}
95     [Documentation]    Remove property from node
96     ${resp}    RequestsLibrary.Delete    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}/property/${property}
97     Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
98
99 Add property to nodeconnector
100     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
101     [Documentation]    Add property to nodeconnector
102     ${resp}    RequestsLibrary.Put    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodeconnector/${node_type}/${node_id}/${nc_type}/${nc_id}/property/${property}/${value}
103     Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
104
105 Remove property from nodeconnector
106     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}
107     [Documentation]    Remove property from nodeconnector
108     ${resp}    RequestsLibrary.Delete    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodeconnector/${node_type}/${node_id}/${nc_type}/${nc_id}/property/${property}
109     Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
110
111 Node property should exist
112     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
113     [Documentation]    Property of node should exist
114     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
115     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
116     ${result}    TO JSON    ${resp.content}
117     Log    ${result}
118     ${nodes}    Extract All Nodes    ${result}
119     ${property_values}    Extract Node Property Values    ${result}    ${property}
120     ${node}    Create Dictionary    id=${node_id}    type=${node_type}
121     ${property_value}    Create Dictionary    value=${value}
122     Log    ${property_value}
123     List Should Contain Value    ${nodes}    ${node}
124     List Should Contain Value    ${property_values}    ${property_value}
125
126 Node property should not exist
127     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
128     [Documentation]    Property of node should not exist
129     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
130     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
131     ${result}    TO JSON    ${resp.content}
132     Log    ${result}
133     ${nodes}    Extract All Nodes    ${result}
134     ${properties}    Extract Node Property Values    ${result}    ${property}
135     ${node}    Create Dictionary    id=${node_id}    type=${node_type}
136     ${property}    Create Dictionary    value=${value}
137     Log    ${property}
138     List Should Contain Value    ${nodes}    ${node}
139     List Should Not Contain Value    ${properties}    ${property}
140
141 Nodeconnector property should exist
142     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
143     [Documentation]    Property of nodeconnector should exist
144     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}
145     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
146     ${result}    TO JSON    ${resp.content}
147     Log    ${result}
148     ${property_values}    Extract Nodeconnector Property Values    ${result}    ${property}
149     Log    ${property_values}
150     ${property_value}    Create Dictionary    value=${value}
151     List Should Contain Value    ${property_values}    ${property_value}
152
153 Nodeconnector property should not exist
154     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
155     [Documentation]    Property of nodeconnector should not exist
156     ${resp}    RequestsLibrary.Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}
157     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
158     ${result}    TO JSON    ${resp.content}
159     Log    ${result}
160     ${property_values}    Extract Nodeconnector Property Values    ${result}    ${property}
161     Log    ${property_values}
162     ${property_value}    Create Dictionary    value=${value}
163     List Should not Contain Value    ${property_values}    ${property_value}
164
165 List all nodeconnectors of node
166     [Arguments]    ${node_type}    ${node_id}
167     [Documentation]    List all nodeconnectors and properties of node