Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / openflowplugin / Clustering_Bulkomatic / 040__Cluster_Current_Term_Verification_3Node_Cluster.robot
1 *** Settings ***
2 Documentation     Test suite for OF-18 Spurious Leader Election verification of term change while flows are added/deleted    #
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}    400s
16 ${restart_timeout}    450s
17 ${flow_count_per_switch}    10000
18 ${flow_count_per_switch_ten_percent}    1000
19 ${switch_count}    1
20 ${flow_count_after_add}    10000
21 ${flow_count_after_del}    0
22 ${flow_count_after_del_ten_percent}    9000
23 ${orig_json_config_add}    sal_add_bulk_flow_config.json
24 ${orig_json_config_get}    sal_get_bulk_flow_config.json
25 ${orig_json_config_del}    sal_del_bulk_flow_config.json
26 ${orig_json_config_table_add}    add_table.json
27 ${shard_name}     inventory
28 ${shard_type}     config
29 ${verify_restconf}    False
30
31 *** Test Cases ***
32 Check Shard And Get Inventory
33     [Documentation]    Check Status for all shards and Finding a leader and followers in the inventory config shard
34     Check Shards Status And Initialize Variables
35     Get Inventory Follower
36
37 Initial Current Term Verification
38     [Documentation]    Verifying current term for Leader Node Before
39     ${current_term_value_before}    Get_Current_Term_Of_Shard_At_Member
40     BuiltIn.Log to console    Current Term is ${current_term_value_before}
41     BuiltIn.Set Suite Variable    ${current_term_value_before}
42
43 Add Bulk Flow From Follower
44     [Documentation]    ${flow_count_after_add} Flows added via Follower Node1 and verify it gets applied in all instances.
45     BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add}    ${Follower_Node_1}    ${operation_timeout}
46
47 Get Bulk Flows And Verify In Cluster
48     [Documentation]    Initiate get operation and check flow count across cluster nodes
49     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}    ${Inventory_Leader_List}
50
51 Current Term Verification After Adding Bulk Flow
52     [Documentation]    Verifying current term for Leader Node after pushing the flows
53     ${current_term_value_after}    Get_Current_Term_Of_Shard_At_Member
54     BuiltIn.Set Suite Variable    ${current_term_value_after}
55
56 Current Term Comparison Before And After Addition Of Flow
57     [Documentation]    Comparison of Current Term Before and After Addition of Flows
58     BuiltIn.Log to console    Current Term after pushing the flows is ${current_term_value_after}
59     Run Keyword If    ${current_term_value_before} == ${current_term_value_after}    Log    SUCCESS
60     ...    ELSE    Log    FAILURE
61     Should Be Equal    ${current_term_value_before}    ${current_term_value_after}
62
63 Delete and Add ten percent of the flows for 5 iterations
64     [Documentation]    Performeing 5 iterations for Delete and Add ten Percentage of the flows
65     FOR    ${index}    IN RANGE    1    6
66         Log    ${index}
67         BulkomaticKeywords.Delete Bulk Flow In Node    ${temp_json_config_del_ten_percent}    ${Follower_Node_1}    ${operation_timeout}
68         BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_del_ten_percent}    ${Inventory_Leader_List}
69         BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add_ten_percent}    ${Follower_Node_1}    ${operation_timeout}
70         BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_add}    ${Inventory_Leader_List}
71     END
72
73 Current Term Verification After Continuous Deletion and Addition Of Flows for 5 iterations
74     [Documentation]    Verifying current term for Leader Node after continuous deletion and addition of ten percent of the flows
75     ${current_term_value_after}    Get_Current_Term_Of_Shard_At_Member
76     BuiltIn.Set Suite Variable    ${current_term_value_after}
77
78 Current Term Comparison Before and After Continuous Deletion and Addition Of Flows for 5 iterations
79     [Documentation]    Comparison Current Term Before and After Continuous Deletion and Addition Of Flows for 5 iterations
80     BuiltIn.Log to console    Current Term after pushing the flows is ${current_term_value_after}
81     Run Keyword If    ${current_term_value_before} == ${current_term_value_after}    Log    SUCCESS
82     ...    ELSE    Log    FAILURE
83     Should Be Equal    ${current_term_value_before}    ${current_term_value_after}
84
85 Delete All Flows From Follower Node
86     [Documentation]    ${flow_count_after_add} Flows deleted via Leader Node and verify it gets applied in all instances.
87     BulkomaticKeywords.Delete Bulk Flow In Node    ${temp_json_config_del}    ${Follower_Node_1}    ${operation_timeout}
88
89 Verify No Flows In Cluster After Flow Deletion
90     [Documentation]    Verifying No FLows in Cluster after Flows Deletion
91     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster    ${temp_json_config_get}    ${operation_timeout}    ${flow_count_after_del}    ${Inventory_Leader_List}
92
93 PreLeader Verification
94     [Documentation]    Verifying LastIndex and LastApplied and compare both are equal
95     ${LastIndex}    Get_Last_Index_Of_Shard_At_Member
96     ${LastApplied}    Get_Last_Applied_Of_Shard_At_Member
97     Should Be Equal    ${LastIndex}    ${LastApplied}
98     BulkomaticKeywords.Add Table In Node    ${temp_json_config_table}    ${Follower_Node_1}    ${operation_timeout}
99     ${LastIndex}    Get_Last_Index_Of_Shard_At_Member
100     ${LastApplied}    Get_Last_Applied_Of_Shard_At_Member
101     Should Be Equal    ${LastIndex}    ${LastApplied}
102
103 *** Keywords ***
104 Check Shards Status And Initialize Variables
105     [Documentation]    Check Status for all shards in OpenFlow application.
106     ClusterOpenFlow.Check OpenFlow Shards Status
107     ${temp_json_config_add}    BulkomaticKeywords.Set DPN And Flow Count In Json Add    ${orig_json_config_add}    ${switch_count}    ${flow_count_per_switch}
108     ${temp_json_config_get}    BulkomaticKeywords.Set DPN And Flow Count In Json Get    ${orig_json_config_get}    ${switch_count}    ${flow_count_after_add}
109     ${temp_json_config_del}    BulkomaticKeywords.Set DPN And Flow Count In Json Del    ${orig_json_config_del}    ${switch_count}    ${flow_count_per_switch}
110     ${temp_json_config_del_ten_percent}    BulkomaticKeywords.Set DPN And Flow Count In Json Del    ${orig_json_config_del}    ${switch_count}    ${flow_count_per_switch_ten_percent}
111     ${temp_json_config_add_ten_percent}    BulkomaticKeywords.Set DPN And Flow Count In Json Add    ${orig_json_config_add}    ${switch_count}    ${flow_count_per_switch_ten_percent}
112     ${temp_json_config_table}    BulkomaticKeywords.Set DPN And Flow Count In Json Add    ${orig_json_config_table_add}    ${switch_count}    ${flow_count_per_switch}
113     Set Suite Variable    ${temp_json_config_add}
114     Set Suite Variable    ${temp_json_config_get}
115     Set Suite Variable    ${temp_json_config_del}
116     Set Suite Variable    ${temp_json_config_del_ten_percent}
117     Set Suite Variable    ${temp_json_config_add_ten_percent}
118     Set Suite Variable    ${temp_json_config_table}
119
120 Get Inventory Follower
121     [Documentation]    Find a leader and followers in the inventory config shard
122     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status
123     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
124     ${Follower_Node_2}=    Get From List    ${Inventory_Followers}    1
125     ${Inventory_Leader_List}=    Create List    ${inventory_leader}
126     ${Inventory_Follower_Node1_List}=    Create List    ${Follower_Node_1}
127     BuiltIn.Log to console    ${\n}
128     BuiltIn.Log to console    The follower Node1 is ${Follower_Node_1}
129     BuiltIn.Log to console    The follower Node2 is ${Follower_Node_2}
130     BuiltIn.Log to console    The leader Node is ${Inventory_Leader}
131     BuiltIn.Set Suite Variable    ${Follower_Node_1}
132     BuiltIn.Set Suite Variable    ${Follower_Node_2}
133     BuiltIn.Set Suite Variable    ${Inventory_Leader}
134     BuiltIn.Set Suite Variable    ${Inventory_Leader_List}
135     BuiltIn.Set Suite Variable    ${Inventory_Follower_Node1_List}
136
137 Get_Current_Term_Of_Shard_At_Member
138     [Documentation]    Find a Raft Property Values From Shard Member
139     ${current_term_value} =    ClusterManagement.Get_Raft_Property_From_Shard_Member    CurrentTerm    ${shard_name}    ${shard_type}    ${Inventory_Leader}    ${verify_restconf}
140     [Return]    ${current_term_value}
141
142 Get_Last_Index_Of_Shard_At_Member
143     [Documentation]    Find a leader and followers in the inventory config shard
144     ${LastIndex} =    ClusterManagement.Get_Raft_Property_From_Shard_Member    LastIndex    ${shard_name}    ${shard_type}    ${Inventory_Leader}    ${verify_restconf}
145     [Return]    ${LastIndex}
146
147 Get_Last_Applied_Of_Shard_At_Member
148     [Documentation]    Find a leader and followers in the inventory config shard
149     ${LastApplied} =    ClusterManagement.Get_Raft_Property_From_Shard_Member    LastApplied    ${shard_name}    ${shard_type}    ${Inventory_Leader}    ${verify_restconf}
150     [Return]    ${LastApplied}