blob: c7c85cb000857e931d557cf781187481090c75c3 [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
Matteo Scandolo564009f2019-01-16 14:11:02 -08005Library Collections
6Library String
7Library OperatingSystem
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -08008Library DateTime
Matteo Scandolo564009f2019-01-16 14:11:02 -08009Library ./utils/devices.py
10Suite Setup Setup
11Suite Teardown Teardown
12
13*** Variables ***
14${xos_chameleon_url} xos-chameleon
15${xos_chameleon_port} 9101
Matteo Scandolo564009f2019-01-16 14:11:02 -080016${num_olts} 1
17${num_pon_ports} 1
18${num_onus} 1
Matteo Scandolo564009f2019-01-16 14:11:02 -080019${timeout} 300s
20
21*** Test Cases ***
Matteo Scandolo564009f2019-01-16 14:11:02 -080022Check OLTs Created
23 ${res} = CORD Get /xosapi/v1/volt/oltdevices
24 ${jsondata} = To Json ${res.content}
25 ${length} = Get Length ${jsondata['items']}
26 ${total} = Convert To Integer ${num_olts}
27 Should Be Equal ${length} ${total}
28
29Check PON Ports Created
30 ${res} = CORD Get /xosapi/v1/volt/ponports
31 ${jsondata} = To Json ${res.content}
32 ${length} = Get Length ${jsondata['items']}
33 ${total} = Evaluate ${num_olts} * ${num_pon_ports}
34 Should Be Equal ${length} ${total}
35
36Check ONUs Created
37 ${res} = CORD Get /xosapi/v1/volt/onudevices
38 ${jsondata} = To Json ${res.content}
39 ${length} = Get Length ${jsondata['items']}
40 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
41 Should Be Equal ${length} ${total}
42
43Check UNI Ports Created
44 ${res} = CORD Get /xosapi/v1/volt/uniports
45 ${jsondata} = To Json ${res.content}
46 ${length} = Get Length ${jsondata['items']}
47 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
48 Should Be Equal ${length} ${total}
49
50Check Whitelist Created
51 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
52 ${jsondata} = To Json ${res.content}
53 ${length} = Get Length ${jsondata['items']}
54 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
55 Should Be Equal ${length} ${total}
56
57Activate ONUs
58 [Documentation] Send activation events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
59 ${events} = Generate Onu Events
60 : FOR ${e} IN @{events}
61 \ Send Kafka Event onu.events ${e}
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080062 ${start} = Get Time
Matteo Scandolo564009f2019-01-16 14:11:02 -080063 Wait Until Keyword Succeeds ${timeout} 5s Validate ATT_SI Number ${events}
Kailash2abefa82019-02-01 12:40:07 -080064 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080065 ${end} = Get Time
66 Log To Console Test started at: ${start}
67 Log To Console Test ended at: ${end}
68 ${duration} = Subtract Date From Date ${end} ${start}
69 Log To Console Test duration: ${duration}
70
Matteo Scandolo6ccc9902019-03-01 13:07:35 -080071Authenticate Subscribers
72 [Documentation] Send authentication events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
73 ${events} = Generate Auth Events
74 : FOR ${e} IN @{events}
75 \ Send Kafka Event authentication.events ${e}
76 ${start} = Get Time
77 Wait Until Keyword Succeeds ${timeout} 5s AuthCompleted
78 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
79 # TODO validate that:
80 # - subscriber status has changed
81 # - vOLT SI have been created and policed (we can't test sync'ed without a backend)
82 # - fabric-xconnect have been created and policed (we can't test sync'ed without a backend)
83 ${end} = Get Time
84 Log To Console Test started at: ${start}
85 Log To Console Test ended at: ${end}
86 ${duration} = Subtract Date From Date ${end} ${start}
87 Log To Console Test duration: ${duration}
88
89DHCP Subscribers
90 [Documentation] Send dhcp events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
91 ${events} = Generate Dhcp Events
92 : FOR ${e} IN @{events}
93 \ Send Kafka Event dhcp.events ${e}
94 ${start} = Get Time
95 Wait Until Keyword Succeeds ${timeout} 5s DHCPCompleted
96 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
97 # TODO validate that:
98 # - subscriber has an IP address
99 ${end} = Get Time
100 Log To Console Test started at: ${start}
101 Log To Console Test ended at: ${end}
102 ${duration} = Subtract Date From Date ${end} ${start}
103 Log To Console Test duration: ${duration}
104
Matteo Scandolo564009f2019-01-16 14:11:02 -0800105
106*** Keywords ***
107
108Validate ATT_SI Number
109 [Arguments] ${events}
110 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
111 ${jsondata} = To Json ${res.content}
112 ${length} = Get Length ${jsondata['items']}
113 ${total} = Get Length ${events}
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -0800114 Log To Console ${length} Service Instances created, expecting ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800115 Should Be Equal ${length} ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800116
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800117DHCPCompleted
118 [Documentation] Check that all ATT_SI have an ip address
Kailash2abefa82019-02-01 12:40:07 -0800119 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
120 ${jsondata} = To Json ${res.content}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800121 Log To Console Checking DHCP
Kailash2abefa82019-02-01 12:40:07 -0800122 : FOR ${i} IN @{jsondata['items']}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800123 \ Should Not Be Empty ${i['ip_address']}
124
125AuthCompleted
126 [Documentation] Check that all ATT_SI have status=authenticated
127 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
128 ${jsondata} = To Json ${res.content}
129 Log To Console Checking Authentication
130 : FOR ${i} IN @{jsondata['items']}
131 \ Should Be Equal ${i['authentication_state']} APPROVED
132
133ModelPolicy completed
134 # TODO make this method configurable to check model_policies on arbitrary models
135 [Documentation] Check that model_policies had run for all the items in the list
136 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
137 ${jsondata} = To Json ${res.content}
138 Log To Console Checking ModelPolicy
139 : FOR ${i} IN @{jsondata['items']}
140 \ Should Be True ${i['policed']} >= ${i['updated']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800141
142Setup
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800143 # TODO remove all JSON files that a previous run may have left around
Kailash48ef41a2019-03-05 13:08:37 -0800144 ${cord_kafka}= Get Environment Variable CORD_KAFKA_IP cord-kafka
Matteo Scandolo564009f2019-01-16 14:11:02 -0800145 ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
146 Log Testing with ${target} ONUs
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -0800147 Log To Console Testing with ${target} ONUs
Matteo Scandolo564009f2019-01-16 14:11:02 -0800148 Connect Producer ${cord_kafka}:9092 onu.events
149 Connect Producer ${cord_kafka}:9092 authentication.events
150 Connect Producer ${cord_kafka}:9092 dhcp.events
151 ${auth} = Create List admin@opencord.org letmein
152 ${HEADERS} Create Dictionary Content-Type=application/json allow_modify_feedback=True
153 Create Session XOS http://${xos_chameleon_url}:${xos_chameleon_port} auth=${AUTH} headers=${HEADERS}
154 Store Data
155 Mock Data
156 ${mock} = Get Mock Data
157 Log ${mock}
158
159Teardown
160 [Documentation] Delete all models created
161 Log Teardown
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800162 Log To Console Teardown
Matteo Scandolo564009f2019-01-16 14:11:02 -0800163 Delete OLTs
164 Delete Whitelist
165 Delete ServiceInstances
166 Delete All Sessions
167 Clean Storage
168
169Mock Data
170 [Documentation] Mock all the data needed from the test
171 Create Mock Olts ${num_olts} ${voltservice_id}
172 Create Olts
173 Create Mock Pon Ports ${num_pon_ports}
174 Create Pon Ports
175 Create Mock Onus ${num_onus}
176 Create Onus
177 Create Mock Unis
178 Create Unis
179 Create Whitelist
180
181Create Olts
182 [Documentation] Stub OLT for the test
183 ${olts} = Get Rest Olts
184 : FOR ${OLT} IN @{olts}
185 \ Log ${OLT}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800186 \ Log To Console Creating OLT ${OLT['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800187 \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT}
188 \ ${jsondata} = To Json ${res.content}
189 \ Update Olt Id ${OLT} ${jsondata['id']}
190
191Create Pon Ports
192 ${pon_ports} = Get Rest Pon Ports
193 : FOR ${port} IN @{pon_ports}
194 \ Log ${port}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800195 \ Log To Console Creating PON Port ${port['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800196 \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port}
197 \ ${jsondata} = To Json ${res.content}
198 \ Update Pon Port Id ${port} ${jsondata['id']}
199
200Create Onus
201 ${onus} = Get Rest Onus
202 : FOR ${onu} IN @{onus}
203 \ Log ${onu}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800204 \ Log To Console Creating ONU ${onu['serial_number']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800205 \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu}
206 \ ${jsondata} = To Json ${res.content}
207 \ Update Onu Id ${onu} ${jsondata['id']}
208
209Create Unis
210 ${unis} = Get Rest Unis
211 : FOR ${uni} IN @{unis}
212 \ Log ${uni}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800213 \ Log To Console Creating UNI ${uni['name']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800214 \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni}
215 \ ${jsondata} = To Json ${res.content}
216 \ Update Uni Id ${uni} ${jsondata['id']}
217
218Create Whitelist
219 [Documentation] Create a whitelist for the tests
220 ${whitelist} = Create Mock Whitelist ${attworkflowservice_id}
221 : FOR ${e} IN @{whitelist}
222 \ Log ${e}
Matteo Scandolo6ccc9902019-03-01 13:07:35 -0800223 \ Log To Console Creating Whitelist Entry ${e['serial_number']}
Matteo Scandolo564009f2019-01-16 14:11:02 -0800224 \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e}
225
226Delete Olts
227 [Documentation] Remove all the OLTs created for the test
228 ${res} = CORD Get /xosapi/v1/volt/oltdevices
229 ${jsondata} = To Json ${res.content}
230 :FOR ${ELEMENT} IN @{jsondata['items']}
231 \ ${id}= Get From Dictionary ${ELEMENT} id
232 \ CORD Delete /xosapi/v1/volt/oltdevices ${id}
233
234Delete Whitelist
235 [Documentation] Clean the whitelist
236 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
237 ${jsondata} = To Json ${res.content}
238 :FOR ${ELEMENT} IN @{jsondata['items']}
239 \ ${id}= Get From Dictionary ${ELEMENT} id
240 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${id}
241
242Delete ServiceInstances
243 [Documentation] Clean the whitelist
244 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
245 ${jsondata} = To Json ${res.content}
246 :FOR ${ELEMENT} IN @{jsondata['items']}
247 \ ${id}= Get From Dictionary ${ELEMENT} id
248 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances ${id}
249
250Store Data
251 [Documentation] Store all the ids needed for the test to work
252 # Get AttWorkflowDriverService id
253 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
254 ${jsondata}= To Json ${resp.content}
255 ${attworkflowservice}= Get From List ${jsondata['items']} 0
256 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
257 Set Suite Variable ${attworkflowservice_id}
258
259 # Get VoltService id
260 ${resp}= CORD Get /xosapi/v1/volt/voltservices
261 ${jsondata}= To Json ${resp.content}
262 ${voltservice}= Get From List ${jsondata['items']} 0
263 ${voltservice_id}= Get From Dictionary ${voltservice} id
264 Set Suite Variable ${voltservice_id}
265
266Send Kafka Event
267 [Documentation] Send event
268 [Arguments] ${topic} ${message}
269 Log Sending event
270 ${event}= evaluate json.dumps(${message}) json
271 Send ${topic} ${event}
272 Flush
273
274CORD Get
275 [Documentation] Make a GET call to XOS
276 [Arguments] ${service}
277 ${resp}= Get Request XOS ${service}
278 Log ${resp.content}
279 Should Be Equal As Strings ${resp.status_code} 200
280 [Return] ${resp}
281
282CORD Post
283 [Documentation] Make a POST call to XOS
284 [Arguments] ${service} ${data}
285 ${data}= Evaluate json.dumps(${data}) json
286 ${resp}= Post Request XOS uri=${service} data=${data}
287 Log ${resp.content}
288 Should Be Equal As Strings ${resp.status_code} 200
289 [Return] ${resp}
290
291CORD Delete
292 [Documentation] Make a DELETE call to the CORD controller
293 [Arguments] ${service} ${data_id}
294 ${resp}= Delete Request XOS uri=${service}/${data_id}
295 Log ${resp.content}
296 Should Be Equal As Strings ${resp.status_code} 200
Kailash2abefa82019-02-01 12:40:07 -0800297 [Return] ${resp}