2 Documentation Test suite for Stats Manager flows collection
4 Library OperatingSystem
7 Library ../../../libraries/XmlComparator.py
8 Library RequestsLibrary
9 Library ../../../libraries/Common.py
10 Variables ../../../variables/Variables.py
11 Resource ../../../variables/openflowplugin/Variables.robot
13 Suite Setup Initialization Phase
14 Suite Teardown Teardown Phase
18 ${XmlsDir} ${CURDIR}/../../../variables/xmls
20 ${switch_name} s${switch_idx}
21 @{xml_files} f1.xml f2.xml f3.xml f5.xml f7.xml f8.xml f9.xml
22 ... f10.xml f11.xml f14.xml f17.xml f19.xml f24.xml
27 [Documentation] Add all flows and waits for SM to collect data
28 FOR ${flowfile} IN @{xml_files}
30 Init Flow Variables ${flowfile}
31 Run Keyword And Continue On Failure Add Flow
35 [Documentation] Checks if flow is configured and operational
36 Init Flow Variables f1.xml
37 Check Config Flow ${True}
38 Check Operational Table ${True}
41 [Documentation] Checks if flow is configured and operational
42 Init Flow Variables f2.xml
43 Check Config Flow ${True}
44 Check Operational Table ${True}
47 [Documentation] Checks if flow is configured and operational
48 Init Flow Variables f3.xml
49 Check Config Flow ${True}
50 Check Operational Table ${True}
53 [Documentation] Checks if flow is configured and operational
54 Init Flow Variables f5.xml
55 Check Config Flow ${True}
56 Check Operational Table ${True}
59 [Documentation] Checks if flow is configured and operational
60 Init Flow Variables f7.xml
61 Check Config Flow ${True}
62 Check Operational Table ${True}
65 [Documentation] Checks if flow is configured and operational
66 Init Flow Variables f8.xml
67 Check Config Flow ${True}
68 Check Operational Table ${True}
71 [Documentation] Checks if flow is configured and operational
72 Init Flow Variables f9.xml
73 Check Config Flow ${True}
74 Check Operational Table ${True}
77 [Documentation] Checks if flow is configured and operational
78 Init Flow Variables f10.xml
79 Check Config Flow ${True}
80 Check Operational Table ${True}
83 [Documentation] Checks if flow is configured and operational
84 Init Flow Variables f11.xml
85 Check Config Flow ${True}
86 Check Operational Table ${True}
89 [Documentation] Checks if flow is configured and operational
90 Init Flow Variables f14.xml
91 Check Config Flow ${True}
92 Check Operational Table ${True}
95 [Documentation] Checks if flow is configured and operational
96 Init Flow Variables f17.xml
97 Check Config Flow ${True}
98 Check Operational Table ${True}
100 Test Is Flow 19 Added
101 [Documentation] Checks if flow is configured and operational
102 Init Flow Variables f19.xml
103 Check Config Flow ${True}
104 Check Operational Table ${True}
106 Test Is Flow 24 Added
107 [Documentation] Checks if flow is configured and operational
108 Init Flow Variables f24.xml
109 Check Config Flow ${True}
110 Check Operational Table ${True}
113 [Documentation] Delete all flows and waits for SM to collect data
114 FOR ${flowfile} IN @{xml_files}
116 Init Flow Variables ${flowfile}
117 Run Keyword And Continue On Failure Delete Flow
120 Test Is Flow 1 Deleted
121 [Documentation] Checks if flow is not configured and operational
122 Init Flow Variables f1.xml
123 Check Config Flow ${False}
124 Check Operational Table ${False}
126 Test Is Flow 2 Deleted
127 [Documentation] Checks if flow is not configured and operational
128 Init Flow Variables f2.xml
129 Check Config Flow ${False}
130 Check Operational Table ${False}
132 Test Is Flow 3 Deleted
133 [Documentation] Checks if flow is not configured and operational
134 Init Flow Variables f3.xml
135 Check Config Flow ${False}
136 Check Operational Table ${False}
138 Test Is Flow 5 Deleted
139 [Documentation] Checks if flow is not configured and operational
140 Init Flow Variables f5.xml
141 Check Config Flow ${False}
142 Check Operational Table ${False}
144 Test Is Flow 7 Deleted
145 [Documentation] Checks if flow is not configured and operational
146 Init Flow Variables f7.xml
147 Check Config Flow ${False}
148 Check Operational Table ${False}
150 Test Is Flow 8 Deleted
151 [Documentation] Checks if flow is not configured and operational
152 Init Flow Variables f8.xml
153 Check Config Flow ${False}
154 Check Operational Table ${False}
156 Test Is Flow 9 Deleted
157 [Documentation] Checks if flow is not configured and operational
158 Init Flow Variables f9.xml
159 Check Config Flow ${False}
160 Check Operational Table ${False}
162 Test Is Flow 10 Deleted
163 [Documentation] Checks if flow is not configured and operational
164 Init Flow Variables f10.xml
165 Check Config Flow ${False}
166 Check Operational Table ${False}
168 Test Is Flow 11 Deleted
169 [Documentation] Checks if flow is not configured and operational
170 Init Flow Variables f11.xml
171 Check Config Flow ${False}
172 Check Operational Table ${False}
174 Test Is Flow 14 Deleted
175 [Documentation] Checks if flow is not configured and operational
176 Init Flow Variables f14.xml
177 Check Config Flow ${False}
178 Check Operational Table ${False}
180 Test Is Flow 17 Deleted
181 [Documentation] Checks if flow is not configured and operational
182 Init Flow Variables f17.xml
183 Check Config Flow ${False}
184 Check Operational Table ${False}
186 Test Is Flow 19 Deleted
187 [Documentation] Checks if flow is not configured and operational
188 Init Flow Variables f19.xml
189 Check Config Flow ${False}
190 Check Operational Table ${False}
192 Test Is Flow 24 Deleted
193 [Documentation] Checks if flow is not configured and operational
194 Init Flow Variables f24.xml
195 Check Config Flow ${False}
196 Check Operational Table ${False}
202 ${data}= Get File ${XmlsDir}/${file}
203 ${xmlroot}= Parse Xml ${XmlsDir}/${file}
204 ${table_id}= Get Element Text ${xmlroot} table_id
205 ${flow_id}= Get Element Text ${xmlroot} id
206 ${flow_priority}= Get Element Text ${xmlroot} priority
207 Set Suite Variable ${table_id}
208 Set Suite Variable ${flow_id}
209 Set Suite Variable ${flow_priority}
210 Set Suite Variable ${data}
211 Set Suite Variable ${xmlroot}
214 [Arguments] ${expected}
215 Wait Until Keyword Succeeds 40s 2s Check Config Flow Presence ${expected}
217 Check Config Flow Presence
218 [Arguments] ${expected}
219 ${presence_flow} ${msg}= Flow Presence Config Flow
220 ${msgf}= Get Presence Failure Message config ${expected} ${presence_flow} ${msg}
221 Should Be Equal ${expected} ${presence_flow} msg=${msgf}
223 Flow Presence Config Flow
224 ${headers}= Create Dictionary Accept=application/xml
225 ${resp}= RequestsLibrary.Get Request
227 ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
228 ... headers=${headers}
231 IF ${resp.status_code}!=200 RETURN ${False} ${EMPTY}
232 ${pres} ${msg}= Is Flow Configured ${data} ${resp.content}
233 IF '''${msg}'''!='${EMPTY}' Log ${msg}
234 RETURN ${pres} ${msg}
236 Check Operational Table
237 [Arguments] ${expected}
238 Wait Until Keyword Succeeds 120s 2s Check Operational Table Presence ${expected}
240 Check Operational Table Presence
241 [Arguments] ${expected}
242 ${presence_table} ${msg}= Flow Presence Operational Table
243 ${msgf}= Get Presence Failure Message config ${expected} ${presence_table} ${msg}
244 Should Be Equal ${expected} ${presence_table} msg=${msgf}
246 Flow Presence Operational Table
247 ${headers}= Create Dictionary Accept=application/xml
248 ${resp}= RequestsLibrary.Get Request
250 ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}?${RFC8040_OPERATIONAL_CONTENT}
251 ... headers=${headers}
254 IF ${resp.status_code}!=200 RETURN ${False} ${EMPTY}
255 ${pres} ${msg}= Is Flow Operational2 ${data} ${resp.content}
256 IF '''${msg}'''!='${EMPTY}' Log ${msg}
257 RETURN ${pres} ${msg}
261 ${resp}= RequestsLibrary.Put Request
263 ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
264 ... headers=${HEADERS_XML}
267 ... Adding flow for ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
268 Should Be Equal As Strings ${resp.status_code} 200 msg=${msg}
271 ${resp}= RequestsLibrary.Delete Request
273 ... ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
275 ... Delete flow for ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
276 Should Be Equal As Strings ${resp.status_code} 200 msg=${msg}
279 [Documentation] Deletes all flows
280 FOR ${flowfile} IN @{xml_files}
282 Init Flow Variables ${flowfile}
287 [Documentation] Initiate tcp connection with controller
288 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
291 [Documentation] Closes tcp connection with controller and removes flows
294 Get Presence Failure Message
295 [Arguments] ${ds} ${expected} ${presence} ${diffmsg}
296 IF '''${diffmsg}'''!='${EMPTY}'
297 RETURN Flow found in ${ds} data store but: ${diffmsg}
299 ${msgf}= Set Variable If
300 ... ${expected}==${True}
301 ... The flow is expected in operational data store, but
302 ... The flow is not expected in operational data store, but
303 ${msgp}= Set Variable If ${presence}==${True} it is present. it is not present.
304 RETURN ${msgf} ${msgp}