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