Replace deprecated variables in suites/openflowplugin (1).
[integration/test.git] / csit / suites / openflowplugin / Groups_Meters_OF13 / 010__openflow_meter.robot
1 *** Settings ***
2 Documentation     Test suite for OpenFlow meter
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
4 Suite Teardown    Delete All Sessions
5 Library           SSHLibrary
6 Library           Collections
7 Library           OperatingSystem
8 Library           RequestsLibrary
9 Library           ../../../libraries/Common.py
10 Variables         ../../../variables/Variables.py
11 Resource          ../../../libraries/Utils.robot
12
13 *** Variables ***
14 ${REST_CONTEXT}    /restconf/operational/opendaylight-inventory:nodes/
15 ${REST_CONTEXT_CF}    /restconf/config/opendaylight-inventory:nodes/node/openflow:1
16 ${REST_CONTEXT_OP}    /restconf/operational/opendaylight-inventory:nodes/node/openflow:1
17 ${METER}          ${CURDIR}/../../../variables/xmls/m4.xml
18 ${FLOW}           ${CURDIR}/../../../variables/xmls/f51.xml
19 ${METER_NAME}     Foo
20 ${FLOW_NAME}      forward
21
22 *** Test Cases ***
23 Get list of nodes
24     [Documentation]    Get the inventory to make sure openflow:1 comes up
25     ${node_list}=    Create List    openflow:1
26     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_CONTEXT_OP}    ${node_list}
27
28 Add a meter
29     [Documentation]    Add a meter using RESTCONF
30     [Tags]    Push
31     ${body}    OperatingSystem.Get File    ${METER}
32     Set Suite Variable    ${body}
33     ${resp}    RequestsLibrary.Put    session    ${REST_CONTEXT_CF}/meter/1    headers=${HEADERS_XML}    data=${body}
34     Log    ${resp.content}
35     Should Be Equal As Strings    ${resp.status_code}    200
36
37 Verify after adding meter config
38     [Documentation]    Get the meter stat in config
39     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/meter/1
40     Log    ${resp.content}
41     Should Be Equal As Strings    ${resp.status_code}    200
42     Should Contain    ${resp.content}    ${METER_NAME}
43
44 Verify after adding meter operational
45     [Documentation]    Get the meter stat in operational
46     ${elements}=    Create List    meter-statistics    meter-kbps    flow-count    packet-in-count    byte-in-count
47     ...    meter-band-stats    meter-band-headers
48     Wait Until Keyword Succeeds    6s    2s    Check For Elements At URI    ${REST_CONTEXT_OP}/meter/1    ${elements}
49
50 Add a flow that includes a meter
51     [Documentation]    Push a flow through RESTCONF
52     [Tags]    Push
53     ${body}    OperatingSystem.Get File    ${FLOW}
54     Set Suite Variable    ${body}
55     ${resp}    RequestsLibrary.Put    session    ${REST_CONTEXT_CF}/table/0/flow/2    headers=${HEADERS_XML}    data=${body}
56     Log    ${resp.content}
57     Should Be Equal As Strings    ${resp.status_code}    200
58
59 Verify after adding flow config
60     [Documentation]    Verify the flow
61     [Tags]    Get
62     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/table/0/flow/2
63     Log    ${resp.content}
64     Should Be Equal As Strings    ${resp.status_code}    200
65     Should Contain    ${resp.content}    ${FLOW_NAME}
66
67 Verify after adding flow operational
68     [Documentation]    Verify the flow
69     ${elements}=    Create List    meter-id    flow
70     Wait Until Keyword Succeeds    6s    2s    Check For Elements At URI    ${REST_CONTEXT_OP}/table/0/flow/2    ${elements}
71
72 Remove the flow
73     [Documentation]    Remove the flow
74     ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT_CF}/table/0/flow/2
75     Should Be Equal As Strings    ${resp.status_code}    200
76
77 Verify after deleting flow
78     [Documentation]    Verify the flow removal
79     [Tags]    Get
80     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/table/0/flow/2
81     Should Not Contain    ${resp.content}    ${FLOW_NAME}
82
83 Delete the meter
84     [Documentation]    Remove the meter
85     [Tags]    Delete
86     ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT_CF}/meter/1
87     Log    ${resp.content}
88     Should Be Equal As Strings    ${resp.status_code}    200
89
90 Verify after deleting meter
91     [Documentation]    Verify the flow removal
92     [Tags]    Get
93     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/meter/1
94     Should Not Contain    ${resp.content}    ${METER_NAME}