Verify Bulkomatic Flows with 2Node Cluster
[integration/test.git] / csit / suites / openflowplugin / Clustering_Bulkomatic / 020__Cluster_HA_Data_Recovery_BulkFlow_2Node_Cluster.robot
1 *** Settings ***
2 Documentation     Test suite for 2Node Cluster HA with Bulk Flows - Cluster node convergance and Data consistency after leader and follower restart with one switch connected
3 Suite Setup       ClusterManagement Setup
4 Suite Teardown    Delete All Sessions
5 Resource          ../../../libraries/BulkomaticKeywords.robot
6 Resource          ../../../libraries/MininetKeywords.robot
7 Resource          ../../../libraries/ClusterManagement.robot
8 Resource          ../../../libraries/ClusterOpenFlow.robot
9 Resource          ../../../libraries/Utils.robot
10 Variables         ../../../variables/Variables.py
11
12 *** Variables ***
13 ${operation_timeout}    100s
14 ${restart_timeout}    350s
15 ${flow_count_per_switch}    10000
16 ${switch_count}    1
17 ${flow_count_after_add}    10000
18 ${flow_count_after_del}    0
19 ${orig_json_config_add}    sal_add_bulk_flow_config.json
20 ${orig_json_config_get}    sal_get_bulk_flow_config.json
21 ${orig_json_config_del}    sal_del_bulk_flow_config.json
22
23 *** Test Cases ***
24 Check Shards Status and Initialize Variables
25     [Documentation]    Check Status for all shards in OpenFlow application.
26     ClusterOpenFlow.Check OpenFlow Shards Status
27     ${temp_json_config_add}    BulkomaticKeywords.Set DPN And Flow Count In Json Add    ${orig_json_config_add}    ${switch_count}    ${flow_count_per_switch}
28     ${temp_json_config_get}    BulkomaticKeywords.Set DPN And Flow Count In Json Get    ${orig_json_config_get}    ${switch_count}    ${flow_count_after_add}
29     ${temp_json_config_del}    BulkomaticKeywords.Set DPN And Flow Count In Json Del    ${orig_json_config_del}    ${switch_count}    ${flow_count_per_switch}
30     Set Suite Variable    ${temp_json_config_add}
31     Set Suite Variable    ${temp_json_config_get}
32     Set Suite Variable    ${temp_json_config_del}
33
34 Get Inventory Follower Before Leader Restart
35     [Documentation]    Find a follower in the inventory config shard
36     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status
37     ${Inventory_Pre_Leader_List}=    Create List    ${Inventory_Leader}
38     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
39     Set Suite Variable    ${Inventory_Followers}
40     Set Suite Variable    ${Follower_Node_1}
41     Set Suite Variable    ${Inventory_Leader}
42     Set Suite Variable    ${Inventory_Pre_Leader_List}
43     ${Inventory_Pre_Leader}    Set Variable    ${Inventory_Leader}
44     Set Suite Variable    ${Inventory_Pre_Leader}
45
46 Shutdown Leader From Cluster Node
47     [Documentation]    Shutdown Leader Node and Start it Up
48     ClusterManagement.Kill Single Member    ${Inventory_Leader}
49
50 Check Shards Status After Leader Shutdown
51     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
52     Wait Until Keyword Succeeds    ${operation_timeout}    2s    ClusterOpenFlow.Check OpenFlow Shards Status    ${Inventory_Followers}
53
54 Check Shard Status For Leader After PreLeader Shutdown
55     [Documentation]    Find a Leader in the inventory config shard
56     ${Inventory_Leader_Post}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status    ${Inventory_Followers}
57     ${Inventory_Leader_List_Post}=    Create List    ${Inventory_Leader_Post}
58     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
59     Set Suite Variable    ${Inventory_Followers}
60     Set Suite Variable    ${Follower_Node_1}
61     Set Suite Variable    ${Inventory_Leader_Post}
62     Set Suite Variable    ${Inventory_Leader_List_Post}
63
64 Start Mininet Connect To Follower Node1
65     [Documentation]    Start mininet with connection to Follower Node1
66     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${Follower_Node_1}_IP}    --topo linear,${switch_count} --switch ovsk,protocols=OpenFlow13
67     Set Suite Variable    ${mininet_conn_id}
68
69 Add Bulk Flow From Follower
70     [Documentation]    ${flow_count_per_switch} Flows added via Follower Node1 and verify it gets applied in all instances.
71     BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add}    ${Follower_Node_1}    ${operation_timeout}
72
73 Get Bulk Flows And Verify In Leader
74     [Documentation]    Initiate get operation and check flow count across cluster nodes.
75     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}    ${Inventory_Leader_List_Post}
76
77 Verify Flows In Switch Before Cluster Restart
78     [Documentation]    Verify flows are installed in switch before cluster restart.
79     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${flow_count_after_add}    ${operation_timeout}
80
81 Restart Pre Leader From Cluster Node
82     [Documentation]    Restart Leader Node.
83     ClusterManagement.Start Single Member    ${Inventory_Leader}
84
85 Verify Data Recovery After Leader Restart
86     [Documentation]    ${flow_count_after_add} Flows preserved in all controller instances.
87     Wait Until Keyword Succeeds    ${restart_timeout}    2s    BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}
88     ...    ${Inventory_Leader_List_Post}
89
90 Verify Flows In Switch After Leader Restart
91     [Documentation]    Verify flows are installed in switch after cluster restart.
92     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${flow_count_after_add}    ${operation_timeout}
93
94 Stop Mininet Connected To Follower Node1
95     [Documentation]    Stop mininet and exit connection.
96     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
97     Utils.Clean Mininet System
98
99 Delete All Flows From Follower Node1
100     [Documentation]    ${flow_count_after_add} Flows deleted via Follower Node1 and verify it gets applied in all instances.
101     BulkomaticKeywords.Delete Bulk Flow In Node    ${temp_json_config_del}    ${Follower_Node_1}    ${operation_timeout}
102
103 Verify No Flows In Leader Node
104     [Documentation]    Verify flow count is ${flow_count_after_del} across cluster nodes.
105     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_del}    ${Inventory_Leader_List_Post}
106
107 Get Inventory Follower And Leader Before Cluster Restart
108     [Documentation]    Find a follower in the inventory config shard
109     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status
110     ${Active_Nodes}=    Create List
111     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
112     ${Follower_Node_2}=    Get From List    ${Inventory_Followers}    1
113     Append To List    ${Active_Nodes}    ${inventory_leader}    ${Follower_Node_1}
114     Set Suite Variable    ${Active_Nodes}
115     ${Inventory_Leader_List}=    Create List    ${inventory_leader}
116     ${Inventory_Follower_Node1_List}=    Create List    ${Follower_Node_1}
117     Set Suite Variable    ${Follower_Node_1}
118     Set Suite Variable    ${Follower_Node_2}
119     Set Suite Variable    ${Inventory_Leader}
120     Set Suite Variable    ${Inventory_Leader_List}
121     Set Suite Variable    ${Inventory_Follower_Node1_List}
122
123 Shutdown Follower From Cluster Node
124     [Documentation]    Shutdown Follower Node2 and Start it Up.
125     ClusterManagement.Kill Single Member    ${Follower_Node_2}
126
127 Check Shards Status After Follower Shutdown
128     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
129     Wait Until Keyword Succeeds    ${operation_timeout}    2s    ClusterOpenFlow.Check OpenFlow Shards Status    ${Active_Nodes}
130
131 Start Mininet Connect To Follower Node
132     [Documentation]    Start mininet with connection to Follower Node1.
133     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${Follower_Node_1}_IP}    --topo linear,${switch_count} --switch ovsk,protocols=OpenFlow13
134     Set Suite Variable    ${mininet_conn_id}
135
136 Add Bulk Flow From Follower Node1
137     [Documentation]    ${flow_count_after_add} Flows added via Follower Node1 and verify it gets applied in all instances.
138     BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add}    ${Follower_Node_1}    ${operation_timeout}
139
140 Get Bulk Flows And Verify In Leader Before Follower Restart
141     [Documentation]    Initiate get operation and check flow count ${flow_count_after_add} only across active cluster nodes
142     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}    ${Inventory_Leader_List}
143
144 Verify Flows In Switch Before Follower Restart
145     [Documentation]    Verify flows are installed in switch before follower restart.
146     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${flow_count_after_add}    ${operation_timeout}
147
148 Restart Follower From Cluster Node
149     [Documentation]    Restart Follower Node2.
150     ClusterManagement.Start Single Member    ${Follower_Node_2}
151
152 Verify Data Recovery After Follower Restart
153     [Documentation]    ${flow_count_after_add} Flows preserved in all controller instances.
154     Wait Until Keyword Succeeds    ${restart_timeout}    2s    BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}
155     ...    ${Inventory_Leader_List}
156
157 Verify Flows In Switch After Follower Restart
158     [Documentation]    Verify flows are installed in switch after cluster restart.
159     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${flow_count_after_add}    ${operation_timeout}
160
161 Stop Mininet Connected To Follower Node
162     [Documentation]    Stop mininet and exit connection.
163     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
164     Utils.Clean Mininet System
165
166 Delete All Flows From Follower Node
167     [Documentation]    ${flow_count_after_add} Flows deleted via Follower Node1 and verify it gets applied in all instances.
168     BulkomaticKeywords.Delete Bulk Flow In Node    ${temp_json_config_del}    ${Follower_Node_1}    ${operation_timeout}
169
170 Verify No Flows In Leader Node After Follower Restart
171     [Documentation]    Verify flow count is ${flow_count_after_del} across cluster nodes.
172     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_del}    ${Inventory_Leader_List}