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