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