b6836def759b84adfe64aae37eb2afc1a7f8d26c
[integration/test.git] / csit / suites / openflowplugin / Flows_Additional_TCs / 030_Flow_Update_Test.robot
1 *** Settings ***
2 Documentation     Test suite with independent flow tests
3 Suite Setup       Initialization Phase
4 Suite Teardown    Final Phase
5 Library           String
6 Library           Collections
7 Library           XML
8 Library           RequestsLibrary
9 Library           SSHLibrary
10 Resource          ../../../libraries/Utils.robot
11 Resource          ../../../libraries/FlowLib.robot
12 Resource          ../../../variables/openflowplugin/Variables.robot
13 Variables         ../../../variables/Variables.py
14 Library           ../../../libraries/XmlComparator.py
15
16 *** Variables ***
17 ${XmlsDir}        ${CURDIR}/../../../../csit/variables/xmls
18 ${flowfile}       f2.xml
19 ${switch_idx}     1
20 ${switch_name}    s${switch_idx}
21
22 *** Test Cases ***
23 Update With Delete And Add
24     [Documentation]    Updates a flow by changing priority which causes delete and add flow reaction
25     Create Flow Variables For Suite From XML File    ${XmlsDir}/${flowfile}
26     Add Flow Via Restconf    ${switch_idx}    ${table_id}    ${data}
27     Check Config Flow    ${True}    ${data}
28     Log Switch Flows
29     Wait Until Keyword Succeeds    30s    1s    Check Operational Flow    ${True}    ${data}
30     ${upddata}=    Replace String    ${data}    <priority>2</priority>    <priority>3</priority>
31     Update Flow Via Restconf    ${switch_idx}    ${table_id}    ${flow_id}    ${upddata}
32     Check Config Flow    ${True}    ${upddata}
33     Log Switch Flows
34     Wait Until Keyword Succeeds    30s    1s    Check Operational Flow    ${True}    ${upddata}
35     [Teardown]    Delete Flow
36
37 *** Keywords ***
38 Log Switch Flows
39     [Documentation]    Logs the switch content
40     Write    dpctl dump-flows -O OpenFlow13
41     ${switchouput}=    Read Until    mininet>
42     Log    ${switchouput}
43
44 Initialization Phase
45     [Documentation]    Starts mininet and verify if topology is in operational ds
46     Start Mininet
47     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
48     Wait Until Keyword Succeeds    10s    1s    FlowLib.Check Switches In Topology    1
49
50 Final Phase
51     [Documentation]    Stops mininet
52     Stop Mininet
53     Delete All Sessions
54
55 Delete Flow
56     [Documentation]    Removes used flow
57     ${resp}=    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
58     Log    ${resp.content}
59     ${msg}=    Set Variable    Delete flow for ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
60     Should Be Equal As Strings    ${resp.status_code}    200    msg=${msg}