Correctly space expected_status
[integration/test.git] / csit / suites / openflowplugin / Groups_Meters_OF13 / 010__openflow_meter.robot
1 *** Settings ***
2 Documentation       Test suite for OpenFlow meter
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 ${METER}            ${CURDIR}/../../../variables/xmls/m4.xml
20 ${FLOW}             ${CURDIR}/../../../variables/xmls/f51.xml
21 ${METER_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     ...    3s
31     ...    1s
32     ...    Check For Elements At URI
33     ...    ${REST_CONTEXT}?${RFC8040_OPERATIONAL_CONTENT}
34     ...    ${node_list}
35
36 Add a meter
37     [Documentation]    Add a meter using RESTCONF
38     [Tags]    push
39     ${body}    OperatingSystem.Get File    ${METER}
40     Set Suite Variable    ${body}
41     ${resp}    RequestsLibrary.Put Request
42     ...    session
43     ...    ${REST_CONTEXT}/meter=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 meter config
50     [Documentation]    Get the meter stat in config
51     ${resp}    RequestsLibrary.Get Request    session    ${REST_CONTEXT}/meter=1?${RFC8040_CONFIG_CONTENT}
52     Log    ${resp.content}
53     Should Be Equal As Strings    ${resp.status_code}    200
54     Should Contain    ${resp.content}    ${METER_NAME}
55
56 Verify after adding meter operational
57     [Documentation]    Get the meter stat in operational
58     ${elements}    Create List    meter-statistics    meter-kbps    flow-count    packet-in-count    byte-in-count
59     ...    meter-band-stats    meter-band-headers
60     Wait Until Keyword Succeeds
61     ...    6s
62     ...    2s
63     ...    Check For Elements At URI
64     ...    ${REST_CONTEXT}/meter=1?${RFC8040_OPERATIONAL_CONTENT}
65     ...    ${elements}
66
67 Add a flow that includes a meter
68     [Documentation]    Push a flow through RESTCONF
69     [Tags]    push
70     ${body}    OperatingSystem.Get File    ${FLOW}
71     Set Suite Variable    ${body}
72     ${resp}    RequestsLibrary.Put Request
73     ...    session
74     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2
75     ...    headers=${HEADERS_XML}
76     ...    data=${body}
77     Log    ${resp.content}
78     BuiltIn.Should_Match    "${resp.status_code}"    "20?"
79
80 Verify after adding flow config
81     [Documentation]    Verify the flow
82     [Tags]    get
83     ${resp}    RequestsLibrary.Get Request
84     ...    session
85     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_CONFIG_CONTENT}
86     Log    ${resp.content}
87     Should Be Equal As Strings    ${resp.status_code}    200
88     Should Contain    ${resp.content}    ${FLOW_NAME}
89
90 Verify after adding flow operational
91     [Documentation]    Verify the flow
92     ${elements}    Create List    meter-id    flow
93     Wait Until Keyword Succeeds
94     ...    6s
95     ...    2s
96     ...    Check For Elements At URI
97     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_OPERATIONAL_CONTENT}
98     ...    ${elements}
99
100 Remove the flow
101     [Documentation]    Remove the flow
102     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2
103     Should Be Equal As Strings    ${resp.status_code}    200
104
105 Verify after deleting flow
106     [Documentation]    Verify the flow removal
107     [Tags]    get
108     ${resp}    RequestsLibrary.Get Request
109     ...    session
110     ...    ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_CONFIG_CONTENT}
111     Should Not Contain    ${resp.content}    ${FLOW_NAME}
112
113 Delete the meter
114     [Documentation]    Remove the meter
115     [Tags]    delete
116     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CONTEXT}/meter=1
117     Log    ${resp.content}
118     Should Be Equal As Strings    ${resp.status_code}    200
119
120 Verify after deleting meter
121     [Documentation]    Verify the flow removal
122     [Tags]    get
123     ${resp}    RequestsLibrary.Get Request    session    ${REST_CONTEXT}/meter=1?${RFC8040_CONFIG_CONTENT}
124     Should Not Contain    ${resp.content}    ${METER_NAME}