Merge "Add missing comma to list, related to 16559"
[integration/test.git] / test / tools / OF_Test / robot_suites / 998__Independent_OF_Tests_ovs / 020__Flow_Data_Tests.txt
1 *** Settings ***
2 Documentation     Test suite with independent flow tests
3 Library           OperatingSystem
4 Library           Collections
5 Library           String
6 Library           XML
7 Library           SSHLibrary
8 Library           ../../../../csit/libraries/XmlComparator.py
9 Variables         ../../../../csit/variables/Variables.py
10 Library           ../../../../csit/libraries/RequestsLibrary.py
11 Library           ../../../../csit/libraries/Common.py
12 Suite Setup       Init Phase    3
13 Suite Teardown    Stop Phase
14
15 *** Variables ***
16 ${XmlsDir}=       ${CURDIR}/../../../../csit/variables/xmls
17 ${switch_idx}=    1
18 ${switch_name}=   s${switch_idx}
19
20 *** Test Cases ***
21 Barrier Field True
22       [Documentation]   Adding flow with barrier set to true
23       [Teardown]        Delete Flow
24       Init Flow Variables   f1.xml
25       ${data}=   Replace String     ${data}   <barrier>false</barrier>    <barrier>true</barrier>
26       Set Suite Variable    ${data}
27       Add Flow
28       Sleep    15s
29       Log Switch Flows
30       Check Config Flow         ${True}   ${data}
31       Check Operational Table   ${True}   ${data}
32 Update With Delete And Add
33       [Documentation]   Updates a flow by changing priority which causes delete and add flow reaction
34       [Teardown]        Delete Flow
35       Init Flow Variables   f2.xml
36       Add Flow
37       Sleep    15s
38       Log Switch Flows
39       Check Config Flow         ${True}   ${data}
40       Check Operational Table   ${True}   ${data}
41       ${upddata}=   Replace String     ${data}   <priority>2</priority>    <priority>3</priority>
42       Set Suite Variable    ${upddata}
43       Update Flow
44       Sleep    30s
45       Log Switch Flows
46       Check Config Flow         ${True}   ${upddata}
47       Check Operational Table   ${True}   ${upddata}
48
49 *** Keywords ***
50 Init Phase   [Arguments]   ${swnr}
51       [Documentation]    Starts mininet with requested number of switches (${swnr})
52       Log    Starting mininet with ${swnr} switches
53       Open Connection   ${MININET}   prompt=>
54       Login With Public Key   ${MININET_USER}   ${USER_HOME}/.ssh/id_rsa   any
55       Set Client Configuration    timeout=600
56       Write   sudo ovs-vsctl set-manager ptcp:6644
57       Write   sudo mn -c
58       Read Until   >
59       Write    sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,${swnr} --switch ovsk,protocols=OpenFlow13
60       Read Until   mininet>
61       Create Session   session   http://${CONTROLLER}:${PORT}   auth=${AUTH}   headers=${HEADERS_XML}
62 Stop Phase
63     [Documentation]    Stops mininet 
64     Log    Stopping mininet
65     Delete All Sessions
66     Read
67     Write   exit
68     Read Until    >
69     Close Connection
70     Delete All Sessions
71 Init Flow Variables   [Arguments]   ${file}
72       ${data}=       OperatingSystem.Get File     ${XmlsDir}/${file}
73       ${xmlroot}=    Parse Xml    ${XmlsDir}/${file}
74       ${table_id}=   Get Element Text   ${xmlroot}   table_id
75       ${flow_id}=    Get Element Text   ${xmlroot}   id
76       ${flow_priority}=    Get Element Text   ${xmlroot}   priority
77       ${upddata}=    Get Data For Flow Put Update   ${data}
78       Set Suite Variable   ${table_id}
79       Set Suite Variable   ${flow_id}
80       Set Suite Variable   ${flow_priority}
81       Set Suite Variable   ${data}
82       Set Suite Variable   ${upddata}
83       Set Suite Variable   ${xmlroot}
84 Check Config Flow   [Arguments]   ${expected}   ${expvalue}
85          ${presence_flow}   ${msg}=      Flow Presence Config Flow    ${expvalue}
86          ${msgf}=   Get Presence Failure Message    config    ${expected}    ${presence_flow}   ${msg}
87          Should Be Equal    ${expected}  ${presence_flow}   msg=${msgf}
88 Flow Presence Config Flow  [Arguments]   ${expvalue}
89          ${headers}=      Create Dictionary   Accept   application/xml
90          ${resp}=   Get  session  /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}   headers=${headers}
91          Log  ${resp}
92          Log  ${resp.content}
93          Return From Keyword If   ${resp.status_code}!=200  ${False}   ${EMPTY}
94          ${pres}  ${msg}=  Is Flow Configured  ${expvalue}   ${resp.content}
95          Run Keyword If   '''${msg}'''!='${EMPTY}'   Log   ${msg}
96          Return From Keyword   ${pres}   ${msg}
97 Check Operational Table  [Arguments]   ${expected}    ${expvalue}
98          ${presence_table}  ${msg}=  Flow Presence Operational Table   ${expvalue}
99          ${msgf}=   Get Presence Failure Message    operational    ${expected}    ${presence_table}   ${msg}
100          Should Be Equal  ${expected}  ${presence_table}  msg=${msgf}
101 Flow Presence Operational Table   [Arguments]  ${expvalue}
102          ${headers}=      Create Dictionary   Accept   application/xml
103          ${resp}=   Get   session   /restconf/operational/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}    headers=${headers}
104          Log   ${resp}
105          Log   ${resp.content}
106          Return From Keyword If    ${resp.status_code}!=200   ${False}   ${EMPTY}
107          ${pres}   ${msg}=   Is Flow Operational2   ${expvalue}   ${resp.content}
108          Run Keyword If   '''${msg}'''!='${EMPTY}'   Log   ${msg}
109          Return From Keyword   ${pres}   ${msg}
110 Add Flow
111       Log             ${data}
112       ${resp}=        Post    session   /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}   data=${data}
113       Log             ${resp.content}
114       ${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.
115       Should Be Equal As Strings   ${resp.status_code}   204   msg=${msg}
116 Update Flow
117        Log          ${upddata}
118        ${resp}=     Putxml    session  /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}  data=${upddata}
119        Log             ${resp.content}
120        ${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.
121        Should Be Equal As Strings  ${resp.status_code}   200    msg=${msg}
122 Delete Flow
123       ${resp}=  Delete   session   /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}
124       Log             ${resp.content}
125       ${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.
126       Should Be Equal As Strings   ${resp.status_code}   200   msg=${msg}
127 Get Presence Failure Message   [Arguments]   ${ds}   ${expected}   ${presence}  ${diffmsg}
128          Return From Keyword If   '''${diffmsg}'''!='${EMPTY}'  Flow found in ${ds} data store but: ${diffmsg}
129          ${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
130          ${msgp}=   Set Variable If   ${presence}==${True}   it is present.   it is not present.
131          Return From Keyword   ${msgf} ${msgp}
132 Log Switch Flows
133         Write    dpctl dump-flows -O OpenFlow13
134         Sleep  1s
135         ${switchouput}    Read
136         Log     ${switchouput}
137