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
7 Library OperatingSystem
8 Library RequestsLibrary
9 Library ../../../libraries/Common.py
10 Variables ../../../variables/Variables.py
11 Resource ../../../variables/openflowplugin/Variables.robot
12 Resource ../../../libraries/Utils.robot
15 ${REST_CONTEXT} ${RFC8040_NODES_API}/node=openflow%3A1
16 ${METER} ${CURDIR}/../../../variables/xmls/m4.xml
17 ${FLOW} ${CURDIR}/../../../variables/xmls/f51.xml
23 [Documentation] Get the inventory to make sure openflow:1 comes up
24 ${node_list}= Create List openflow:1
25 Wait Until Keyword Succeeds 3s 1s Check For Elements At URI ${REST_CONTEXT}?${RFC8040_OPERATIONAL_CONTENT} ${node_list}
28 [Documentation] Add a meter using RESTCONF
30 ${body} OperatingSystem.Get File ${METER}
31 Set Suite Variable ${body}
32 ${resp} RequestsLibrary.Put Request session ${REST_CONTEXT}/meter=1 headers=${HEADERS_XML} data=${body}
34 BuiltIn.Should_Match "${resp.status_code}" "20?"
36 Verify after adding meter config
37 [Documentation] Get the meter stat in config
38 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}/meter=1?${RFC8040_CONFIG_CONTENT}
40 Should Be Equal As Strings ${resp.status_code} 200
41 Should Contain ${resp.content} ${METER_NAME}
43 Verify after adding meter operational
44 [Documentation] Get the meter stat in operational
45 ${elements}= Create List meter-statistics meter-kbps flow-count packet-in-count byte-in-count
46 ... meter-band-stats meter-band-headers
47 Wait Until Keyword Succeeds 6s 2s Check For Elements At URI ${REST_CONTEXT}/meter=1?${RFC8040_OPERATIONAL_CONTENT} ${elements}
49 Add a flow that includes a meter
50 [Documentation] Push a flow through RESTCONF
52 ${body} OperatingSystem.Get File ${FLOW}
53 Set Suite Variable ${body}
54 ${resp} RequestsLibrary.Put Request session ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2 headers=${HEADERS_XML} data=${body}
56 BuiltIn.Should_Match "${resp.status_code}" "20?"
58 Verify after adding flow config
59 [Documentation] Verify the flow
61 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_CONFIG_CONTENT}
63 Should Be Equal As Strings ${resp.status_code} 200
64 Should Contain ${resp.content} ${FLOW_NAME}
66 Verify after adding flow operational
67 [Documentation] Verify the flow
68 ${elements}= Create List meter-id flow
69 Wait Until Keyword Succeeds 6s 2s Check For Elements At URI ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_OPERATIONAL_CONTENT} ${elements}
72 [Documentation] Remove the flow
73 ${resp} RequestsLibrary.Delete Request session ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2
74 Should Be Equal As Strings ${resp.status_code} 200
76 Verify after deleting flow
77 [Documentation] Verify the flow removal
79 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}/flow-node-inventory:table=0/flow=2?${RFC8040_CONFIG_CONTENT}
80 Should Not Contain ${resp.content} ${FLOW_NAME}
83 [Documentation] Remove the meter
85 ${resp} RequestsLibrary.Delete Request session ${REST_CONTEXT}/meter=1
87 Should Be Equal As Strings ${resp.status_code} 200
89 Verify after deleting meter
90 [Documentation] Verify the flow removal
92 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}/meter=1?${RFC8040_CONFIG_CONTENT}
93 Should Not Contain ${resp.content} ${METER_NAME}