Merge "Changed the body of flows."
[integration/test.git] / test / csit / suites / openflowplugin / Groups_Meters_OF13 / 010__openflow_meter.txt
1 *** Settings ***
2 Documentation     Test suite for OpenFlow meter
3 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
4 Suite Teardown    Delete All Sessions
5 Library           SSHLibrary
6 Library           Collections
7 Library           OperatingSystem
8 Library           ../../../libraries/RequestsLibrary.py
9 Library           ../../../libraries/Common.py
10 Variables         ../../../variables/Variables.py
11 Resource          ../../../libraries/Utils.txt
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     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}
26     Log    ${resp.content}
27     Should Be Equal As Strings    ${resp.status_code}    200
28     Should Contain    ${resp.content}    openflow:1
29
30 Add a meter
31     [Documentation]    Add a meter using RESTCONF
32     [Tags]    Push
33     ${body}    OperatingSystem.Get File    ${METER}
34     Set Suite Variable    ${body}
35     ${resp}    Putxml    session    ${REST_CONTEXT_CF}/meter/1    data=${body}
36     Log    ${resp.content}
37     Should Be Equal As Strings    ${resp.status_code}    200
38
39 Verify after adding meter config
40     [Documentation]    Get the meter stat in config
41     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/meter/1
42     Log    ${resp.content}
43     Should Be Equal As Strings    ${resp.status_code}    200
44     Should Contain    ${resp.content}    ${METER_NAME}
45
46 Verify after adding meter operational
47     [Documentation]    Get the meter stat in operational
48     ${elements}=    Create List    meter-statistics    meter-config-stats
49     Wait Until Keyword Succeeds    60s    2s    Check For Elements At URI    ${REST_CONTEXT_OP}/meter/1    ${elements}
50
51 Add a flow that includes a meter
52     [Documentation]    Push a flow through RESTCONF
53     [Tags]    Push
54     ${body}    OperatingSystem.Get File    ${FLOW}
55     Set Suite Variable    ${body}
56     ${resp}    Putxml    session    ${REST_CONTEXT_CF}/table/0/flow/2    data=${body}
57     Log    ${resp.content}
58     Should Be Equal As Strings    ${resp.status_code}    200
59
60 Verify after adding flow config
61     [Documentation]    Verify the flow
62     [Tags]    Get
63     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/table/0/flow/2
64     Log    ${resp.content}
65     Should Be Equal As Strings    ${resp.status_code}    200
66     Should Contain    ${resp.content}    ${FLOW_NAME}
67
68 Verify after adding flow operational
69     [Documentation]    Verify the flow
70     ${elements}=    Create List    meter-id    flow
71     Wait Until Keyword Succeeds    60s    2s    Check For Elements At URI    ${REST_CONTEXT_OP}/table/0/flow/2    ${elements}
72
73 Remove the flow
74     [Documentation]    Remove the flow
75     ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT_CF}/table/0/flow/2
76     Should Be Equal As Strings    ${resp.status_code}    200
77
78 Verify after deleting flow
79     [Documentation]    Verify the flow removal
80     [Tags]    Get
81     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/table/0/flow/2
82     Should Not Contain    ${resp.content}    ${FLOW_NAME}
83
84 Delete the meter
85     [Documentation]    Remove the meter
86     [Tags]    Delete
87     ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT_CF}/meter/1
88     Log    ${resp.content}
89     Should Be Equal As Strings    ${resp.status_code}    200
90
91 Verify after deleting meter
92     [Documentation]    Verify the flow removal
93     [Tags]    Get
94     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_CF}/meter/1
95     Should Not Contain    ${resp.content}    ${METER_NAME}