blob: 47e7dfe61e7e39be949f87bf351e191f168b988f [file] [log] [blame]
Matteo Scandolo564009f2019-01-16 14:11:02 -08001*** Settings ***
2Documentation Scale up models in a SEBA deployment with no backends
3Library KafkaLibrary
4Library RequestsLibrary
5Library HttpLibrary.HTTP
6Library Collections
7Library String
8Library OperatingSystem
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -08009Library DateTime
Matteo Scandolo564009f2019-01-16 14:11:02 -080010Library ./utils/devices.py
11Suite Setup Setup
12Suite Teardown Teardown
13
14*** Variables ***
15${xos_chameleon_url} xos-chameleon
16${xos_chameleon_port} 9101
17${cord_kafka} cord-kafka
18
19${num_olts} 1
20${num_pon_ports} 1
21${num_onus} 1
22
23${timeout} 300s
24
25*** Test Cases ***
26
27Check OLTs Created
28 ${res} = CORD Get /xosapi/v1/volt/oltdevices
29 ${jsondata} = To Json ${res.content}
30 ${length} = Get Length ${jsondata['items']}
31 ${total} = Convert To Integer ${num_olts}
32 Should Be Equal ${length} ${total}
33
34Check PON Ports Created
35 ${res} = CORD Get /xosapi/v1/volt/ponports
36 ${jsondata} = To Json ${res.content}
37 ${length} = Get Length ${jsondata['items']}
38 ${total} = Evaluate ${num_olts} * ${num_pon_ports}
39 Should Be Equal ${length} ${total}
40
41Check ONUs Created
42 ${res} = CORD Get /xosapi/v1/volt/onudevices
43 ${jsondata} = To Json ${res.content}
44 ${length} = Get Length ${jsondata['items']}
45 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
46 Should Be Equal ${length} ${total}
47
48Check UNI Ports Created
49 ${res} = CORD Get /xosapi/v1/volt/uniports
50 ${jsondata} = To Json ${res.content}
51 ${length} = Get Length ${jsondata['items']}
52 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
53 Should Be Equal ${length} ${total}
54
55Check Whitelist Created
56 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
57 ${jsondata} = To Json ${res.content}
58 ${length} = Get Length ${jsondata['items']}
59 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
60 Should Be Equal ${length} ${total}
61
62Activate ONUs
63 [Documentation] Send activation events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
64 ${events} = Generate Onu Events
65 : FOR ${e} IN @{events}
66 \ Send Kafka Event onu.events ${e}
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080067 ${start} = Get Time
Matteo Scandolo564009f2019-01-16 14:11:02 -080068 Wait Until Keyword Succeeds ${timeout} 5s Validate ATT_SI Number ${events}
Kailash2abefa82019-02-01 12:40:07 -080069 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080070 ${end} = Get Time
71 Log To Console Test started at: ${start}
72 Log To Console Test ended at: ${end}
73 ${duration} = Subtract Date From Date ${end} ${start}
74 Log To Console Test duration: ${duration}
75
Matteo Scandolo6ccc9902019-03-01 13:07:35 -080076Authenticate Subscribers
77 [Documentation] Send authentication events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
78 ${events} = Generate Auth Events
79 : FOR ${e} IN @{events}
80 \ Send Kafka Event authentication.events ${e}
81 ${start} = Get Time
82 Wait Until Keyword Succeeds ${timeout} 5s AuthCompleted
83 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
84 # TODO validate that:
85 # - subscriber status has changed
86 # - vOLT SI have been created and policed (we can't test sync'ed without a backend)
87 # - fabric-xconnect have been created and policed (we can't test sync'ed without a backend)
88 ${end} = Get Time
89 Log To Console Test started at: ${start}
90 Log To Console Test ended at: ${end}
91 ${duration} = Subtract Date From Date ${end} ${start}
92 Log To Console Test duration: ${duration}
93
94DHCP Subscribers
95 [Documentation] Send dhcp events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
96 ${events} = Generate Dhcp Events
97 : FOR ${e} IN @{events}
98 \ Send Kafka Event dhcp.events ${e}
99 ${start} = Get Time
100 Wait Until Keyword Succeeds ${timeout} 5s DHCPCompleted
101 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
102 # TODO validate that:
103 # - subscriber has an IP address
104 ${end} = Get Time
105 Log To Console Test started at: ${start}
106 Log To Console Test ended at: ${end}
107 ${duration} = Subtract Date From Date ${end} ${start}
108 Log To Console Test duration: ${duration}
109
Matteo Scandolo564009f2019-01-16 14:11:02 -0800110
111*** Keywords ***
112
113Validate ATT_SI Number
114 [Arguments] ${events}
115 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
116 ${jsondata} = To Json ${res.content}
117 ${length} = Get Length ${jsondata['items']}
118 ${total} = Get Length ${events}
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -0800119 Log To Console ${length} Service Instances created, expecting ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800120 Should Be Equal ${length} ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800121
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800122DHCPCompleted
123 [Documentation] Check that all ATT_SI have an ip address
Kailash2abefa82019-02-01 12:40:07 -0800124 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
125 ${jsondata} = To Json ${res.content}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800126 Log To Console Checking DHCP
Kailash2abefa82019-02-01 12:40:07 -0800127 : FOR ${i} IN @{jsondata['items']}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800128 \ Should Not Be Empty ${i['ip_address']}
129
130AuthCompleted
131 [Documentation] Check that all ATT_SI have status=authenticated
132 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
133 ${jsondata} = To Json ${res.content}
134 Log To Console Checking Authentication
135 : FOR ${i} IN @{jsondata['items']}
136 \ Should Be Equal ${i['authentication_state']} APPROVED
137
138ModelPolicy completed
139 # TODO make this method configurable to check model_policies on arbitrary models
140 [Documentation] Check that model_policies had run for all the items in the list
141 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
142 ${jsondata} = To Json ${res.content}
143 Log To Console Checking ModelPolicy
144 : FOR ${i} IN @{jsondata['items']}
145 \ Should Be True ${i['policed']} >= ${i['updated']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800146
147Setup
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800148 # TODO remove all JSON files that a previous run may have left around
Matteo Scandolo564009f2019-01-16 14:11:02 -0800149 ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
150 Log Testing with ${target} ONUs
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -0800151 Log To Console Testing with ${target} ONUs
Matteo Scandolo564009f2019-01-16 14:11:02 -0800152 Connect Producer ${cord_kafka}:9092 onu.events
153 Connect Producer ${cord_kafka}:9092 authentication.events
154 Connect Producer ${cord_kafka}:9092 dhcp.events
155 ${auth} = Create List admin@opencord.org letmein
156 ${HEADERS} Create Dictionary Content-Type=application/json allow_modify_feedback=True
157 Create Session XOS http://${xos_chameleon_url}:${xos_chameleon_port} auth=${AUTH} headers=${HEADERS}
158 Store Data
159 Mock Data
160 ${mock} = Get Mock Data
161 Log ${mock}
162
163Teardown
164 [Documentation] Delete all models created
165 Log Teardown
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800166 Log To Console Teardown
Matteo Scandolo564009f2019-01-16 14:11:02 -0800167 Delete OLTs
168 Delete Whitelist
169 Delete ServiceInstances
170 Delete All Sessions
171 Clean Storage
172
173Mock Data
174 [Documentation] Mock all the data needed from the test
175 Create Mock Olts ${num_olts} ${voltservice_id}
176 Create Olts
177 Create Mock Pon Ports ${num_pon_ports}
178 Create Pon Ports
179 Create Mock Onus ${num_onus}
180 Create Onus
181 Create Mock Unis
182 Create Unis
183 Create Whitelist
184
185Create Olts
186 [Documentation] Stub OLT for the test
187 ${olts} = Get Rest Olts
188 : FOR ${OLT} IN @{olts}
189 \ Log ${OLT}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800190 \ Log To Console Creating OLT ${OLT['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800191 \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT}
192 \ ${jsondata} = To Json ${res.content}
193 \ Update Olt Id ${OLT} ${jsondata['id']}
194
195Create Pon Ports
196 ${pon_ports} = Get Rest Pon Ports
197 : FOR ${port} IN @{pon_ports}
198 \ Log ${port}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800199 \ Log To Console Creating PON Port ${port['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800200 \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port}
201 \ ${jsondata} = To Json ${res.content}
202 \ Update Pon Port Id ${port} ${jsondata['id']}
203
204Create Onus
205 ${onus} = Get Rest Onus
206 : FOR ${onu} IN @{onus}
207 \ Log ${onu}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800208 \ Log To Console Creating ONU ${onu['serial_number']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800209 \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu}
210 \ ${jsondata} = To Json ${res.content}
211 \ Update Onu Id ${onu} ${jsondata['id']}
212
213Create Unis
214 ${unis} = Get Rest Unis
215 : FOR ${uni} IN @{unis}
216 \ Log ${uni}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800217 \ Log To Console Creating UNI ${uni['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800218 \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni}
219 \ ${jsondata} = To Json ${res.content}
220 \ Update Uni Id ${uni} ${jsondata['id']}
221
222Create Whitelist
223 [Documentation] Create a whitelist for the tests
224 ${whitelist} = Create Mock Whitelist ${attworkflowservice_id}
225 : FOR ${e} IN @{whitelist}
226 \ Log ${e}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800227 \ Log To Console Creating Whitelist Entry ${e['serial_number']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800228 \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e}
229
230Delete Olts
231 [Documentation] Remove all the OLTs created for the test
232 ${res} = CORD Get /xosapi/v1/volt/oltdevices
233 ${jsondata} = To Json ${res.content}
234 :FOR ${ELEMENT} IN @{jsondata['items']}
235 \ ${id}= Get From Dictionary ${ELEMENT} id
236 \ CORD Delete /xosapi/v1/volt/oltdevices ${id}
237
238Delete Whitelist
239 [Documentation] Clean the whitelist
240 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
241 ${jsondata} = To Json ${res.content}
242 :FOR ${ELEMENT} IN @{jsondata['items']}
243 \ ${id}= Get From Dictionary ${ELEMENT} id
244 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${id}
245
246Delete ServiceInstances
247 [Documentation] Clean the whitelist
248 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
249 ${jsondata} = To Json ${res.content}
250 :FOR ${ELEMENT} IN @{jsondata['items']}
251 \ ${id}= Get From Dictionary ${ELEMENT} id
252 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances ${id}
253
254Store Data
255 [Documentation] Store all the ids needed for the test to work
256 # Get AttWorkflowDriverService id
257 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
258 ${jsondata}= To Json ${resp.content}
259 ${attworkflowservice}= Get From List ${jsondata['items']} 0
260 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
261 Set Suite Variable ${attworkflowservice_id}
262
263 # Get VoltService id
264 ${resp}= CORD Get /xosapi/v1/volt/voltservices
265 ${jsondata}= To Json ${resp.content}
266 ${voltservice}= Get From List ${jsondata['items']} 0
267 ${voltservice_id}= Get From Dictionary ${voltservice} id
268 Set Suite Variable ${voltservice_id}
269
270Send Kafka Event
271 [Documentation] Send event
272 [Arguments] ${topic} ${message}
273 Log Sending event
274 ${event}= evaluate json.dumps(${message}) json
275 Send ${topic} ${event}
276 Flush
277
278CORD Get
279 [Documentation] Make a GET call to XOS
280 [Arguments] ${service}
281 ${resp}= Get Request XOS ${service}
282 Log ${resp.content}
283 Should Be Equal As Strings ${resp.status_code} 200
284 [Return] ${resp}
285
286CORD Post
287 [Documentation] Make a POST call to XOS
288 [Arguments] ${service} ${data}
289 ${data}= Evaluate json.dumps(${data}) json
290 ${resp}= Post Request XOS uri=${service} data=${data}
291 Log ${resp.content}
292 Should Be Equal As Strings ${resp.status_code} 200
293 [Return] ${resp}
294
295CORD Delete
296 [Documentation] Make a DELETE call to the CORD controller
297 [Arguments] ${service} ${data_id}
298 ${resp}= Delete Request XOS uri=${service}/${data_id}
299 Log ${resp.content}
300 Should Be Equal As Strings ${resp.status_code} 200
Kailash2abefa82019-02-01 12:40:07 -0800301 [Return] ${resp}