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