Initial works for OF cluster test
[integration/test.git] / csit / suites / openflowplugin / Clustering / 010__Cluster_HA_Owner_Failover.robot
1 *** Settings ***
2 Suite Setup       Create Controller Sessions
3 Suite Teardown    Delete All Sessions
4 Library           RequestsLibrary
5 Resource          ../../../libraries/ClusterKeywords.robot
6 Resource          ../../../libraries/MininetKeywords.robot
7 Variables         ../../../variables/Variables.py
8
9 *** Variables ***
10 ${config_table_0}    ${CONFIG_NODES_API}/node/openflow:1/table/0
11 ${operational_table_0}    ${OPERATIONAL_NODES_API}/node/openflow:1/table/0
12 ${operational_port_1}    ${OPERATIONAL_NODES_API}/node/openflow:1/node-connector/openflow:1:1
13
14 *** Test Cases ***
15 Check OpenFlow Shards Status
16     [Documentation]    Create original cluster list and Check Status for all shards in OpenFlow application.
17     ${original_cluster_list}    Create Controller Index List
18     Set Suite Variable    ${original_cluster_list}
19     ${inv_conf_leader}    ${inv_conf_followers_list}    Get Cluster Shard Status    ${original_cluster_list}    config    inventory
20     ${inv_oper_leader}    ${inv_oper_followers_list}    Get Cluster Shard Status    ${original_cluster_list}    operational    inventory
21     ${topo_oper_leader}    ${topo_oper_followers_list}    Get Cluster Shard Status    ${original_cluster_list}    operational    topology
22     Log    config inventory Leader is ${inv_conf_leader} and followers are ${inv_conf_followers_list}
23     Log    operational inventory Leader is ${inv_oper_leader} and followers are ${inv_oper_followers_list}
24     Log    operational topology Leader is ${topo_oper_leader} and followers are ${topo_oper_followers_list}
25
26 Start Mininet Multiple Connections
27     [Documentation]    Start mininet with connection to all cluster instances.
28     ${mininet_conn_id}=    Start Mininet Multiple Controllers    ${TOOLS_SYSTEM_IP}    ${original_cluster_list}
29     Set Suite Variable    ${mininet_conn_id}
30
31 Check Entity Owner Status And Find Owner and Candidate
32     [Documentation]    Check Entity Owner Status and identify owner and candidate.
33     ${original_owner}    ${original_candidates_list}    Wait Until Keyword Succeeds    5s    1s    Get Cluster Entity Owner Status    ${original_cluster_list}
34     ...    openflow    openflow:1
35     ${original_candidate}=    Get From List    ${original_candidates_list}    0
36     Set Suite Variable    ${original_owner}
37     Set Suite Variable    ${original_candidate}
38
39 Check Network Operational Information
40     [Documentation]    Check device is in operational inventory and topology in all cluster instances.
41     ...    Inventory should show 1x node_id per device 1x node_id per connector. Topology should show 2x node_id per device + 3x node_id per connector.
42     ${dictionary}    Create Dictionary    openflow:1=4
43     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${OPERATIONAL_NODES_API}
44     ${dictionary}    Create Dictionary    openflow:1=11
45     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}
46
47 Add Flow In Owner and Verify
48     [Documentation]    Add Flow in Owner and verify it gets applied from all instances.
49     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/sample_flow_1.json
50     ${dictionary}=    Create Dictionary    10.0.1.0/24=1
51     Put And Check At URI In Cluster    ${original_cluster_list}    ${original_owner}    ${config_table_0}/flow/1    ${body}    ${HEADERS}
52     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
53
54 Modify Flow In Owner and Verify
55     [Documentation]    Modify Flow in Owner and verify it gets applied from all instances.
56     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/sample_flow_2.json
57     ${dictionary}=    Create Dictionary    10.0.2.0/24=1
58     Put And Check At URI In Cluster    ${original_cluster_list}    ${original_owner}    ${config_table_0}/flow/1    ${body}    ${HEADERS}
59     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
60
61 Delete Flow In Owner and Verify
62     [Documentation]    Delete Flow in Owner and verify it gets applied from all instances.
63     ${dictionary}=    Create Dictionary    10.0.2.0/24=0
64     Delete And Check At URI In Cluster    ${original_cluster_list}    ${original_owner}    ${config_table_0}/flow/1
65     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
66
67 Add Flow In Candidate and Verify
68     [Documentation]    Add Flow in Owner and verify it gets applied from all instances.
69     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/sample_flow_1.json
70     ${dictionary}=    Create Dictionary    10.0.1.0/24=1
71     Put And Check At URI In Cluster    ${original_cluster_list}    ${original_candidate}    ${config_table_0}/flow/1    ${body}    ${HEADERS}
72     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
73
74 Modify Flow In Candidate and Verify
75     [Documentation]    Modify Flow in Owner and verify it gets applied from all instances.
76     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/sample_flow_2.json
77     ${dictionary}=    Create Dictionary    10.0.2.0/24=1
78     Put And Check At URI In Cluster    ${original_cluster_list}    ${original_candidate}    ${config_table_0}/flow/1    ${body}    ${HEADERS}
79     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
80
81 Delete Flow In Candidate and Verify
82     [Documentation]    Delete Flow in Owner and verify it gets removed from all instances.
83     ${dictionary}=    Create Dictionary    10.0.2.0/24=0
84     Delete And Check At URI In Cluster    ${original_cluster_list}    ${original_candidate}    ${config_table_0}/flow/1
85     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
86
87 Send RPC Add Flow to Owner and Verify
88     [Documentation]    Add Flow in Owner and verify it gets applied from all instances.
89     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/add_flow_rpc.json
90     ${dictionary}=    Create Dictionary    10.0.1.0/24=1
91     ${resp}    RequestsLibrary.Post Request    controller${original_owner}    /restconf/operations/sal-flow:add-flow    ${body}    ${HEADERS}
92     Log    ${resp.content}
93     Should Be Equal As Strings    ${resp.status_code}    200
94     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
95
96 Send RPC Delete Flow to Owner and Verify
97     [Documentation]    Delete Flow in Owner and verify it gets removed from all instances.
98     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/delete_flow_rpc.json
99     ${dictionary}=    Create Dictionary    10.0.1.0/24=0
100     ${resp}    RequestsLibrary.Post Request    controller${original_owner}    /restconf/operations/sal-flow:remove-flow    ${body}    ${HEADERS}
101     Log    ${resp.content}
102     Should Be Equal As Strings    ${resp.status_code}    200
103     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
104
105 Send RPC Add Flow to Candidate and Verify
106     [Documentation]    Add Flow in Candidate and verify it gets applied from all instances.
107     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/add_flow_rpc.json
108     ${dictionary}=    Create Dictionary    10.0.1.0/24=1
109     ${resp}    RequestsLibrary.Post Request    controller${original_candidate}    /restconf/operations/sal-flow:add-flow    ${body}    ${HEADERS}
110     Log    ${resp.content}
111     Should Be Equal As Strings    ${resp.status_code}    200
112     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
113
114 Send RPC Delete Flow to Candidate and Verify
115     [Documentation]    Delete Flow in Candidate and verify it gets removed from all instances.
116     ${body}=    OperatingSystem.Get File    ${CURDIR}/../../../variables/openflowplugin/delete_flow_rpc.json
117     ${dictionary}=    Create Dictionary    10.0.1.0/24=0
118     ${resp}    RequestsLibrary.Post Request    controller${original_candidate}    /restconf/operations/sal-flow:remove-flow    ${body}    ${HEADERS}
119     Log    ${resp.content}
120     Should Be Equal As Strings    ${resp.status_code}    200
121     Wait Until Keyword Succeeds    10s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_table_0}
122
123 Take a Link Down and Verify
124     [Documentation]    Take a link down and verify port status in all instances.
125     ${dictionary}=    Create Dictionary    "link-down":true=1
126     ${ouput}=    Send Mininet Command    ${mininet_conn_id}    link s1 h1 down
127     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_port_1}
128
129 Take a Link Up and Verify
130     [Documentation]    Take the link up and verify port status in all instances.
131     ${dictionary}=    Create Dictionary    "link-down":true=0
132     ${ouput}=    Send Mininet Command    ${mininet_conn_id}    link s1 h1 up
133     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${operational_port_1}
134
135 Stop Mininet and Exit
136     [Documentation]    Stop mininet and exit connection.
137     Stop Mininet And Exit    ${mininet_conn_id}
138     Clean Mininet System
139
140 Check No Network Operational Information
141     [Documentation]    Check device is not in operational inventory or topology in all cluster instances.
142     ${dictionary}    Create Dictionary    openflow:1=0
143     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${OPERATIONAL_NODES_API}
144     ${dictionary}    Create Dictionary    openflow:1=0
145     Wait Until Keyword Succeeds    5s    1s    Check Item Occurrence At URI In Cluster    ${original_cluster_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}