Correctly space expected_status
[integration/test.git] / csit / suites / openflowplugin / Flows_Stats_OF13 / 010__SM_add_upd_del_flows.robot
1 *** Settings ***
2 Documentation       Test suite for Stats Manager flows collection
3
4 Library             OperatingSystem
5 Library             Collections
6 Library             XML
7 Library             ../../../libraries/XmlComparator.py
8 Library             RequestsLibrary
9 Library             ../../../libraries/Common.py
10 Variables           ../../../variables/Variables.py
11 Resource            ../../../variables/openflowplugin/Variables.robot
12
13 Suite Setup         Initialization Phase
14 Suite Teardown      Teardown Phase
15
16
17 *** Variables ***
18 ${XmlsDir}          ${CURDIR}/../../../variables/xmls
19 ${switch_idx}       1
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
23
24
25 *** Test Cases ***
26 Test Add Flows
27     [Documentation]    Add all flows and waits for SM to collect data
28     FOR    ${flowfile}    IN    @{xml_files}
29         Log    ${flowfile}
30         Init Flow Variables    ${flowfile}
31         Run Keyword And Continue On Failure    Add Flow
32     END
33
34 Test Is Flow 1 Added
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}
39
40 Test Is Flow 2 Added
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}
45
46 Test Is Flow 3 Added
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}
51
52 Test Is Flow 5 Added
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}
57
58 Test Is Flow 7 Added
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}
63
64 Test Is Flow 8 Added
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}
69
70 Test Is Flow 9 Added
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}
75
76 Test Is Flow 10 Added
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}
81
82 Test Is Flow 11 Added
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}
87
88 Test Is Flow 14 Added
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}
93
94 Test Is Flow 17 Added
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}
99
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}
105
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}
111
112 Test Delete Flows
113     [Documentation]    Delete all flows and waits for SM to collect data
114     FOR    ${flowfile}    IN    @{xml_files}
115         Log    ${flowfile}
116         Init Flow Variables    ${flowfile}
117         Run Keyword And Continue On Failure    Delete Flow
118     END
119
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}
125
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}
131
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}
137
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}
143
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}
149
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}
155
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}
161
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}
167
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}
173
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}
179
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}
185
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}
191
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}
197
198
199 *** Keywords ***
200 Init Flow Variables
201     [Arguments]    ${file}
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}
212
213 Check Config Flow
214     [Arguments]    ${expected}
215     Wait Until Keyword Succeeds    40s    2s    Check Config Flow Presence    ${expected}
216
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}
222
223 Flow Presence Config Flow
224     ${headers}=    Create Dictionary    Accept=application/xml
225     ${resp}=    RequestsLibrary.Get Request
226     ...    session
227     ...    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
228     ...    headers=${headers}
229     Log    ${resp}
230     Log    ${resp.content}
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}
235
236 Check Operational Table
237     [Arguments]    ${expected}
238     Wait Until Keyword Succeeds    120s    2s    Check Operational Table Presence    ${expected}
239
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}
245
246 Flow Presence Operational Table
247     ${headers}=    Create Dictionary    Accept=application/xml
248     ${resp}=    RequestsLibrary.Get Request
249     ...    session
250     ...    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}?${RFC8040_OPERATIONAL_CONTENT}
251     ...    headers=${headers}
252     Log    ${resp}
253     Log    ${resp.content}
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}
258
259 Add Flow
260     Log    ${data}
261     ${resp}=    RequestsLibrary.Put Request
262     ...    session
263     ...    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
264     ...    headers=${HEADERS_XML}
265     ...    data=${data}
266     ${msg}=    Set Variable
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}
269
270 Delete Flow
271     ${resp}=    RequestsLibrary.Delete Request
272     ...    session
273     ...    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
274     ${msg}=    Set Variable
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}
277
278 Delete All Flows
279     [Documentation]    Deletes all flows
280     FOR    ${flowfile}    IN    @{xml_files}
281         Log    ${flowfile}
282         Init Flow Variables    ${flowfile}
283         Delete Flow
284     END
285
286 Initialization Phase
287     [Documentation]    Initiate tcp connection with controller
288     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
289
290 Teardown Phase
291     [Documentation]    Closes tcp connection with controller and removes flows
292     Delete All Sessions
293
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}
298     END
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}