Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / openflowplugin / Bundlebased_Reconciliation / 010_bundle_resync.robot
1 *** Settings ***
2 Documentation     Test suite for verifying Bundle based reconciliation with switch(OVS)
3 Suite Setup       Start Suite
4 Suite Teardown    End Suite
5 Library           XML
6 Library           ${CURDIR}/../../../../csit/libraries/XmlComparator.py
7 Resource          ../../../libraries/Utils.robot
8 Resource          ../../../libraries/OVSDB.robot
9 Resource          ../../../libraries/KarafKeywords.robot
10 Resource          ../../../libraries/FlowLib.robot
11 Resource          ../../../variables/Variables.robot
12 Resource          ../../../variables/netvirt/Variables.robot
13 Resource          ../../../libraries/DataModels.robot
14
15 *** Variables ***
16 ${XMLSDIR}        ${CURDIR}/../../../../csit/variables/openflowplugin
17 @{FLOWFILE}       f279.xml    f280.xml    f281.xml    f282.xml    f283.xml    f284.xml    f278.xml
18 @{GROUPFILE}      g279.xml    g280.xml    g281.xml
19 @{GROUP_ID}       1    2    3
20 ${FLAG_MSG}       "bundle-based-reconciliation-enabled configuration property was changed to 'true'"
21 ${STATIC_FLOW}    table=91
22 @{DATA_MODELS}    config/opendaylight-inventory:nodes    operational/opendaylight-inventory:nodes
23
24 *** Test Cases ***
25 TC01_Reconciliation check after switch restart
26     [Documentation]    Verify the Bundle based reconciliation with switch(OVS) restart scenario
27     Push Static Flow    ${TOOLS_SYSTEM_IP}
28     ${switch_idx}    OVSDB.Get DPID    ${TOOLS_SYSTEM_IP}
29     Push Flow Via Restcall    ${switch_idx}    ${FLOWFILE[6]}
30     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo service openvswitch-switch restart
31     Wait Until Keyword Succeeds    5s    1s    FlowLib.Check Operational Flow    ${True}    ${data}
32     Log    Check if static flow is removed in the switch
33     ${Ovs1Flow}    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_IP}    sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenflow13
34     Should Not Contain    ${Ovs1Flow}    ${STATIC_FLOW}
35     Log    Check if flows are pushed as bundle messages
36     ${Resyncdone_msg}=    BuiltIn.Set Variable    "Completing bundle based reconciliation for device ID:${switch_idx}"
37     Check_Karaf_Log_Message_Count    ${Resyncdone_msg}    1
38
39 TC02_Reconcilation check with new switch added
40     [Documentation]    Verify the Bundle based reconciliation pushing a group dependent flow in the new switch added
41     Push Static Flow    ${TOOLS_SYSTEM_2_IP}
42     ${switch_idx}    OVSDB.Get DPID    ${TOOLS_SYSTEM_2_IP}
43     Push Groups Via Restcall    ${switch_idx}    0
44     Push Flow Via Restcall    ${switch_idx}    ${FLOWFILE[0]}
45     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo service openvswitch-switch restart
46     Wait Until Keyword Succeeds    5s    1s    FlowLib.Check Operational Flow    ${True}    ${data}
47     Log    Check if static flow is removed in the switch
48     ${Ovs1Flow}    Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenflow13
49     Should Not Contain    ${Ovs1Flow}    ${STATIC_FLOW}
50     Log    Check if flows are pushed as bundle messages
51     ${Resyncdone_msg}=    BuiltIn.Set Variable    "Completing bundle based reconciliation for device ID:${switch_idx}"
52     Check_Karaf_Log_Message_Count    ${Resyncdone_msg}    1
53
54 TC03_Reconciliation check by pushing group dependent flows
55     [Documentation]    Verify the Bundle based reconciliation by pushing multiple group dependent flows
56     ${switch_idx}    OVSDB.Get DPID    ${TOOLS_SYSTEM_2_IP}
57     FOR    ${index}    IN RANGE    1    3
58         Push Groups Via Restcall    ${switch_idx}    ${index}
59     END
60     FOR    ${index}    IN RANGE    1    6
61         Push Flow Via Restcall    ${switch_idx}    ${FLOWFILE[${index}]}
62         Set Test Variable    ${flowbody[${index}]}    ${data}
63     END
64     Utils.Run Command On Remote System    ${TOOLS_SYSTEM_2_IP}    sudo service openvswitch-switch restart
65     FOR    ${index}    IN RANGE    1    6
66         Wait Until Keyword Succeeds    5s    1s    FlowLib.Check Operational Flow    ${True}    ${flowbody[${index}]}
67     END
68     Log    Check if flows are pushed as bundle messages
69     ${Resyncdone_msg}=    BuiltIn.Set Variable    "Completing bundle based reconciliation for device ID:${switch_idx}"
70     Check_Karaf_Log_Message_Count    ${Resyncdone_msg}    2
71
72 *** Keywords ***
73 Start Suite
74     [Documentation]    Run at start of the suite
75     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
76     KarafKeywords.Issue_Command_On_Karaf_Console    log:set DEBUG org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeReconciliationImpl
77     Check_Karaf_Log_Message_Count    ${FLAG_MSG}    1
78     Configure DPN    ${TOOLS_SYSTEM_IP}
79     Configure DPN    ${TOOLS_SYSTEM_2_IP}
80
81 End Suite
82     [Documentation]    Run at end of the suite
83     RequestsLibrary.Delete Request    session    ${CONFIG_NODES_API}
84     KarafKeywords.Issue_Command_On_Karaf_Console    log:set INFO org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeReconciliationImpl
85     SSHLibrary.Close All Connections
86
87 Configure DPN
88     [Arguments]    ${ip}
89     [Documentation]    Add the bridge in the DPN specified and set manager,controller for the bridge
90     Utils.Run Command On Remote System    ${ip}    sudo ovs-vsctl add-br ${INTEGRATION_BRIDGE}
91     Utils.Run Command On Remote System    ${ip}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
92     Utils.Run Command On Remote System    ${ip}    sudo ovs-vsctl set-controller ${INTEGRATION_BRIDGE} tcp:${ODL_SYSTEM_IP}:6653
93     Utils.Run Command On Remote System    ${ip}    sudo ovs-vsctl set bridge ${INTEGRATION_BRIDGE} protocols=OpenFlow13
94     Wait Until Keyword Succeeds    20s    2s    DataModels.Get Model Dump    ${ODL_SYSTEM_IP}    ${DATA_MODELS}
95
96 Push Static Flow
97     [Arguments]    ${ip}
98     [Documentation]    Add Static Flow in the DPN specified
99     Utils.Run Command On Remote System    ${ip}    sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenflow13
100     Utils.Run Command On Remote System    ${ip}    sudo ovs-ofctl add-flow ${INTEGRATION_BRIDGE} table=91,ipv6,actions=dec_ttl -OOpenflow13
101
102 Push Flow Via Restcall
103     [Arguments]    ${switch_idx}    ${flowfile}
104     [Documentation]    Adds Flow to the specified DPN via Restcall
105     FlowLib.Create Flow Variables For Suite From XML File    ${XMLSDIR}/${flowfile}
106     FlowLib.Add Flow Via Restconf    ${switch_idx}    ${table_id}    ${data}
107     BuiltIn.Set Test Variable    ${switch_idx}
108     FlowLib.Check Config Flow    ${True}    ${data}
109     Wait Until Keyword Succeeds    5s    1s    FlowLib.Check Operational Flow    ${True}    ${data}
110
111 Push Groups Via Restcall
112     [Arguments]    ${switch_idx}    ${index}
113     ${GROUP_BODY}    OperatingSystem.Get File    ${XMLSDIR}/${GROUPFILE[${index}]}
114     ${node_id}    BuiltIn.Set Variable    openflow:${switch_idx}
115     ${group_id}    BuiltIn.Set Variable    ${GROUP_ID[${index}]}
116     FlowLib.Add Group To Controller And Verify    ${GROUP_BODY}    ${node_id}    ${group_id}
117     Wait Until Keyword Succeeds    5s    1s    Utils.Get URI And Verify    ${OPERATIONAL_NODES_API}/node/${node_id}/group/${group_id}