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 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}
65 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}
66 ... member_index_list=${controller_index_list}
67 ${dictionary} Create Dictionary openflow=0
68 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}
70 Add Sample Flow And Verify
71 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
72 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
73 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
74 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
75 # replicating some of the matches in the flows section. Same comment applies for further keywords.
76 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
77 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
78 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
79 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}
82 [Arguments] ${controller_index_list}=${EMPTY}
83 [Documentation] Verify sample flow gets applied in all instances in ${controller_index_list}.
84 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
85 # replicating some of the matches in the flows section. Same comment applies for further keywords.
86 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
87 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
88 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}
90 Modify Sample Flow And Verify
91 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
92 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
93 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
94 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
95 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
96 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
97 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}
99 Delete Sample Flow And Verify
100 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
101 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
102 ${dictionary}= Create Dictionary 10.0.1.0/24=0
103 ClusterManagement.Delete_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${controller_index} ${controller_index_list}
104 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}
106 Send RPC Add Sample Flow And Verify
107 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
108 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
109 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
110 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2
111 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1
112 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:add-flow data=${body} member_index=${controller_index}
113 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}
115 Send RPC Delete Sample Flow And Verify
116 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
117 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
118 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
119 ${dictionary}= Create Dictionary 10.0.1.0/24=0
120 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:remove-flow data=${body} member_index=${controller_index}
121 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}
123 Take OpenFlow Device Link Down and Verify
124 [Arguments] ${controller_index_list}=${EMPTY}
125 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
126 ${dictionary}= Create Dictionary "link-down":true=1
127 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 down
128 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}
129 ${dictionary} Create Dictionary openflow:1=16 openflow:2=14 openflow:3=19
130 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}
132 Take OpenFlow Device Link Up and Verify
133 [Arguments] ${controller_index_list}=${EMPTY}
134 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
135 ${dictionary}= Create Dictionary "link-down":true=0
136 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 up
137 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}
138 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
139 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}
141 Verify Switch Connections Running On Member
142 [Arguments] ${switch_count} ${member_index}
143 [Documentation] Check if number of Switch connections on member of given index is equal to ${switch_count}.
144 ${count} = ScaleClient.Get_Switches_Count controller=${ODL_SYSTEM_${member_index}_IP}
145 BuiltIn.Should_Be_Equal_As_Numbers ${switch_count} ${count}
147 Check Flows Operational Datastore On Member
148 [Arguments] ${flow_count} ${member_index}
149 [Documentation] Check if number of Operational Flows on member of given index is equal to ${flow_count}.
150 ${sw} ${reported_flow} ${found_flow}= ScaleClient.Flow Stats Collected controller=${ODL_SYSTEM_${member_index}_IP}
151 BuiltIn.Should_Be_Equal_As_Numbers ${flow_count} ${found_flow}
153 Check Linear Topology On Member
154 [Arguments] ${switches} ${member_index}=1
155 [Documentation] Check Linear topology.
156 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
157 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
159 Should Be Equal As Strings ${resp.status_code} 200
160 FOR ${switch} IN RANGE 1 ${switches+1}
161 Should Contain ${resp.content} "node-id":"openflow:${switch}"
162 Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
163 Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
164 Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
165 Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
166 ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
167 Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
168 Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
169 Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3
172 Check No Switches On Member
173 [Arguments] ${switches} ${member_index}=1
174 [Documentation] Check no switch is in topology
175 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
176 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
178 Should Be Equal As Strings ${resp.status_code} 200
179 FOR ${switch} IN RANGE 1 ${switches+1}
180 Should Not Contain ${resp.content} openflow:${switch}
183 Check Number Of Flows On Member
184 [Arguments] ${flows} ${member_index}=1
185 [Documentation] Check number of flows in the inventory.
186 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
187 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
189 Should Be Equal As Strings ${resp.status_code} 200
190 ${count}= Get Count ${resp.content} "priority"
191 Should Be Equal As Integers ${count} ${flows}
193 Check Number Of Groups On Member
194 [Arguments] ${groups} ${member_index}=1
195 [Documentation] Check number of groups in the inventory.
196 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
197 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
199 Should Be Equal As Strings ${resp.status_code} 200
200 ${group_count}= Get Count ${resp.content} "group-type"
201 Should Be Equal As Integers ${group_count} ${groups}