2 Documentation Cluster OpenFlow library. So far this library is only to be used by OpenFlow cluster test as it is very specific for this test.
3 Library RequestsLibrary
4 Library ${CURDIR}/ScaleClient.py
5 Resource ClusterManagement.robot
6 Resource MininetKeywords.robot
8 Variables ../variables/Variables.py
11 @{SHARD_OPER_LIST} inventory topology default entity-ownership
12 @{SHARD_CONF_LIST} inventory topology default
13 ${config_table_0} ${CONFIG_NODES_API}/node/openflow:1/table/0
14 ${operational_table_0} ${OPERATIONAL_NODES_API}/node/openflow:1/table/0
15 ${operational_port_1} ${OPERATIONAL_NODES_API}/node/openflow:1/node-connector/openflow:1:1
18 Get InventoryConfig Shard Status
19 [Arguments] ${controller_index_list}=${EMPTY}
20 [Documentation] Check Status for Inventory Config shard in OpenFlow application.
21 ${inv_conf_leader} ${inv_conf_followers_list} Wait Until Keyword Succeeds 10s 1s ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=inventory
22 ... shard_type=config member_index_list=${controller_index_list}
23 Log config inventory Leader is ${inv_conf_leader} and followers are ${inv_conf_followers_list}
24 [Return] ${inv_conf_leader} ${inv_conf_followers_list}
26 Check OpenFlow Shards Status
27 [Arguments] ${controller_index_list}=${EMPTY}
28 [Documentation] Check Status for all shards in OpenFlow application.
29 ClusterManagement.Verify_Leader_Exists_For_Each_Shard shard_name_list=${SHARD_OPER_LIST} shard_type=operational member_index_list=${controller_index_list}
30 ClusterManagement.Verify_Leader_Exists_For_Each_Shard shard_name_list=${SHARD_CONF_LIST} shard_type=config member_index_list=${controller_index_list}
32 Check OpenFlow Shards Status After Cluster Event
33 [Arguments] ${controller_index_list}=${EMPTY}
34 [Documentation] Check Shards Status after some cluster event.
35 Wait Until Keyword Succeeds 90s 1s ClusterOpenFlow.Check OpenFlow Shards Status ${controller_index_list}
37 Get OpenFlow Entity Owner Status For One Device
38 [Arguments] ${device} ${controller_index} ${controller_index_list}=${EMPTY} ${after_stop}=False
39 [Documentation] Check Entity Owner Status and identify owner and successors for the device ${device}. Request is sent to controller ${controller_index}.
40 ${owner} ${successor_list} Wait Until Keyword Succeeds 10s 1s ClusterManagement.Verify_Owner_And_Successors_For_Device device_name=${device}
41 ... device_type=openflow member_index=${controller_index} candidate_list=${controller_index_list} after_stop=${after_stop}
42 [Return] ${owner} ${successor_list}
44 Check OpenFlow Device Owner
45 [Arguments] ${device} ${controller_index} ${expected_owner} ${expected_candidate_list}=${EMPTY}
46 [Documentation] Check owner and candidates for the device ${device}. Request is sent to controller ${controller_index}.
47 ${owner} ${successor_list} ClusterManagement.Verify_Owner_And_Successors_For_Device device_name=${device} device_type=openflow member_index=${controller_index} candidate_list=${expected_candidate_list}
48 Should Be Equal ${owner} ${expected_owner}
50 Check OpenFlow Network Operational Information For Sample Topology
51 [Arguments] ${controller_index_list}=${EMPTY}
52 [Documentation] Check devices in tree,2 are in operational inventory and topology in all instances in ${controller_index_list}.
53 ... 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
54 ... + 5x node_id per link termination. TODO: A Keyword that can calculate this based on mininet topology.
55 ${dictionary} Create Dictionary openflow:1=4 openflow:2=5 openflow:3=5
56 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_NODES_API} dictionary=${dictionary} member_index_list=${controller_index_list}
57 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
58 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_TOPO_API} dictionary=${dictionary} member_index_list=${controller_index_list}
60 Check No OpenFlow Network Operational Information
61 [Arguments] ${controller_index_list}=${EMPTY}
62 [Documentation] Check device is not in operational inventory or topology in all cluster instances in ${controller_index_list}.
63 ${dictionary} Create Dictionary openflow=0
64 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_NODES_API} dictionary=${dictionary} member_index_list=${controller_index_list}
65 ${dictionary} Create Dictionary openflow=0
66 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_TOPO_API} dictionary=${dictionary} member_index_list=${controller_index_list}
68 Add Sample Flow And Verify
69 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
70 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
71 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
72 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
73 # replicating some of the matches in the flows section. Same comment applies for further keywords.
74 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
75 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
76 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
77 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
80 [Arguments] ${controller_index_list}=${EMPTY}
81 [Documentation] Verify sample flow gets applied in all instances in ${controller_index_list}.
82 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
83 # replicating some of the matches in the flows section. Same comment applies for further keywords.
84 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
85 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
86 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
88 Modify Sample Flow And Verify
89 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
90 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
91 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
92 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
93 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
94 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
95 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
97 Delete Sample Flow And Verify
98 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
99 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
100 ${dictionary}= Create Dictionary 10.0.1.0/24=0
101 ClusterManagement.Delete_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${controller_index} ${controller_index_list}
102 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
104 Send RPC Add Sample Flow And Verify
105 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
106 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
107 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
108 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2
109 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1
110 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:add-flow data=${body} member_index=${controller_index}
111 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
113 Send RPC Delete Sample Flow And Verify
114 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
115 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
116 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
117 ${dictionary}= Create Dictionary 10.0.1.0/24=0
118 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:remove-flow data=${body} member_index=${controller_index}
119 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
121 Take OpenFlow Device Link Down and Verify
122 [Arguments] ${controller_index_list}=${EMPTY}
123 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
124 ${dictionary}= Create Dictionary "link-down":true=1
125 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 down
126 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_port_1} dictionary=${dictionary} member_index_list=${controller_index_list}
127 ${dictionary} Create Dictionary openflow:1=16 openflow:2=14 openflow:3=19
128 Wait Until Keyword Succeeds 20s 2s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_TOPO_API} dictionary=${dictionary} member_index_list=${controller_index_list}
130 Take OpenFlow Device Link Up and Verify
131 [Arguments] ${controller_index_list}=${EMPTY}
132 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
133 ${dictionary}= Create Dictionary "link-down":true=0
134 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 up
135 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_port_1} dictionary=${dictionary} member_index_list=${controller_index_list}
136 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
137 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_TOPO_API} dictionary=${dictionary} member_index_list=${controller_index_list}
139 Verify Switch Connections Running On Member
140 [Arguments] ${switch_count} ${member_index}
141 [Documentation] Check if number of Switch connections on member of given index is equal to ${switch_count}.
142 ${count} = ScaleClient.Get_Switches_Count controller=${ODL_SYSTEM_${member_index}_IP}
143 BuiltIn.Should_Be_Equal_As_Numbers ${switch_count} ${count}
145 Check Flows Operational Datastore On Member
146 [Arguments] ${flow_count} ${member_index}
147 [Documentation] Check if number of Operational Flows on member of given index is equal to ${flow_count}.
148 ${sw} ${reported_flow} ${found_flow}= ScaleClient.Flow Stats Collected controller=${ODL_SYSTEM_${member_index}_IP}
149 BuiltIn.Should_Be_Equal_As_Numbers ${flow_count} ${found_flow}
151 Check Linear Topology On Member
152 [Arguments] ${switches} ${member_index}=1
153 [Documentation] Check Linear topology.
154 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
155 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
157 Should Be Equal As Strings ${resp.status_code} 200
158 : FOR ${switch} IN RANGE 1 ${switches+1}
159 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
160 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
161 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
162 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
163 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
164 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
165 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
166 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
167 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3
169 Check No Switches On Member
170 [Arguments] ${switches} ${member_index}=1
171 [Documentation] Check no switch is in topology
172 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
173 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
175 Should Be Equal As Strings ${resp.status_code} 200
176 : FOR ${switch} IN RANGE 1 ${switches+1}
177 \ Should Not Contain ${resp.content} openflow:${switch}
179 Check Number Of Flows On Member
180 [Arguments] ${flows} ${member_index}=1
181 [Documentation] Check number of flows in the inventory.
182 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
183 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
185 Should Be Equal As Strings ${resp.status_code} 200
186 ${count}= Get Count ${resp.content} "priority"
187 Should Be Equal As Integers ${count} ${flows}
189 Check Number Of Groups On Member
190 [Arguments] ${groups} ${member_index}=1
191 [Documentation] Check number of groups in the inventory.
192 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
193 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
195 Should Be Equal As Strings ${resp.status_code} 200
196 ${group_count}= Get Count ${resp.content} "group-type"
197 ${count}= CompareStream.Set_Variable_If_At Least_Boron ${group_count} ${group_count/2}
198 Should Be Equal As Integers ${count} ${groups}