blob: a2bae1a26046243c5c30d3ceab049991c6b2ee2f [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 # need to increase modelpolicy creation timeout
70 Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080071 ${end} = Get Time
72 Log To Console Test started at: ${start}
73 Log To Console Test ended at: ${end}
74 ${duration} = Subtract Date From Date ${end} ${start}
75 Log To Console Test duration: ${duration}
76
Matteo Scandolo564009f2019-01-16 14:11:02 -080077
78*** Keywords ***
79
80Validate ATT_SI Number
81 [Arguments] ${events}
82 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
83 ${jsondata} = To Json ${res.content}
84 ${length} = Get Length ${jsondata['items']}
85 ${total} = Get Length ${events}
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080086 Log To Console ${length} Service Instances created, expecting ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -080087 Should Be Equal ${length} ${total}
Matteo Scandolo564009f2019-01-16 14:11:02 -080088
89ModelPolicy completed
90 [Documentation] Check that model_policies had run for all the items in the list
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -080091 # TODO print something to the console to notify the user that this test is still running
Kailash2abefa82019-02-01 12:40:07 -080092 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
93 ${jsondata} = To Json ${res.content}
94 : FOR ${i} IN @{jsondata['items']}
95 \ Should Be Equal As Integers ${i['policy_code']} 1
96 \ Log To Console \n Waiting for model_policies to run for all Service Instance
Matteo Scandolo564009f2019-01-16 14:11:02 -080097
98Setup
99 ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
100 Log Testing with ${target} ONUs
Matteo Scandolo1a2f9dd2019-01-29 10:57:05 -0800101 Log To Console Testing with ${target} ONUs
Matteo Scandolo564009f2019-01-16 14:11:02 -0800102 Connect Producer ${cord_kafka}:9092 onu.events
103 Connect Producer ${cord_kafka}:9092 authentication.events
104 Connect Producer ${cord_kafka}:9092 dhcp.events
105 ${auth} = Create List admin@opencord.org letmein
106 ${HEADERS} Create Dictionary Content-Type=application/json allow_modify_feedback=True
107 Create Session XOS http://${xos_chameleon_url}:${xos_chameleon_port} auth=${AUTH} headers=${HEADERS}
108 Store Data
109 Mock Data
110 ${mock} = Get Mock Data
111 Log ${mock}
112
113Teardown
114 [Documentation] Delete all models created
115 Log Teardown
116 Delete OLTs
117 Delete Whitelist
118 Delete ServiceInstances
119 Delete All Sessions
120 Clean Storage
121
122Mock Data
123 [Documentation] Mock all the data needed from the test
124 Create Mock Olts ${num_olts} ${voltservice_id}
125 Create Olts
126 Create Mock Pon Ports ${num_pon_ports}
127 Create Pon Ports
128 Create Mock Onus ${num_onus}
129 Create Onus
130 Create Mock Unis
131 Create Unis
132 Create Whitelist
133
134Create Olts
135 [Documentation] Stub OLT for the test
136 ${olts} = Get Rest Olts
137 : FOR ${OLT} IN @{olts}
138 \ Log ${OLT}
139 \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT}
140 \ ${jsondata} = To Json ${res.content}
141 \ Update Olt Id ${OLT} ${jsondata['id']}
142
143Create Pon Ports
144 ${pon_ports} = Get Rest Pon Ports
145 : FOR ${port} IN @{pon_ports}
146 \ Log ${port}
147 \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port}
148 \ ${jsondata} = To Json ${res.content}
149 \ Update Pon Port Id ${port} ${jsondata['id']}
150
151Create Onus
152 ${onus} = Get Rest Onus
153 : FOR ${onu} IN @{onus}
154 \ Log ${onu}
155 \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu}
156 \ ${jsondata} = To Json ${res.content}
157 \ Update Onu Id ${onu} ${jsondata['id']}
158
159Create Unis
160 ${unis} = Get Rest Unis
161 : FOR ${uni} IN @{unis}
162 \ Log ${uni}
163 \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni}
164 \ ${jsondata} = To Json ${res.content}
165 \ Update Uni Id ${uni} ${jsondata['id']}
166
167Create Whitelist
168 [Documentation] Create a whitelist for the tests
169 ${whitelist} = Create Mock Whitelist ${attworkflowservice_id}
170 : FOR ${e} IN @{whitelist}
171 \ Log ${e}
172 \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e}
173
174Delete Olts
175 [Documentation] Remove all the OLTs created for the test
176 ${res} = CORD Get /xosapi/v1/volt/oltdevices
177 ${jsondata} = To Json ${res.content}
178 :FOR ${ELEMENT} IN @{jsondata['items']}
179 \ ${id}= Get From Dictionary ${ELEMENT} id
180 \ CORD Delete /xosapi/v1/volt/oltdevices ${id}
181
182Delete Whitelist
183 [Documentation] Clean the whitelist
184 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
185 ${jsondata} = To Json ${res.content}
186 :FOR ${ELEMENT} IN @{jsondata['items']}
187 \ ${id}= Get From Dictionary ${ELEMENT} id
188 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${id}
189
190Delete ServiceInstances
191 [Documentation] Clean the whitelist
192 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
193 ${jsondata} = To Json ${res.content}
194 :FOR ${ELEMENT} IN @{jsondata['items']}
195 \ ${id}= Get From Dictionary ${ELEMENT} id
196 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances ${id}
197
198Store Data
199 [Documentation] Store all the ids needed for the test to work
200 # Get AttWorkflowDriverService id
201 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
202 ${jsondata}= To Json ${resp.content}
203 ${attworkflowservice}= Get From List ${jsondata['items']} 0
204 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
205 Set Suite Variable ${attworkflowservice_id}
206
207 # Get VoltService id
208 ${resp}= CORD Get /xosapi/v1/volt/voltservices
209 ${jsondata}= To Json ${resp.content}
210 ${voltservice}= Get From List ${jsondata['items']} 0
211 ${voltservice_id}= Get From Dictionary ${voltservice} id
212 Set Suite Variable ${voltservice_id}
213
214Send Kafka Event
215 [Documentation] Send event
216 [Arguments] ${topic} ${message}
217 Log Sending event
218 ${event}= evaluate json.dumps(${message}) json
219 Send ${topic} ${event}
220 Flush
221
222CORD Get
223 [Documentation] Make a GET call to XOS
224 [Arguments] ${service}
225 ${resp}= Get Request XOS ${service}
226 Log ${resp.content}
227 Should Be Equal As Strings ${resp.status_code} 200
228 [Return] ${resp}
229
230CORD Post
231 [Documentation] Make a POST call to XOS
232 [Arguments] ${service} ${data}
233 ${data}= Evaluate json.dumps(${data}) json
234 ${resp}= Post Request XOS uri=${service} data=${data}
235 Log ${resp.content}
236 Should Be Equal As Strings ${resp.status_code} 200
237 [Return] ${resp}
238
239CORD Delete
240 [Documentation] Make a DELETE call to the CORD controller
241 [Arguments] ${service} ${data_id}
242 ${resp}= Delete Request XOS uri=${service}/${data_id}
243 Log ${resp.content}
244 Should Be Equal As Strings ${resp.status_code} 200
Kailash2abefa82019-02-01 12:40:07 -0800245 [Return] ${resp}