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