2 Documentation Resource for OpenFlow workflows. This library can be used for scalability and longevity tests.
5 Library RequestsLibrary
7 Library SwitchClasses/BaseSwitch.py
9 Resource CompareStream.robot
10 Resource MininetKeywords.robot
11 Resource KarafKeywords.robot
12 Resource ../variables/Variables.robot
15 ${topology_file} create_fullymesh.py
16 ${topology_file_path} MininetTopo/${topology_file}
24 Workflow Linear Topology
25 [Arguments] ${switches} ${sustain_time}=0
26 [Documentation] Workflow to bring a Linear topology of ${switches} switches, push flows, hold for ${sustain_time} seconds, delete flows and stop topology.
27 ... This KW returns workflow state (PASS/FAIL), error message and topology discover time.
28 # Define required variables
29 ${error_message}= Set Variable Test has completed
30 ${topology_discover_time}= Set Variable ${0}
31 ${controller_list}= Create List ${ODL_SYSTEM_IP}
32 ${flow_count}= Convert to Integer ${flow_count}
33 ${flows_ovs_25}= Evaluate ${flow_count} + ${switches}
34 ${flows_before}= CompareStream.Set_Variable_If_At_Least_Boron ${switches} ${0}
35 ${flows_after}= CompareStream.Set_Variable_If_At_Least_Boron ${flows_ovs_25} ${flow_count}
36 ${flows} ${notes} ScaleClient.Generate New Flow Details flows=${flow_count} switches=${switches} swspread=${swspread} tables=${tables}
37 ... tabspread=${tabspread}
40 Log To Console Starting mininet linear ${switches} switches
41 ${status} ${result} Run Keyword And Ignore Error Start Mininet Linear ${switches} mininet_timeout=${switches*4}
42 Return From Keyword If '${status}' == 'FAIL' ${status} Fail starting mininet ${topology_discover_time}
43 ${start_time}= DateTime.Get Current Date result_format=timestamp
44 Log To Console Verify controller is OK
45 ${status} ${result} Run Keyword And Ignore Error Utils.Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
46 Return From Keyword If '${status}' == 'FAIL' ${status} Controller is dead ${topology_discover_time}
47 ${status} ${result} Run Keyword And Ignore Error Utils.Verify Controller Has No Null Pointer Exceptions ${ODL_SYSTEM_IP}
48 Return From Keyword If '${status}' == 'FAIL' ${status} Controller has NPE ${topology_discover_time}
49 Log To Console Checking ${switches} switches
50 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s Check Every Switch
52 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking switch ${topology_discover_time}
53 Log To Console Checking Linear Topology
54 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches} 2s Check Linear Topology
56 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking topology ${topology_discover_time}
57 ${end_time}= DateTime.Get Current Date result_format=timestamp
58 ${topology_discover_time}= DateTime.Subtract Date From Date ${end_time} ${start_time}
59 Log To Console Topology Discovery Time = ${topology_discover_time} seconds
60 Log To Console Adding ${flow_count} flows
61 ${status} ${result} Run Keyword And Ignore Error ScaleClient.Configure Flows flow_details=${flows} controllers=${controller_list} nrthreads=${nrthreads}
62 Return From Keyword If '${status}' == 'FAIL' ${status} Fail configuring flows ${topology_discover_time}
63 Log To Console Checking ${flow_count} flows in Mininet
64 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Verify Aggregate Flow From Mininet Session ${mininet_conn_id} ${flows_after} ${switches}
65 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking flows in mininet ${topology_discover_time}
66 Log To Console Checking ${flow_count} flows in Operational DS
67 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*4} 2s Check Flows Operational Datastore
69 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking flows in operational DS ${topology_discover_time}
70 Log To Console Sleep for ${sustain_time} seconds
72 Log To Console Deleting ${flow_count} flows
73 ${status} ${result} Run Keyword And Ignore Error ScaleClient.Deconfigure Flows flow_details=${flows} controllers=${controller_list} nrthreads=${nrthreads}
74 Return From Keyword If '${status}' == 'FAIL' ${status} Fail deconfiguring flows ${topology_discover_time}
75 Log To Console Checking no flows in Mininet
76 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Verify Aggregate Flow From Mininet Session ${mininet_conn_id} ${flows_before} ${switches}
77 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no flows in mininet ${topology_discover_time}
78 Log To Console Checking no flows in Operational DS
79 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*4} 2s Check Flows Operational Datastore
81 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no flows in operational DS ${topology_discover_time}
82 Log To Console Stopping Mininet
83 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Stop Mininet And Exit
84 Return From Keyword If '${status}' == 'FAIL' ${status} Fail stopping mininet ${topology_discover_time}
85 Log To Console Checking No Switches
86 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check No Switches
88 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no switch ${topology_discover_time}
89 Log To Console Checking No Topology
90 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check No Topology
92 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no topology ${topology_discover_time}
93 [Return] PASS ${error_message} ${topology_discover_time}
95 Workflow Full Mesh Topology
96 [Arguments] ${switches} ${sustain_time}=0
97 [Documentation] Workflow to bring a Full mesh topology of ${switches} switches, push some flows, delete flows and stop topology.
98 ... This KW returns workflow state (PASS/FAIL), error message and topology discover time.
99 # Define required variables
100 ${error_message}= Set Variable Test has completed
101 ${topology_discover_time}= Set Variable ${0}
102 ${mininet_timeout}= Evaluate ${switches} * ${switches}
103 ${links}= Evaluate ${switches} * ${switches-1}
104 ${controller_list}= Create List ${ODL_SYSTEM_IP}
105 ${flow_count}= Convert to Integer ${flow_count}
106 ${flows_ovs_25}= Evaluate ${flow_count} + ${switches}
107 ${flows_before}= CompareStream.Set_Variable_If_At_Least_Boron ${switches} ${0}
108 ${flows_after}= CompareStream.Set_Variable_If_At_Least_Boron ${flows_ovs_25} ${flow_count}
109 ${flows} ${notes} ScaleClient.Generate New Flow Details flows=${flow_count} switches=${switches} swspread=${swspread} tables=${tables}
110 ... tabspread=${tabspread}
113 Log To Console Start a mininet full mesh ${switches} switches
114 ${status} ${result} Run Keyword And Ignore Error Start Mininet Full Mesh ${switches} mininet_timeout=${mininet_timeout}
115 Return From Keyword If '${status}' == 'FAIL' ${status} Fail starting mininet ${topology_discover_time}
116 ${start_time}= DateTime.Get Current Date result_format=timestamp
117 Log To Console Verify controller is OK
118 ${status} ${result} Run Keyword And Ignore Error Utils.Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
119 Return From Keyword If '${status}' == 'FAIL' ${status} Controller is dead ${topology_discover_time}
120 ${status} ${result} Run Keyword And Ignore Error Utils.Verify Controller Has No Null Pointer Exceptions ${ODL_SYSTEM_IP}
121 Return From Keyword If '${status}' == 'FAIL' ${status} Controller has NPE ${topology_discover_time}
122 Log To Console Checking ${switches} switches
123 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check Every Switch
125 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking switch ${topology_discover_time}
126 Log To Console Check number of links in inventory is ${links}
127 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check Number Of Links
129 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking topology ${topology_discover_time}
130 ${end_time}= DateTime.Get Current Date result_format=timestamp
131 ${topology_discover_time}= DateTime.Subtract Date From Date ${end_time} ${start_time}
132 Log To Console Topology Discovery Time = ${topology_discover_time} seconds
133 Log To Console Adding ${flow_count} flows
134 ${status} ${result} Run Keyword And Ignore Error ScaleClient.Configure Flows flow_details=${flows} controllers=${controller_list} nrthreads=${nrthreads}
135 Return From Keyword If '${status}' == 'FAIL' ${status} Fail configuring flows ${topology_discover_time}
136 Log To Console Checking ${flow_count} flows in Mininet
137 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Verify Aggregate Flow From Mininet Session ${mininet_conn_id} ${flows_after} ${switches}
138 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking flows in mininet ${topology_discover_time}
139 Log To Console Checking ${flow_count} flows in Operational DS
140 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*4} 2s Check Flows Operational Datastore
142 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking flows in operational DS ${topology_discover_time}
143 Log To Console Sleep for ${sustain_time} seconds
144 Sleep ${sustain_time}
145 Log To Console Deleting ${flow_count} flows
146 ${status} ${result} Run Keyword And Ignore Error ScaleClient.Deconfigure Flows flow_details=${flows} controllers=${controller_list} nrthreads=${nrthreads}
147 Return From Keyword If '${status}' == 'FAIL' ${status} Fail deconfiguring flows ${topology_discover_time}
148 Log To Console Checking no flows in Mininet
149 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Verify Aggregate Flow From Mininet Session ${mininet_conn_id} ${flows_before} ${switches}
150 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no flows in mininet ${topology_discover_time}
151 Log To Console Checking no flows in Operational DS
152 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*4} 2s Check Flows Operational Datastore
154 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no flows in operational DS ${topology_discover_time}
155 Log To Console Stopping Mininet
156 ${status} ${result} Run Keyword And Ignore Error MininetKeywords.Stop Mininet And Exit
157 Return From Keyword If '${status}' == 'FAIL' ${status} Fail stopping mininet ${topology_discover_time}
158 Log To Console Checking No Switches
159 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check No Switches
161 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no switch ${topology_discover_time}
162 Log To Console Checking No Topology
163 ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 10s 2s Check No Topology
165 Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no topology ${topology_discover_time}
166 [Return] PASS ${error_message} ${topology_discover_time}
169 [Arguments] ${switches} ${mininet_timeout}=${DEFAULT_TIMEOUT}
170 [Documentation] Start mininet linear topology with ${switches} nodes
171 Log Start Mininet Linear
172 MininetKeywords.StartMininet Single Controller options=--topo linear,${switches} --switch ovsk,protocols=OpenFlow13 timeout=${mininet_timeout}
174 Start Mininet Full Mesh
175 [Arguments] ${switches} ${base_mac}=00:00:00:00:00:00 ${base_ip}=10.0.0.0 ${hosts}=0 ${mininet_timeout}=${DEFAULT_TIMEOUT}
176 [Documentation] Start a custom mininet topology.
177 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=${mininet_timeout}
178 Set Suite Variable ${mininet_conn_id}
179 Utils.Flexible_Mininet_Login
180 Log Copying ${topology_file_path} file to Mininet VM and Creating Full Mesh topology
181 SSHLibrary.Put File ${CURDIR}/${topology_file_path}
182 SSHLibrary.Write python ${topology_file} ${switches} ${hosts} ${base_mac} ${base_ip}
183 SSHLibrary.Read Until ${DEFAULT_LINUX_PROMPT}
184 Log Start Mininet Full Mesh
185 SSHLibrary.Write sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom switch.py --topo demotopo --switch ovsk,protocols=OpenFlow13
187 Log Check OVS configuratiom
188 Write sh ovs-vsctl show
189 ${output}= Read Until mininet>
190 # Ovsdb connection is sometimes lost after mininet is started. Checking if the connection is alive before proceeding.
191 Should Not Contain ${output} database connection failed
194 [Arguments] ${switches} ${base_mac}=00:00:00:00:00:00
195 [Documentation] Check all switches and stats in operational inventory
196 ${mac}= String.Replace String Using Regexp ${base_mac} : ${EMPTY}
197 ${mac}= BaseSwitch.Convert Hex To Decimal As String ${mac}
198 ${mac}= Convert To Integer ${mac}
199 : FOR ${switch} IN RANGE 1 ${switches+1}
200 \ ${dpid_decimal}= Evaluate ${mac} + ${switch}
201 \ ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}/node/openflow:${dpid_decimal}
202 \ Should Be Equal As Strings ${resp.status_code} 200
203 \ Should Contain ${resp.content} flow-capable-node-connector-statistics
204 \ Should Contain ${resp.content} flow-table-statistics
206 Check Linear Topology
207 [Arguments] ${switches}
208 [Documentation] Check Linear topology given ${switches}
209 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
210 Should Be Equal As Strings ${resp.status_code} 200
211 : FOR ${switch} IN RANGE 1 ${switches+1}
212 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
213 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
214 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
215 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
216 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
217 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
218 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
219 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
220 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3"
222 Check Number Of Links
224 [Documentation] Check number of links in inventory is ${links}
225 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
226 Log Check number of links in inventory is ${links}
227 Should Be Equal As Strings ${resp.status_code} 200
228 ${count}= Get Count ${resp.content} "link-id":"openflow:
229 Should Be Equal As Integers ${count} ${links}
231 Check Flows Operational Datastore
232 [Arguments] ${flow_count} ${controller_ip}=${ODL_SYSTEM_IP}
233 [Documentation] Check if number of Operational Flows on member of given index is equal to ${flow_count}.
234 ${sw} ${reported_flow} ${found_flow}= ScaleClient.Flow Stats Collected controller=${controller_ip}
235 Should_Be_Equal_As_Numbers ${flow_count} ${found_flow}
238 [Arguments] ${switches}
239 [Documentation] Check no switch is in inventory
240 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}
241 Should Be Equal As Strings ${resp.status_code} 200
242 : FOR ${switch} IN RANGE 1 ${switches+1}
243 \ Should Not Contain ${resp.content} "openflow:${switch}"
246 [Arguments] ${switches}
247 [Documentation] Check no switch is in topology
248 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
249 Should Be Equal As Strings ${resp.status_code} 200
250 : FOR ${switch} IN RANGE 1 ${switches+1}
251 \ Should Not Contain ${resp.content} openflow:${switch}
254 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
255 Wait Until Keyword Succeeds 3x 1s KarafKeywords.Issue Command On Karaf Console log:set ERROR
258 [Documentation] Cleanup when workflow is interrupt
259 Run Keyword And Ignore Error RequestsLibrary.Delete Request session ${CONFIG_NODES_API}
261 RequestsLibrary.Delete All Sessions