*** Settings ***
Documentation Test suite with independent flow tests
Library OperatingSystem
Library Collections
Library String
Library XML
Library SSHLibrary
Library ../../../../csit/libraries/XmlComparator.py
Variables ../../../../csit/variables/Variables.py
Library ../../../../csit/libraries/RequestsLibrary.py
Library ../../../../csit/libraries/Common.py
Suite Setup Init Phase 3
Suite Teardown Stop Phase
*** Variables ***
${XmlsDir}= ${CURDIR}/../../../../csit/variables/xmls
${switch_idx}= 1
${switch_name}= s${switch_idx}
*** Test Cases ***
Barrier Field True
[Documentation] Adding flow with barrier set to true
[Teardown] Delete Flow
Init Flow Variables f1.xml
${data}= Replace String ${data} false true
Set Suite Variable ${data}
Add Flow
Sleep 15s
Log Switch Flows
Check Config Flow ${True} ${data}
Check Operational Table ${True} ${data}
Update With Delete And Add
[Documentation] Updates a flow by changing priority which causes delete and add flow reaction
[Teardown] Delete Flow
Init Flow Variables f2.xml
Add Flow
Sleep 15s
Log Switch Flows
Check Config Flow ${True} ${data}
Check Operational Table ${True} ${data}
${upddata}= Replace String ${data} 2 3
Set Suite Variable ${upddata}
Update Flow
Sleep 30s
Log Switch Flows
Check Config Flow ${True} ${upddata}
Check Operational Table ${True} ${upddata}
*** Keywords ***
Init Phase [Arguments] ${swnr}
[Documentation] Starts mininet with requested number of switches (${swnr})
Log Starting mininet with ${swnr} switches
Open Connection ${MININET} prompt=>
Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
Set Client Configuration timeout=600
Write sudo ovs-vsctl set-manager ptcp:6644
Write sudo mn -c
Read Until >
Write sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,${swnr} --switch ovsk,protocols=OpenFlow13
Read Until mininet>
Create Session session http://${CONTROLLER}:${PORT} auth=${AUTH} headers=${HEADERS_XML}
Stop Phase
[Documentation] Stops mininet
Log Stopping mininet
Delete All Sessions
Read
Write exit
Read Until >
Close Connection
Delete All Sessions
Init Flow Variables [Arguments] ${file}
${data}= OperatingSystem.Get File ${XmlsDir}/${file}
${xmlroot}= Parse Xml ${XmlsDir}/${file}
${table_id}= Get Element Text ${xmlroot} table_id
${flow_id}= Get Element Text ${xmlroot} id
${flow_priority}= Get Element Text ${xmlroot} priority
${upddata}= Get Data For Flow Put Update ${data}
Set Suite Variable ${table_id}
Set Suite Variable ${flow_id}
Set Suite Variable ${flow_priority}
Set Suite Variable ${data}
Set Suite Variable ${upddata}
Set Suite Variable ${xmlroot}
Check Config Flow [Arguments] ${expected} ${expvalue}
${presence_flow} ${msg}= Flow Presence Config Flow ${expvalue}
${msgf}= Get Presence Failure Message config ${expected} ${presence_flow} ${msg}
Should Be Equal ${expected} ${presence_flow} msg=${msgf}
Flow Presence Config Flow [Arguments] ${expvalue}
${headers}= Create Dictionary Accept application/xml
${resp}= Get session /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} headers=${headers}
Log ${resp}
Log ${resp.content}
Return From Keyword If ${resp.status_code}!=200 ${False} ${EMPTY}
${pres} ${msg}= Is Flow Configured ${expvalue} ${resp.content}
Run Keyword If '''${msg}'''!='${EMPTY}' Log ${msg}
Return From Keyword ${pres} ${msg}
Check Operational Table [Arguments] ${expected} ${expvalue}
${presence_table} ${msg}= Flow Presence Operational Table ${expvalue}
${msgf}= Get Presence Failure Message operational ${expected} ${presence_table} ${msg}
Should Be Equal ${expected} ${presence_table} msg=${msgf}
Flow Presence Operational Table [Arguments] ${expvalue}
${headers}= Create Dictionary Accept application/xml
${resp}= Get session /restconf/operational/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id} headers=${headers}
Log ${resp}
Log ${resp.content}
Return From Keyword If ${resp.status_code}!=200 ${False} ${EMPTY}
${pres} ${msg}= Is Flow Operational2 ${expvalue} ${resp.content}
Run Keyword If '''${msg}'''!='${EMPTY}' Log ${msg}
Return From Keyword ${pres} ${msg}
Add Flow
Log ${data}
${resp}= Post session /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id} data=${data}
Log ${resp.content}
${msg}= Set Variable Adding flow for /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
Should Be Equal As Strings ${resp.status_code} 204 msg=${msg}
Update Flow
Log ${upddata}
${resp}= Putxml session /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} data=${upddata}
Log ${resp.content}
${msg}= Set Variable Updating flow for /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
Should Be Equal As Strings ${resp.status_code} 200 msg=${msg}
Delete Flow
${resp}= Delete session /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}
Log ${resp.content}
${msg}= Set Variable Delete flow for /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
Should Be Equal As Strings ${resp.status_code} 200 msg=${msg}
Get Presence Failure Message [Arguments] ${ds} ${expected} ${presence} ${diffmsg}
Return From Keyword If '''${diffmsg}'''!='${EMPTY}' Flow found in ${ds} data store but: ${diffmsg}
${msgf}= Set Variable If ${expected}==${True} The flow is expected in ${ds} data store, but The flow is not expected in ${ds} data store, but
${msgp}= Set Variable If ${presence}==${True} it is present. it is not present.
Return From Keyword ${msgf} ${msgp}
Log Switch Flows
Write dpctl dump-flows -O OpenFlow13
Sleep 1s
${switchouput} Read
Log ${switchouput}