Correctly space expected_status
[integration/test.git] / csit / suites / openflowplugin / Groups_Meters_OF13 / 005__openflow_group.robot
1 *** Settings ***
2 Documentation       Test suite for OpenFlow group
3
4 Library             SSHLibrary
5 Library             Collections
6 Library             OperatingSystem
7 Library             RequestsLibrary
8 Library             ../../../libraries/Common.py
9 Variables           ../../../variables/Variables.py
10 Resource            ../../../variables/openflowplugin/Variables.robot
11 Resource            ../../../libraries/Utils.robot
12
13 Suite Setup         Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
14 Suite Teardown      Delete All Sessions
15
16
17 *** Variables ***
18 ${REST_CONTEXT}     ${RFC8040_NODES_API}/node=openflow%3A1
19 ${GROUP}            ${CURDIR}/../../../variables/xmls/g4.xml
20 ${FLOW}             ${CURDIR}/../../../variables/xmls/f50.xml
21 ${GROUP_NAME}       Foo
22 ${FLOW_NAME}        forward
23
24
25 *** Test Cases ***
26 Get list of nodes
27     [Documentation]    Get the inventory to make sure openflow:1 comes up
28     ${node_list}    Create List    openflow:1
29     Wait Until Keyword Succeeds
30     ...    90s
31     ...    1s
32     ...    Check For Elements At URI
33     ...    ${REST_CONTEXT}?${RFC8040_OPERATIONAL_CONTENT}
34     ...    ${node_list}
35
36 Add a group
37     [Documentation]    Add a group using RESTCONF
38     [Tags]    push
39     ${body}    OperatingSystem.Get File    ${GROUP}
40     Set Suite Variable    ${body}
41     ${resp}    RequestsLibrary.Put Request
42     ...    session
43     ...    ${REST_CONTEXT}/flow-node-inventory:group=1
44     ...    headers=${HEADERS_XML}
45     ...    data=${body}
46     Log    ${resp.content}
47     BuiltIn.Should_Match    "${resp.status_code}"    "20?"
48
49 Verify after adding group config
50     [Documentation]    Get the group stat in config
51     ${resp}    RequestsLibrary.Get Request
52     ...    session
53     ...    ${REST_CONTEXT}/flow-node-inventory:group=1?${RFC8040_CONFIG_CONTENT}
54     Log    ${resp.content}
55     Should Be Equal As Strings    ${resp.status_code}    200
56     Should Contain    ${resp.content}    ${GROUP_NAME}
57
58 Verify after adding group operational
59     [Documentation]    Get the group stat in operational
60     ${elements}    Create List    group-statistics    ref-count    packet-count    byte-count    buckets
61     ...    weight    group-select
62     Wait Until Keyword Succeeds
63     ...    6s
64     ...    2s
65     ...    Check For Elements At URI
66     ...    ${REST_CONTEXT}/flow-node-inventory:group=1?${RFC8040_OPERATIONAL_CONTENT}
67     ...    ${elements}
68
69 Add a flow that includes a group
70     [Documentation]    Push a flow through RESTCONF
71     [Tags]    push
72     ${body}    OperatingSystem.Get File    ${FLOW}
73     Set Suite Variable    ${body}
74     ${resp}    RequestsLibrary.Put Request
75     ...    session
76     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=1
77     ...    headers=${HEADERS_XML}
78     ...    data=${body}
79     Log    ${resp.content}
80     BuiltIn.Should_Match    "${resp.status_code}"    "20?"
81
82 Verify after adding flow config
83     [Documentation]    Verify the flow
84     [Tags]    get
85     ${resp}    RequestsLibrary.Get Request
86     ...    session
87     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=1?${RFC8040_CONFIG_CONTENT}
88     Log    ${resp.content}
89     Should Be Equal As Strings    ${resp.status_code}    200
90     Should Contain    ${resp.content}    ${FLOW_NAME}
91
92 Verify after adding flow operational
93     [Documentation]    Verify the flow
94     ${elements}    Create List    group-action    group-id
95     Wait Until Keyword Succeeds
96     ...    6s
97     ...    2s
98     ...    Check For Elements At URI
99     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=1?${RFC8040_OPERATIONAL_CONTENT}
100     ...    ${elements}
101
102 Remove the flow
103     [Documentation]    Remove the flow
104     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=1
105     Should Be Equal As Strings    ${resp.status_code}    200
106
107 Verify after deleting flow
108     [Documentation]    Verify the flow removal
109     [Tags]    get
110     ${resp}    RequestsLibrary.Get Request
111     ...    session
112     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=1?${RFC8040_CONFIG_CONTENT}
113     Should Not Contain    ${resp.content}    ${FLOW_NAME}
114
115 Delete the group
116     [Documentation]    Remove the group
117     [Tags]    delete
118     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CONTEXT}/flow-node-inventory:group=1
119     Log    ${resp.content}
120     Should Be Equal As Strings    ${resp.status_code}    200
121
122 Verify after deleting group
123     [Documentation]    Verify the flow removal
124     [Tags]    get
125     ${resp}    RequestsLibrary.Get Request
126     ...    session
127     ...    ${REST_CONTEXT}/flow-node-inventory:group=1?${RFC8040_CONFIG_CONTENT}
128     Should Not Contain    ${resp.content}    ${GROUP_NAME}