405314740bd29ce4767757cecb8c5e32b93a724b
[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 Variables         ../../../variables/Variables.py
12 Resource          ../../../libraries/FlowLib.robot
13 Library           ../../../libraries/XmlComparator.py
14
15 *** Variables ***
16 ${XmlsDir}        ${CURDIR}/../../../../csit/variables/xmls
17 ${flowfile}       f2.xml
18 ${switch_idx}     1
19 ${switch_name}    s${switch_idx}
20
21 *** Test Cases ***
22 Update With Delete And Add
23     [Documentation]    Updates a flow by changing priority which causes delete and add flow reaction
24     Create Flow Variables For Suite From XML File    ${XmlsDir}/${flowfile}
25     Add Flow Via Restconf    ${switch_idx}    ${table_id}    ${data}
26     Check Config Flow    ${True}    ${data}
27     Log Switch Flows
28     Wait Until Keyword Succeeds    30s    1s    Check Operational Flow    ${True}    ${data}
29     ${upddata}=    Replace String    ${data}    <priority>2</priority>    <priority>3</priority>
30     Update Flow Via Restconf    ${switch_idx}    ${table_id}    ${flow_id}    ${upddata}
31     Check Config Flow    ${True}    ${upddata}
32     Log Switch Flows
33     Wait Until Keyword Succeeds    30s    1s    Check Operational Flow    ${True}    ${upddata}
34     [Teardown]    Delete Flow
35
36 *** Keywords ***
37 Log Switch Flows
38     [Documentation]    Logs the switch content
39     Write    dpctl dump-flows -O OpenFlow13
40     ${switchouput}=    Read Until    mininet>
41     Log    ${switchouput}
42
43 Initialization Phase
44     [Documentation]    Starts mininet and verify if topology is in operational ds
45     Start Suite
46     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
47     Wait Until Keyword Succeeds    10s    1s    Are Switches Connected Topo
48
49 Final Phase
50     [Documentation]    Stops mininet
51     Stop Suite
52     Delete All Sessions
53
54 Are Switches Connected Topo
55     [Documentation]    Checks wheather switches are connected to controller
56     ${resp}=    RequestsLibrary.Get    session    ${OPERATIONAL_TOPO_API}/topology/flow:1    headers=${ACCEPT_XML}
57     Log    ${resp.content}
58     ${count}=    Get Element Count    ${resp.content}    xpath=node
59     Should Be Equal As Numbers    ${count}    1
60
61 Delete Flow
62     [Documentation]    Removes used flow
63     ${resp}=    RequestsLibrary.Delete    session    ${CONFIG_NODES_API}/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}
64     Log    ${resp.content}
65     ${msg}=    Set Variable    Delete flow for ${CONFIG_NODES_API}/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
66     Should Be Equal As Strings    ${resp.status_code}    200    msg=${msg}