blob: d084334bacc2d59abb996d97bfa76e8e7f73481e [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
9Library ./utils/devices.py
10Suite Setup Setup
11Suite Teardown Teardown
12
13*** Variables ***
14${xos_chameleon_url} xos-chameleon
15${xos_chameleon_port} 9101
16${cord_kafka} cord-kafka
17
18${num_olts} 1
19${num_pon_ports} 1
20${num_onus} 1
21
22${timeout} 300s
23
24*** Test Cases ***
25
26Check OLTs Created
27 ${res} = CORD Get /xosapi/v1/volt/oltdevices
28 ${jsondata} = To Json ${res.content}
29 ${length} = Get Length ${jsondata['items']}
30 ${total} = Convert To Integer ${num_olts}
31 Should Be Equal ${length} ${total}
32
33Check PON Ports Created
34 ${res} = CORD Get /xosapi/v1/volt/ponports
35 ${jsondata} = To Json ${res.content}
36 ${length} = Get Length ${jsondata['items']}
37 ${total} = Evaluate ${num_olts} * ${num_pon_ports}
38 Should Be Equal ${length} ${total}
39
40Check ONUs Created
41 ${res} = CORD Get /xosapi/v1/volt/onudevices
42 ${jsondata} = To Json ${res.content}
43 ${length} = Get Length ${jsondata['items']}
44 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
45 Should Be Equal ${length} ${total}
46
47Check UNI Ports Created
48 ${res} = CORD Get /xosapi/v1/volt/uniports
49 ${jsondata} = To Json ${res.content}
50 ${length} = Get Length ${jsondata['items']}
51 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
52 Should Be Equal ${length} ${total}
53
54Check Whitelist Created
55 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
56 ${jsondata} = To Json ${res.content}
57 ${length} = Get Length ${jsondata['items']}
58 ${total} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
59 Should Be Equal ${length} ${total}
60
61Activate ONUs
62 [Documentation] Send activation events for all the ONUs and waits for the model_policies of ATT Workflow Driver Service Instances to have completed
63 ${events} = Generate Onu Events
64 : FOR ${e} IN @{events}
65 \ Send Kafka Event onu.events ${e}
66 Wait Until Keyword Succeeds ${timeout} 5s Validate ATT_SI Number ${events}
67
68*** Keywords ***
69
70Validate ATT_SI Number
71 [Arguments] ${events}
72 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
73 ${jsondata} = To Json ${res.content}
74 ${length} = Get Length ${jsondata['items']}
75 ${total} = Get Length ${events}
76 Should Be Equal ${length} ${total}
77 ModelPolicy completed ${jsondata['items']}
78
79ModelPolicy completed
80 [Documentation] Check that model_policies had run for all the items in the list
81 [Arguments] ${list}
82 # NOTE we assume that here we get res.content["items"]
83 : FOR ${i} IN @{list}
84 \ Should Be Equal As Integers ${i["policy_code"]} 1
85
86Setup
87 ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus}
88 Log Testing with ${target} ONUs
89 Connect Producer ${cord_kafka}:9092 onu.events
90 Connect Producer ${cord_kafka}:9092 authentication.events
91 Connect Producer ${cord_kafka}:9092 dhcp.events
92 ${auth} = Create List admin@opencord.org letmein
93 ${HEADERS} Create Dictionary Content-Type=application/json allow_modify_feedback=True
94 Create Session XOS http://${xos_chameleon_url}:${xos_chameleon_port} auth=${AUTH} headers=${HEADERS}
95 Store Data
96 Mock Data
97 ${mock} = Get Mock Data
98 Log ${mock}
99
100Teardown
101 [Documentation] Delete all models created
102 Log Teardown
103 Delete OLTs
104 Delete Whitelist
105 Delete ServiceInstances
106 Delete All Sessions
107 Clean Storage
108
109Mock Data
110 [Documentation] Mock all the data needed from the test
111 Create Mock Olts ${num_olts} ${voltservice_id}
112 Create Olts
113 Create Mock Pon Ports ${num_pon_ports}
114 Create Pon Ports
115 Create Mock Onus ${num_onus}
116 Create Onus
117 Create Mock Unis
118 Create Unis
119 Create Whitelist
120
121Create Olts
122 [Documentation] Stub OLT for the test
123 ${olts} = Get Rest Olts
124 : FOR ${OLT} IN @{olts}
125 \ Log ${OLT}
126 \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT}
127 \ ${jsondata} = To Json ${res.content}
128 \ Update Olt Id ${OLT} ${jsondata['id']}
129
130Create Pon Ports
131 ${pon_ports} = Get Rest Pon Ports
132 : FOR ${port} IN @{pon_ports}
133 \ Log ${port}
134 \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port}
135 \ ${jsondata} = To Json ${res.content}
136 \ Update Pon Port Id ${port} ${jsondata['id']}
137
138Create Onus
139 ${onus} = Get Rest Onus
140 : FOR ${onu} IN @{onus}
141 \ Log ${onu}
142 \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu}
143 \ ${jsondata} = To Json ${res.content}
144 \ Update Onu Id ${onu} ${jsondata['id']}
145
146Create Unis
147 ${unis} = Get Rest Unis
148 : FOR ${uni} IN @{unis}
149 \ Log ${uni}
150 \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni}
151 \ ${jsondata} = To Json ${res.content}
152 \ Update Uni Id ${uni} ${jsondata['id']}
153
154Create Whitelist
155 [Documentation] Create a whitelist for the tests
156 ${whitelist} = Create Mock Whitelist ${attworkflowservice_id}
157 : FOR ${e} IN @{whitelist}
158 \ Log ${e}
159 \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e}
160
161Delete Olts
162 [Documentation] Remove all the OLTs created for the test
163 ${res} = CORD Get /xosapi/v1/volt/oltdevices
164 ${jsondata} = To Json ${res.content}
165 :FOR ${ELEMENT} IN @{jsondata['items']}
166 \ ${id}= Get From Dictionary ${ELEMENT} id
167 \ CORD Delete /xosapi/v1/volt/oltdevices ${id}
168
169Delete Whitelist
170 [Documentation] Clean the whitelist
171 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries
172 ${jsondata} = To Json ${res.content}
173 :FOR ${ELEMENT} IN @{jsondata['items']}
174 \ ${id}= Get From Dictionary ${ELEMENT} id
175 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${id}
176
177Delete ServiceInstances
178 [Documentation] Clean the whitelist
179 ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
180 ${jsondata} = To Json ${res.content}
181 :FOR ${ELEMENT} IN @{jsondata['items']}
182 \ ${id}= Get From Dictionary ${ELEMENT} id
183 \ CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances ${id}
184
185Store Data
186 [Documentation] Store all the ids needed for the test to work
187 # Get AttWorkflowDriverService id
188 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
189 ${jsondata}= To Json ${resp.content}
190 ${attworkflowservice}= Get From List ${jsondata['items']} 0
191 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
192 Set Suite Variable ${attworkflowservice_id}
193
194 # Get VoltService id
195 ${resp}= CORD Get /xosapi/v1/volt/voltservices
196 ${jsondata}= To Json ${resp.content}
197 ${voltservice}= Get From List ${jsondata['items']} 0
198 ${voltservice_id}= Get From Dictionary ${voltservice} id
199 Set Suite Variable ${voltservice_id}
200
201Send Kafka Event
202 [Documentation] Send event
203 [Arguments] ${topic} ${message}
204 Log Sending event
205 ${event}= evaluate json.dumps(${message}) json
206 Send ${topic} ${event}
207 Flush
208
209CORD Get
210 [Documentation] Make a GET call to XOS
211 [Arguments] ${service}
212 ${resp}= Get Request XOS ${service}
213 Log ${resp.content}
214 Should Be Equal As Strings ${resp.status_code} 200
215 [Return] ${resp}
216
217CORD Post
218 [Documentation] Make a POST call to XOS
219 [Arguments] ${service} ${data}
220 ${data}= Evaluate json.dumps(${data}) json
221 ${resp}= Post Request XOS uri=${service} data=${data}
222 Log ${resp.content}
223 Should Be Equal As Strings ${resp.status_code} 200
224 [Return] ${resp}
225
226CORD Delete
227 [Documentation] Make a DELETE call to the CORD controller
228 [Arguments] ${service} ${data_id}
229 ${resp}= Delete Request XOS uri=${service}/${data_id}
230 Log ${resp.content}
231 Should Be Equal As Strings ${resp.status_code} 200
232 [Return] ${resp}