Disable stale marking feature test
[integration/test.git] / csit / suites / openflowplugin / Clustered_Reconciliation / 010_Group_Flows.robot
1 *** Settings ***
2 Documentation     Switch connections and cluster are restarted.
3 Suite Setup       Initialization Phase
4 Suite Teardown    Final Phase
5 Library           RequestsLibrary
6 Resource          ../../../libraries/ClusterManagement.robot
7 Resource          ../../../libraries/ClusterOpenFlow.robot
8 Resource          ../../../libraries/TemplatedRequests.robot
9 Resource          ../../../libraries/MininetKeywords.robot
10 Resource          ../../../libraries/Utils.robot
11 Resource          ../../../libraries/OvsManager.robot
12 Resource          ../../../variables/Variables.robot
13
14 *** Variables ***
15 ${SWITCHES}       3
16 ${ITER}           100
17 ${VAR_DIR}        ${CURDIR}/../../../variables/openflowplugin
18
19 *** Test Cases ***
20 Add Groups And Flows
21     [Documentation]    Add ${ITER} groups 1&2 and flows in every switch.
22     Add Groups And Flows On Member    ${ITER}
23
24 Start Mininet Multiple Connections
25     [Documentation]    Start mininet linear with connection to all cluster instances.
26     ${cluster_index_list}=    ClusterManagement.List All Indices
27     ${mininet_conn_id}=    MininetKeywords.Start Mininet Multiple Controllers    ${TOOLS_SYSTEM_IP}    ${cluster_index_list}    --topo linear,${SWITCHES} --switch ovsk,protocols=OpenFlow13
28     BuiltIn.Set Suite Variable    ${cluster_index_list}
29     BuiltIn.Set Suite Variable    ${mininet_conn_id}
30     BuiltIn.Wait Until Keyword Succeeds    10s    1s    OVSDB.Check OVS OpenFlow Connections    ${TOOLS_SYSTEM_IP}    ${SWITCHES*3}
31
32 Check Linear Topology
33     [Documentation]    Check Linear Topology.
34     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
35
36 Check Flows In Operational DS
37     [Documentation]    Check Flows after mininet starts.
38     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
39
40 Check Groups In Operational DS
41     [Documentation]    Check Groups after mininet starts.
42     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${all_groups}
43
44 Check Flows In Switch
45     [Documentation]    Check Flows in switch after mininet starts.
46     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${all_flows}
47
48 Check Entity Owner Status And Find Owner and Successor Before Fail
49     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
50     ${original_owner}    ${original_successor_list}    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1    1
51     BuiltIn.Set Suite Variable    ${original_owner}
52     BuiltIn.Set Suite Variable    ${new_cluster_list}    ${original_successor_list}
53
54 Disconnect Mininet From Owner
55     [Documentation]    Disconnect mininet from the owner
56     ${owner_list}    BuiltIn.Create List    ${original_owner}
57     MininetKeywords.Disconnect Cluster Mininet    break    ${owner_list}
58     BuiltIn.Set Suite Variable    ${owner_list}
59
60 Check Entity Owner Status And Find Owner and Successor After Fail
61     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
62     ${new_owner}    ${new_successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
63     ...    1    ${new_cluster_list}    after_stop=True
64     BuiltIn.Set Suite Variable    ${new_owner}
65
66 Check Switch Moves To New Master
67     [Documentation]    Check switch s1 is connected to new Master.
68     ${new_master}=    BuiltIn.Set Variable    ${ODL_SYSTEM_${new_owner}_IP}
69     BuiltIn.Wait Until Keyword Succeeds    10s    1s    OvsManager.Should Be Master    s1    ${new_master}    update_data=${True}
70
71 Check Linear Topology After Disconnect
72     [Documentation]    Check Linear Topology After Disconnecting mininet from owner.
73     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
74
75 Remove Flows And Groups After Mininet Is Disconnected
76     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
77     Remove Single Group And Flow On Member
78
79 Check Flows In Operational DS After Mininet Is Disconnected
80     [Documentation]    Check Flows in Operational DS after mininet is disconnected.
81     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${less_flows}
82
83 Check Groups In Operational DS After Mininet Is Disconnected
84     [Documentation]    Check Groups in Operational DS after mininet is disconnected.
85     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${less_groups}
86
87 Check Flows In Switch After Mininet Is Disconnected
88     [Documentation]    Check Flows in switch after mininet is disconnected
89     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${less_flows}
90
91 Reconnect Mininet To Owner
92     [Documentation]    Reconnect mininet to switch 1 owner.
93     MininetKeywords.Disconnect Cluster Mininet    restore    ${owner_list}
94
95 Check Entity Owner Status And Find Owner and Successor After Reconnect
96     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
97     ${owner}    ${successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
98     ...    1
99
100 Check Linear Topology After Reconnect
101     [Documentation]    Check Linear Topology After Reconnect.
102     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
103
104 Add Flows And Groups After Reconnect
105     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
106     Add Single Group And Flow On Member
107
108 Check Flows After Reconnect In Operational DS
109     [Documentation]    Check Flows in Operational DS after mininet is reconnected.
110     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
111
112 Check Groups After Reconnect In Operational DS
113     [Documentation]    Check Groups in Operational DS after mininet is reconnected.
114     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${all_groups}
115
116 Check Flows After Reconnect In Switch
117     [Documentation]    Check Flows in switch after mininet is reconnected.
118     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${all_flows}
119
120 Disconnect Mininet From Cluster
121     [Documentation]    Disconnect Mininet from Cluster.
122     MininetKeywords.Disconnect Cluster Mininet
123
124 Check No Switches After Disconnect
125     [Documentation]    Check no switches in topology after disconnecting mininet from cluster.
126     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check No Switches On Member    ${SWITCHES}
127
128 Check Switch Is Not Connected
129     [Documentation]    Check switch s1 is not connected to any controller.
130     : FOR    ${index}    IN    @{cluster_index_list}
131     \    BuiltIn.Wait Until Keyword Succeeds    10s    1s    OvsManager.Should Be Disconnected    s1    ${ODL_SYSTEM_${index}_IP}
132     \    ...    update_data=${True}
133
134 Reconnect Mininet To Cluster
135     [Documentation]    Reconnect mininet to cluster by removing Iptables drop rules that were used to disconnect
136     MininetKeywords.Disconnect Cluster Mininet    restore
137
138 Check Entity Owner Status And Find Owner and Successor After Reconnect Cluster
139     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
140     ${owner}    ${successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
141     ...    1
142
143 Check Linear Topology After Mininet Reconnects
144     [Documentation]    Check Linear Topology after reconnect.
145     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
146
147 Remove Flows And Groups After Mininet Reconnects
148     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
149     Remove Single Group And Flow On Member
150
151 Check Flows In Operational DS After Mininet Reconnects
152     [Documentation]    Check Flows in Operational DS after mininet is reconnected.
153     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${less_flows}
154
155 Check Groups In Operational DS After Mininet Reconnects
156     [Documentation]    Check Groups in Operational DS after mininet is reconnected to cluster.
157     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${less_groups}
158
159 Check Flows In Switch After Mininet Reconnects
160     [Documentation]    Check Flows in switch after mininet is reconnected to cluster.
161     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${less_flows}
162
163 Check Entity Owner Status And Find Owner and Successor Before Stop
164     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
165     ${original_owner}    ${original_successor_list}    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1    1
166     ${original_successor}=    Collections.Get From List    ${original_successor_list}    0
167     BuiltIn.Set Suite Variable    ${original_owner}
168     BuiltIn.Set Suite Variable    ${original_successor_list}
169     BuiltIn.Set Suite Variable    ${original_successor}
170
171 Check Shards Status before Stop
172     [Documentation]    Check Status for all shards in OpenFlow application.
173     ClusterOpenFlow.Check OpenFlow Shards Status
174
175 Stop Owner Instance
176     [Documentation]    Stop Owner Instance and verify it is shutdown
177     ClusterManagement.Stop Single Member    ${original_owner}
178     BuiltIn.Set Suite Variable    ${new_cluster_list}    ${original_successor_list}
179
180 Check Shards Status After Stop
181     [Documentation]    Check Status for all shards in OpenFlow application.
182     ClusterOpenFlow.Check OpenFlow Shards Status After Cluster Event    ${new_cluster_list}
183
184 Check Entity Owner Status And Find Owner and Successor After Stop
185     [Documentation]    Check Entity Owner Status and identify owner and successor.
186     ${new_owner}    ${new_successor_list}    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1    ${original_successor}    ${new_cluster_list}    after_stop=True
187     BuiltIn.Set Suite Variable    ${new_owner}
188
189 Check Linear Topology After Owner Stop
190     [Documentation]    Check Linear Topology.
191     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}    ${new_owner}
192
193 Add Configuration In Owner and Verify After Fail
194     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
195     Add Single Group And Flow On Member    ${new_owner}
196
197 Check Flows In Operational DS After Owner Is Stopped
198     [Documentation]    Check Flows in Operational DS after Owner is Stopped.
199     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}    ${new_owner}
200
201 Check Groups In Operational DS After Owner Is Stopped
202     [Documentation]    Check Groups in Operational DS after Owner is Stopped.
203     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${all_groups}    ${new_owner}
204
205 Check Flows In Switch After Owner Is Stopped
206     [Documentation]    Check Flows in switch after Owner is Stopped
207     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${all_flows}
208
209 Start Old Owner Instance
210     [Documentation]    Start old Owner Instance and verify it is up
211     ClusterManagement.Start Single Member    ${original_owner}
212
213 Check Entity Owner Status And Find Owner and Successor After Start Owner
214     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
215     ${owner}    ${successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
216     ...    1
217
218 Check Linear Topology After Owner Restart
219     [Documentation]    Check Linear Topology.
220     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
221
222 Remove Configuration In Owner and Verify After Owner Restart
223     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
224     Remove Single Group And Flow On Member    ${new_owner}
225
226 Check Flows After Owner Restart In Operational DS
227     [Documentation]    Check Flows in Operational DS after owner is restarted.
228     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${less_flows}
229
230 Check Groups After Owner Restart In Operational DS
231     [Documentation]    Check Groups in Operational DS after owner is restarted.
232     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${less_groups}
233
234 Check Flows In Switch After Owner Is Restarted
235     [Documentation]    Check Flows in switch after Owner is restarted
236     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${less_flows}
237
238 Restart Cluster
239     [Documentation]    Stop and Start cluster.
240     # Try to stop contoller, if stop does not work or takes too long, kill controller.
241     ${status}    ${result}=    BuiltIn.Run Keyword And Ignore Error    ClusterManagement.Stop_Members_From_List_Or_All
242     BuiltIn.Run Keyword If    '${status}' != 'PASS'    ClusterManagement.Kill_Members_From_List_Or_All
243     ClusterManagement.Start_Members_From_List_Or_All    wait_for_sync=False
244
245 Check Linear Topology After Controller Restarts
246     [Documentation]    Check Linear Topology after controller restarts.
247     BuiltIn.Wait Until Keyword Succeeds    300s    2s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
248
249 Add Flow And Group After Restart
250     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
251     Add Single Group And Flow On Member
252
253 Check Flows In Operational DS After Controller Restarts
254     [Documentation]    Check Flows in Operational DS after controller is restarted.
255     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
256
257 Check Groups In Operational DS After Controller Restarts
258     [Documentation]    Check Groups in Operational DS after controller is restarted.
259     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${all_groups}
260
261 Check Flows In Switch After Controller Restarts
262     [Documentation]    Check Flows in switch after controller is restarted..
263     MininetKeywords.Check Flows In Mininet    ${mininet_conn_id}    ${all_flows}
264
265 Stop Mininet
266     [Documentation]    Stop Mininet.
267     MininetKeywords.Stop Mininet And Exit
268
269 Check No Switches
270     [Documentation]    Check no switches in topology.
271     BuiltIn.Wait Until Keyword Succeeds    5s    1s    ClusterOpenFlow.Check No Switches On Member    ${SWITCHES}
272
273 *** Keywords ***
274 Initialization Phase
275     [Documentation]    Create controller session and set variables.
276     ClusterManagement.ClusterManagement_Setup
277     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
278     ${switches}    Convert To Integer    ${SWITCHES}
279     ${iter}    Convert To Integer    ${ITER}
280     ${all_groups}=    BuiltIn.Evaluate    ${switches} * ${iter} * 2
281     ${less_groups}=    BuiltIn.Evaluate    ${all_groups} - ${switches} * 2
282     # Stale flows/groups feature enabled in Boron onwards.
283     ${less_groups}=    CompareStream.Set Variable If At Least Boron    ${less_groups}    ${all_groups}
284     ${all_flows}=    BuiltIn.Evaluate    ${switches} * ${iter+1}
285     ${less_flows}=    BuiltIn.Evaluate    ${all_flows} - ${switches}
286     # Stale flows/groups feature enabled in Boron onwards.
287     ${less_flows}=    CompareStream.Set Variable If At Least Boron    ${less_flows}    ${all_flows}
288     BuiltIn.Set Suite Variable    ${switches}
289     BuiltIn.Set Suite Variable    ${iter}
290     BuiltIn.Set Suite Variable    ${all_groups}
291     BuiltIn.Set Suite Variable    ${less_groups}
292     BuiltIn.Set Suite Variable    ${all_flows}
293     BuiltIn.Set Suite Variable    ${less_flows}
294     BuiltIn.Set Suite Variable    ${no_flows}    ${SWITCHES}
295
296 Final Phase
297     [Documentation]    Delete all sessions.
298     ${command} =    BuiltIn.Set Variable    sudo iptables -v -F
299     BuiltIn.Run Keyword And Ignore Error    ClusterManagement.Run_Bash_Command_On_List_Or_All    ${command}
300     BuiltIn.Run Keyword And Ignore Error    RequestsLibrary.Delete Request    session    ${CONFIG_NODES_API}
301     RequestsLibrary.Delete All Sessions
302
303 Add Groups And Flows On Member
304     [Arguments]    ${iter}=1    ${member_index}=1
305     [Documentation]    Add ${ITER} groups type 1 & 2 and flows in every switch.
306     ${session} =    Resolve_Http_Session_For_Member    member_index=${member_index}
307     : FOR    ${switch}    IN RANGE    1    ${switches+1}
308     \    TemplatedRequests.Post As Json Templated    folder=${VAR_DIR}/add-group-1    mapping={"SWITCH":"${switch}"}    session=${session}    iterations=${iter}
309     \    TemplatedRequests.Post As Json Templated    folder=${VAR_DIR}/add-group-2    mapping={"SWITCH":"${switch}"}    session=${session}    iterations=${iter}
310     \    TemplatedRequests.Post As Json Templated    folder=${VAR_DIR}/add-flow    mapping={"SWITCH":"${switch}"}    session=${session}    iterations=${iter}
311
312 Add Single Group And Flow On Member
313     [Arguments]    ${member_index}=1
314     [Documentation]    Add 1 group 1&2 and 1 flow in every switch.
315     Add Groups And Flows On Member    1    ${member_index}
316
317 Remove Single Group And Flow On Member
318     [Arguments]    ${member_index}=1
319     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
320     ${session} =    Resolve_Http_Session_For_Member    member_index=${member_index}
321     : FOR    ${switch}    IN RANGE    1    ${switches+1}
322     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/table/0/flow/1
323     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/group/1
324     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/group/1000