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