Added test suites for cluster HA data recovery leader follower failover
[integration/test.git] / csit / suites / openflowplugin / Clustering / 030__Cluster_HA_Data_Recovery_Leader_Follower_Failover.robot
1 *** Settings ***
2 Documentation     Test suite for Cluster HA - Data Recovery at Leader Follower failover and cluster restart
3 Suite Setup       Create Controller Sessions
4 Suite Teardown    Delete All Sessions
5 Library           RequestsLibrary
6 Resource          ../../../libraries/ClusterOpenFlow.robot
7 Resource          ../../../libraries/ClusterKeywords.robot
8 Resource          ../../../libraries/MininetKeywords.robot
9 Variables         ../../../variables/Variables.py
10
11 *** Variables ***
12 ${INVENTORY_SHARD}    shard-inventory-config
13 ${START_TIMEOUT}    300s
14 ${flow_count_per_switch}    1
15 ${switch_count_per_node}    1
16 ${operation_timeout}    15s
17
18 *** Test Cases ***
19 Create Original Cluster List
20     [Documentation]    Create original cluster list.
21     ${original_cluster_list}    ClusterKeywords.Create Controller Index List
22     Set Suite Variable    ${original_cluster_list}
23
24 Check Shards Status Before Leader Restart
25     [Documentation]    Check Status for all shards in OpenFlow application.
26     ClusterOpenFlow.Check OpenFlow Shards Status    ${original_cluster_list}
27
28 Get inventory Leader Before Leader Restart
29     [Documentation]    Find leader in the inventory config shard
30     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status    ${original_cluster_list}
31     ${follower_node_1}=    Get From List    ${inventory_followers}    0
32     ${follower_node_2}=    Get From List    ${inventory_followers}    1
33     Set Suite Variable    ${inventory_leader_old}    ${inventory_leader}
34     Set Suite Variable    ${follower_node_1}
35     Set Suite Variable    ${follower_node_2}
36     Set Suite Variable    ${inventory_leader}
37
38 Start Mininet Connect To Follower Node1
39     [Documentation]    Start mininet with connection to Follower Node1.
40     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${follower_node_1}_IP}
41     Set Suite Variable    ${mininet_conn_id}
42
43 Add Flows In Follower Node2 and Verify Before Leader Restart
44     [Documentation]    Add Flow via Follower Node2 and verify it gets applied from all instances.
45     ClusterOpenFlow.Add Sample Flow And Verify    ${original_cluster_list}    ${follower_node_2}
46
47 Stop Mininet Connected To Follower Node1 and Exit
48     [Documentation]    Stop mininet and exit connection.
49     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
50     Utils.Clean Mininet System
51
52 Restart Leader From Cluster Node
53     [Documentation]    Kill Leader Node and Start it Up, Verify it is sync with other controller node.
54     ClusterKeywords.Kill Multiple Controllers    ${inventory_leader}
55     ClusterKeywords.Start Multiple Controllers    ${START_TIMEOUT}    ${inventory_leader}
56
57 Get inventory Follower After Leader Restart
58     [Documentation]    Find new Followers and Leader in the inventory config shard After Leader Restart.
59     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status    ${original_cluster_list}
60     ${follower_node_1}=    Get From List    ${inventory_followers}    0
61     ${follower_node_2}=    Get From List    ${inventory_followers}    1
62     Set Suite Variable    ${follower_node_1}
63     Set Suite Variable    ${follower_node_2}
64     Set Suite Variable    ${inventory_leader}
65
66 Start Mininet Connect To Old Leader
67     [Documentation]    Start mininet with connection to cluster old leader.
68     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${inventory_leader_old}_IP}
69     Set Suite Variable    ${mininet_conn_id}
70
71 Verify Flows In Switch After Leader Restart
72     [Documentation]    Verify flows are installed in switch after leader restart.
73     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${switch_count_per_node}    ${flow_count_per_switch}    ${operation_timeout}
74
75 Stop Mininet Connected To Old Leader and Exit
76     [Documentation]    Stop mininet and exit connection.
77     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
78     Utils.Clean Mininet System
79
80 Restart Follower Node2
81     [Documentation]    Kill Follower Node2 and Start it Up, Verify it is sync with other controller node.
82     ClusterKeywords.Kill Multiple Controllers    ${follower_node_2}
83     ClusterKeywords.Start Multiple Controllers    ${START_TIMEOUT}    ${follower_node_2}
84
85 Get inventory Follower After Follower Restart
86     [Documentation]    Find Followers and Leader in the inventory config shard After Follower Restart.
87     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status    ${original_cluster_list}
88     ${follower_node_1}=    Get From List    ${inventory_followers}    0
89     ${follower_node_2}=    Get From List    ${inventory_followers}    1
90     Set Suite Variable    ${follower_node_1}
91     Set Suite Variable    ${follower_node_2}
92     Set Suite Variable    ${inventory_leader}
93
94 Start Mininet Connect To Leader
95     [Documentation]    Start mininet with connection to Leader.
96     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${inventory_leader}_IP}
97     Set Suite Variable    ${mininet_conn_id}
98
99 Verify Flows In Switch After Follower Restart
100     [Documentation]    Verify flows are installed in switch after follower restart.
101     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${switch_count_per_node}    ${flow_count_per_switch}    ${operation_timeout}
102
103 Stop Mininet Connected To Leader and Exit
104     [Documentation]    Stop mininet Connected To Other Follower and exit connection.
105     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
106     Utils.Clean Mininet System
107
108 Restart Full Cluster
109     [Documentation]    Kill all Cluster Nodes and Start it Up All.
110     ClusterKeywords.Kill Multiple Controllers    @{original_cluster_list}
111     ClusterKeywords.Start Multiple Controllers    ${START_TIMEOUT}    @{original_cluster_list}
112
113 Get inventory Status After Cluster Restart
114     [Documentation]    Find New Followers and Leader in the inventory config shard After Cluster Restart.
115     ${inventory_leader}    ${inventory_followers}    ClusterOpenFlow.Get InventoryConfig Shard Status    ${original_cluster_list}
116     ${follower_node_1}=    Get From List    ${inventory_followers}    0
117     ${follower_node_2}=    Get From List    ${inventory_followers}    1
118     Set Suite Variable    ${follower_node_1}
119     Set Suite Variable    ${follower_node_2}
120     Set Suite Variable    ${inventory_leader}
121
122 Start Mininet Connect To Follower Node2 After Cluster Restart
123     [Documentation]    Start mininet with connection to cluster Follower Node2.
124     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller    ${TOOLS_SYSTEM_IP}    ${ODL_SYSTEM_${follower_node_2}_IP}
125     Set Suite Variable    ${mininet_conn_id}
126
127 Verify Flows In Switch After Cluster Restart
128     [Documentation]    Verify flows are installed in switch after cluster restart.
129     MininetKeywords.Verify Aggregate Flow From Mininet Session    ${mininet_conn_id}    ${switch_count_per_node}    ${flow_count_per_switch}    ${operation_timeout}
130
131 Delete Flows In Follower Node1 and Verify After Leader Restart
132     [Documentation]    Delete Flow in Follower Node1.
133     ClusterOpenFlow.Delete Sample Flow and Verify    ${original_cluster_list}    ${follower_node_1}
134
135 Stop Mininet Connected To Follower Node2 and Exit After Cluster Restart
136     [Documentation]    Stop mininet Connected To Other Follower and exit connection.
137     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
138     Utils.Clean Mininet System