... cookie and barrier fields, string formatted xml that can be used to push to
... controller). TODO: Remove hard dependency on controller HTTP "session".
-Library XML
-Library String
+Library OperatingSystem
Library RequestsLibrary
-Library ScaleClient.py
+Library String
+Library XML
+Library Common.py
Library FlowLib.py
+Library ScaleClient.py
Library XmlComparator.py
-Library Common.py
Resource CompareStream.robot
+Resource TemplatedRequests.robot
Resource ../variables/openflowplugin/Variables.robot
Variables ../variables/Variables.py
Check No Switches In Inventory
[Documentation] Check no switch is in inventory
[Arguments] ${switches}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
+ ${resp}= RequestsLibrary.GET On Session
+ ... session
+ ... url=${RFC8040_OPERATIONAL_NODES_API}
+ ... expected_status=200
Log ${resp.text}
FOR ${switch} IN RANGE 1 ${switches+1}
Should Not Contain ${resp.text} "openflow:${switch}"
Check No Switches In Topology
[Documentation] Check no switch is in topology
[Arguments] ${switches}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
FOR ${switch} IN RANGE 1 ${switches+1}
Should Not Contain ${resp.text} openflow:${switch}
END
[Documentation] Check all switches and stats in operational inventory
[Arguments] ${switches}
FOR ${switch} IN RANGE 1 ${switches+1}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_NODES_API}/node=openflow%3A${switch}
+ ${resp}= RequestsLibrary.GET On Session
+ ... session
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${switch}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
Should Contain ${resp.text} flow-capable-node-connector-statistics
Should Contain ${resp.text} flow-table-statistics
END
Check Switches In Topology
[Documentation] Check switches are in the topology.
[Arguments] ${switches}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
${count}= Get Count ${resp.text} "node-id":"openflow:
BuiltIn.Should Be Equal As Numbers ${count} ${switches}
Check Number Of Links
[Documentation] Check number of links in the topolgy.
[Arguments] ${links}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
${count}= Get Count ${resp.text} "link-id":"openflow:
Should Be Equal As Integers ${count} ${links}
Check Linear Topology
[Documentation] Check Linear topology.
[Arguments] ${switches}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
FOR ${switch} IN RANGE 1 ${switches+1}
Should Contain ${resp.text} "node-id":"openflow:${switch}"
Should Contain ${resp.text} "tp-id":"openflow:${switch}:1"
Check Number Of Flows
[Documentation] Check number of flows in the inventory.
[Arguments] ${flows}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
+ ${resp}= RequestsLibrary.GET On Session
+ ... session
+ ... url=${RFC8040_OPERATIONAL_NODES_API}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
${count}= Get Count ${resp.text} "priority"
Should Be Equal As Integers ${count} ${flows}
Check Number Of Groups
[Documentation] Check number of groups in the inventory.
[Arguments] ${groups}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
+ ${resp}= RequestsLibrary.GET On Session
+ ... session
+ ... url=${RFC8040_OPERATIONAL_NODES_API}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
${group_count}= Get Count ${resp.text} "group-type"
Should Be Equal As Integers ${group_count} ${groups}
Check Flow Stats Are Available
[Documentation] A GET on the /node=${node_id} inventory API is made and flow stats string is checked for existence.
[Arguments] ${node_id} ${flows}
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.GET On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=2
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=2
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
Should Contain X Times ${resp.text} priority ${flows}
Check Number Of Hosts
[Documentation] Check number of hosts in topology
[Arguments] ${hosts}
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
${count}= Get Count ${resp.text} "node-id":"host:
Should Be Equal As Integers ${count} ${hosts}
Check No Hosts
[Documentation] Check if all hosts are deleted from inventory
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
- Should Be Equal As Strings ${resp.status_code} 200
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_TOPO_API} expected_status=200
Should Not Contain ${resp.text} "node-id":"host:
Add Table Miss Flows
Add Group To Controller And Verify
[Documentation] Push group through REST-API and verify in data-store
[Arguments] ${group_body} ${node_id} ${group_id}
- ${resp}= RequestsLibrary.Put Request
+ ${resp}= RequestsLibrary.PUT On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}
... headers=${HEADERS_XML}
... data=${group_body}
Log ${resp.text}
- BuiltIn.Should_Match "${resp.status_code}" "20?"
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.GET On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config
... headers=${ACCEPT_XML}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
Compare Xml ${group_body} ${resp.text}
Add Flow To Controller And Verify
[Documentation] Push flow through REST-API and verify in data-store
[Arguments] ${flow_body} ${node_id} ${table_id} ${flow_id}
- ${resp}= RequestsLibrary.Put Request
+ ${resp}= RequestsLibrary.PUT On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
... headers=${HEADERS_XML}
... data=${flow_body}
Log ${resp.text}
- BuiltIn.Should_Match "${resp.status_code}" "20?"
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.GET On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
... headers=${ACCEPT_XML}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
Compare Xml ${flow_body} ${resp.text}
Verify Flow On Mininet Switch
Remove Group From Controller And Verify
[Documentation] Remove group and verify
[Arguments] ${node_id} ${group_id}
- ${resp}= RequestsLibrary.Delete Request
+ ${resp}= RequestsLibrary.DELETE On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}
+ ... expected_status=204
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 204
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.Get On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config
+ ... expected_status=anything
IF ${resp.status_code} == 404 or ${resp.status_code} == 409 RETURN
Builtin.Log ${resp.text}
Builtin.Fail The request failed with code ${resp.status_code}
Remove Flow From Controller And Verify
[Documentation] Remove flow and verify
[Arguments] ${node_id} ${table_id} ${flow_id}
- ${resp}= RequestsLibrary.Delete Request
+ ${resp}= RequestsLibrary.DELETE On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... expected_status=204
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 204
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.Get On Session
... session
- ... ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
+ ... expected_status=anything
IF ${resp.status_code} == 404 or ${resp.status_code} == 409 RETURN
Builtin.Log ${resp.text}
Builtin.Fail The request failed with code ${resp.status_code}
write dpctl dump-flows -O OpenFlow13
${switchoutput}= Read Until >
${headers}= Create Dictionary Content-Type=application/yang-data+xml
- ${resp}= RequestsLibrary.Post Request
+ ${resp}= RequestsLibrary.POST On Session
... session
- ... rests/operations/sal-flow:remove-flow
+ ... url=rests/operations/sal-flow:remove-flow
... data=${flow.xml}
... headers=${headers}
+ ... expected_status=200
Log ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
- ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
+ ${resp}= RequestsLibrary.GET On Session session url=${RFC8040_OPERATIONAL_NODES_API}
Log ${resp.text}
Should Not Contain ${resp.text} "output-node-connector": "CONTROLLER",
${strings_to_check_for}= Create List CONTROLLER
... This keyword assumes that the global/suite variables are available (${table_id}, ${flow_id} and ${switch_idx}
[Arguments] ${expvalue}
${headers}= Create Dictionary Accept=application/xml
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.Get On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
... headers=${headers}
+ ... expected_status=anything
Log ${resp}
Log ${resp.text}
IF ${resp.status_code}!=200 RETURN ${False} ${EMPTY}
... This keyword assumes that the global/suite variables are available (${table_id}, ${flow_id} and ${switch_idx}
[Arguments] ${expvalue} ${check_id}=${False}
${headers}= Create Dictionary Accept=application/xml
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.Get On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}
... headers=${headers}
+ ... expected_status=anything
Log ${resp}
Log ${resp.text}
IF ${resp.status_code}!=200 RETURN ${False} ${EMPTY}
Set Element Attribute ${nodeelm} xmlns:inv urn:opendaylight:inventory
Log Element ${req}
${strxml}= Element To String ${req}
- ${resp}= RequestsLibrary.Post Request session /rests/operations/sal-flow:add-flow data=${strxml}
+ ${resp}= RequestsLibrary.POST On Session
+ ... session
+ ... url=/rests/operations/sal-flow:add-flow
+ ... data=${strxml}
+ ... expected_status=204
Log ${resp.text}
- ${expected_status_code}= CompareStream.Set_Variable_If_At_Least_Phosphorus 204 200
- Log ${expected_status_code}
- Should Be Equal As Strings ${resp.status_code} ${expected_status_code}
Add Flow Via Restconf
[Documentation] Configures a flow specified by given flow details (${node_id}, ${table_id}, ${flow_body}) using POST method
[Arguments] ${node_id} ${table_id} ${flow_body}
Log ${flow_body}
- ${resp}= RequestsLibrary.Post Request
+ ${resp}= RequestsLibrary.POST On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}
... data=${flow_body}
+ ... expected_status=201
Log ${resp.text}
- ${msg}= Set Variable
- ... Adding flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id} failed, http response ${resp.status_code} received.
- Should Be Equal As Strings ${resp.status_code} 201 msg=${msg}
Update Flow Via RPC
[Documentation] Updates a flow by using update-flow operation. ${xmlroot} is usually a variable created by
Set Element Attribute ${nodeelm} xmlns:inv urn:opendaylight:inventory
Log Element ${xml}
${strxml}= Element To String ${xml}
- ${resp}= RequestsLibrary.Post Request session /rests/operations/sal-flow:update-flow data=${strxml}
+ ${resp}= RequestsLibrary.POST On Session
+ ... session
+ ... url=/rests/operations/sal-flow:update-flow
+ ... data=${strxml}
+ ... expected_status=204
Log ${resp.text}
- ${expected_status_code}= CompareStream.Set_Variable_If_At_Least_Phosphorus 204 200
- Log ${expected_status_code}
- Should Be Equal As Strings ${resp.status_code} ${expected_status_code}
Update Flow Via Restconf
[Documentation] Updates a flow configuration by given flow details (${node_id}, ${table_id}, ${flow_body}) using PUT method
[Arguments] ${node_id} ${table_id} ${flow_id} ${flow_body}
Log ${flow_body}
- ${resp}= RequestsLibrary.Put Request
+ ${resp}= RequestsLibrary.PUT On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
... data=${flow_body}
+ ... expected_status=204
Log ${resp.text}
- ${msg}= Set Variable
- ... Updating flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
- Should Be Equal As Strings ${resp.status_code} 204 msg=${msg}
Delete Flow Via RPC
[Documentation] Deletes a flow by using remove-flow opearation. ${xmlroot} is usually a variable created by
Set Element Attribute ${nodeelm} xmlns:inv urn:opendaylight:inventory
Log Element ${req}
${strxml}= Element To String ${req}
- ${resp}= RequestsLibrary.Post Request session /rests/operations/sal-flow:remove-flow data=${strxml}
+ ${resp}= RequestsLibrary.POST On Session
+ ... session
+ ... url=/rests/operations/sal-flow:remove-flow
+ ... data=${strxml}
+ ... expected_status=204
Log ${resp.text}
- ${expected_status_code}= CompareStream.Set_Variable_If_At_Least_Phosphorus 204 200
- Log ${expected_status_code}
- Should Be Equal As Strings ${resp.status_code} ${expected_status_code}
Delete Flow Via Restconf
[Documentation] Deletes a flow from configuration datastore specified by given flow details (${node_id}, ${table_id}, ${flow_body}) using DELETE method
[Arguments] ${node_id} ${table_id} ${flow_id}
- ${resp}= RequestsLibrary.Delete Request
+ ${resp}= RequestsLibrary.DELETE On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+ ... expected_status=204
Log ${resp.text}
- ${msg}= Set Variable
- ... Delete flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
- Should Be Equal As Strings ${resp.status_code} 204 msg=${msg}
Get Flow Id
[Documentation] This verifies specific flow-id for particular table-id matching from the flow element
[Arguments] ${dpnid} ${table_id} ${flow_element}
- ${resp}= RequestsLibrary.Get Request
+ ${resp}= RequestsLibrary.GET On Session
... session
- ... ${RFC8040_NODES_API}/node=openflow%3A${dpnid}/flow-node-inventory:table=${table_id}?content=config
+ ... url=${RFC8040_NODES_API}/node=openflow%3A${dpnid}/flow-node-inventory:table=${table_id}?content=config
BuiltIn.Log ${resp.text}
@{flow_id}= String.Get Regexp Matches ${resp.text} id\":\"(\\d+${flow_element}) 1
RETURN @{flow_id}[0]