First test case for Switch Manager
[integration/test.git] / test / csit / suites / base / 005__switch_Manager.txt
1 *** Settings ***
2 Documentation     Test suite for the switch manager bundle.
3 Suite Setup       Create Session    ${ODL_CONTROLLER_SESSION}    http://${CONTROLLER}:8080    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]    list_info
19     Log    ${TOPO_TREE_LEVEL}
20     ${topo_nodes}    Get Nodes From Topology    ${TOPO_TREE_LEVEL}
21     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/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     Collection Should Contain    ${nodes}    ${topo_nodes}
26 Get a node
27     [Documentation]    Get a node
28     Get node    00:00:00:00:00:00:00:02    OF
29 Add property to node
30     [Documentation]    Add a property to node
31     Add property to node    OF    00:00:00:00:00:00:00:02    description     Switch2
32     Node property should exist    OF    00:00:00:00:00:00:00:02    description    Switch2
33 Remove property from node
34     [Documentation]    Remove a property from node
35     Remove property from node    OF    00:00:00:00:00:00:00:02    description
36     Node property should not exist    OF    00:00:00:00:00:00:00:02     description    Switch2
37 Add property to nodeconnector
38     [Documentation]    Add a property to nodeconnector
39     Add property to nodeconnector    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    1000
40     Nodeconnector property should exist    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    ${1000}
41
42 Remove property from nodeconnector
43     [Documentation]    Remove a property from nodeconnector
44     Remove property from nodeconnector    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth
45     Nodeconnector property should not exist    OF    00:00:00:00:00:00:00:02    OF    2    bandwidth    ${1000}
46
47 *** Keywords ***
48 Get node
49     [Arguments]    ${node_id}    ${node_type}
50     [Documentation]    Get a specific node
51     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
52     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
53     ${result}    TO JSON    ${resp.content}
54     ${node}    Create Dictionary    id    ${node_id}    type    ${node_type}
55     ${content}    Extract All Nodes    ${result}
56     Log    ${content}
57     List Should Contain Value    ${content}    ${node}
58
59 Add property to node
60     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
61     [Documentation]    Add property to node
62     ${resp}    Put    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}/property/${property}/${value}
63     Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
64
65 Remove property from node
66     [Arguments]    ${node_type}    ${node_id}    ${property}
67     [Documentation]    Remove property from node
68     ${resp}    Delete    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}/property/${property}
69     Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
70
71 Add property to nodeconnector
72     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
73     [Documentation]    Add property to nodeconnector
74     ${resp}    Put    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodeconnector/${node_type}/${node_id}/${nc_type}/${nc_id}/property/${property}/${value}
75     Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
76
77 Remove property from nodeconnector
78     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}
79     [Documentation]    Remove property from nodeconnector
80     ${resp}    Delete    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodeconnector/${node_type}/${node_id}/${nc_type}/${nc_id}/property/${property}
81     Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
82
83 Node property should exist
84     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
85     [Documentation]    Property of node should exist
86     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
87     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
88     ${result}    TO JSON    ${resp.content}
89     Log    ${result}
90     ${nodes}    Extract All Nodes    ${result}
91     ${property_values}    Extract Node Property Values    ${result}    ${property}
92     ${node}    Create Dictionary    id    ${node_id}    type    ${node_type}
93     ${property_value}    Create Dictionary    value    ${value}
94     Log    ${property_value}
95     List Should Contain Value    ${nodes}    ${node}
96     List Should Contain Value    ${property_values}    ${property_value}
97
98 Node property should not exist
99     [Arguments]    ${node_type}    ${node_id}    ${property}    ${value}
100     [Documentation]    Property of node should not exist
101     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/nodes
102     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
103     ${result}    TO JSON    ${resp.content}
104     Log    ${result}
105     ${nodes}    Extract All Nodes    ${result}
106     ${properties}    Extract Node Property Values    ${result}    ${property}
107     ${node}    Create Dictionary    id    ${node_id}    type    ${node_type}
108     ${property}    Create Dictionary    value    ${value}
109     Log    ${property}
110     List Should Contain Value    ${nodes}    ${node}
111     List Should Not Contain Value    ${properties}    ${property}
112
113 Nodeconnector property should exist
114     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
115     [Documentation]    Property of nodeconnector should exist
116     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}
117     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
118     ${result}    TO JSON    ${resp.content}
119     Log    ${result}
120     ${property_values}    Extract Nodeconnector Property Values    ${result}    ${property}
121     Log    ${property_values}
122     ${property_value}    Create Dictionary    value    ${value}
123     List Should Contain Value    ${property_values}    ${property_value}
124
125 Nodeconnector property should not exist
126     [Arguments]    ${node_type}    ${node_id}    ${nc_type}    ${nc_id}    ${property}    ${value}
127     [Documentation]    Property of nodeconnector should not exist
128     ${resp}    Get    ${ODL_CONTROLLER_SESSION}    ${REST_CONTEXT}/${CONTAINER}/node/${node_type}/${node_id}
129     Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
130     ${result}    TO JSON    ${resp.content}
131     Log    ${result}
132     ${property_values}    Extract Nodeconnector Property Values    ${result}    ${property}
133     Log    ${property_values}
134     ${property_value}    Create Dictionary    value    ${value}
135     List Should not Contain Value    ${property_values}    ${property_value}
136
137 List all nodeconnectors of node
138     [Arguments]    ${node_type}    ${node_id}
139     [Documentation]    List all nodeconnectors and properties of node