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