Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Scale up models in a SEBA deployment with no backends |
| 3 | Library KafkaLibrary |
| 4 | Library RequestsLibrary |
| 5 | Library HttpLibrary.HTTP |
| 6 | Library Collections |
| 7 | Library String |
| 8 | Library OperatingSystem |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 9 | Library DateTime |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 10 | Library ./utils/devices.py |
| 11 | Suite Setup Setup |
| 12 | Suite 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 | |
| 27 | Check 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 | |
| 34 | Check 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 | |
| 41 | Check 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 | |
| 48 | Check 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 | |
| 55 | Check 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 | |
| 62 | Activate 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 Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 67 | ${start} = Get Time |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 68 | Wait Until Keyword Succeeds ${timeout} 5s Validate ATT_SI Number ${events} |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 69 | Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 70 | ${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 Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 76 | Authenticate 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 | |
| 94 | DHCP 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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 110 | |
| 111 | *** Keywords *** |
| 112 | |
| 113 | Validate 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 Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 119 | Log To Console ${length} Service Instances created, expecting ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 120 | Should Be Equal ${length} ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 121 | |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 122 | DHCPCompleted |
| 123 | [Documentation] Check that all ATT_SI have an ip address |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 124 | ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |
| 125 | ${jsondata} = To Json ${res.content} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 126 | Log To Console Checking DHCP |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 127 | : FOR ${i} IN @{jsondata['items']} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 128 | \ Should Not Be Empty ${i['ip_address']} |
| 129 | |
| 130 | AuthCompleted |
| 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 | |
| 138 | ModelPolicy 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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 146 | |
| 147 | Setup |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 148 | # TODO remove all JSON files that a previous run may have left around |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 149 | ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus} |
| 150 | Log Testing with ${target} ONUs |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 151 | Log To Console Testing with ${target} ONUs |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 152 | 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 | |
| 163 | Teardown |
| 164 | [Documentation] Delete all models created |
| 165 | Log Teardown |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 166 | Log To Console Teardown |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 167 | Delete OLTs |
| 168 | Delete Whitelist |
| 169 | Delete ServiceInstances |
| 170 | Delete All Sessions |
| 171 | Clean Storage |
| 172 | |
| 173 | Mock 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 | |
| 185 | Create Olts |
| 186 | [Documentation] Stub OLT for the test |
| 187 | ${olts} = Get Rest Olts |
| 188 | : FOR ${OLT} IN @{olts} |
| 189 | \ Log ${OLT} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 190 | \ Log To Console Creating OLT ${OLT['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 191 | \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT} |
| 192 | \ ${jsondata} = To Json ${res.content} |
| 193 | \ Update Olt Id ${OLT} ${jsondata['id']} |
| 194 | |
| 195 | Create Pon Ports |
| 196 | ${pon_ports} = Get Rest Pon Ports |
| 197 | : FOR ${port} IN @{pon_ports} |
| 198 | \ Log ${port} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 199 | \ Log To Console Creating PON Port ${port['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 200 | \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port} |
| 201 | \ ${jsondata} = To Json ${res.content} |
| 202 | \ Update Pon Port Id ${port} ${jsondata['id']} |
| 203 | |
| 204 | Create Onus |
| 205 | ${onus} = Get Rest Onus |
| 206 | : FOR ${onu} IN @{onus} |
| 207 | \ Log ${onu} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 208 | \ Log To Console Creating ONU ${onu['serial_number']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 209 | \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu} |
| 210 | \ ${jsondata} = To Json ${res.content} |
| 211 | \ Update Onu Id ${onu} ${jsondata['id']} |
| 212 | |
| 213 | Create Unis |
| 214 | ${unis} = Get Rest Unis |
| 215 | : FOR ${uni} IN @{unis} |
| 216 | \ Log ${uni} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 217 | \ Log To Console Creating UNI ${uni['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 218 | \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni} |
| 219 | \ ${jsondata} = To Json ${res.content} |
| 220 | \ Update Uni Id ${uni} ${jsondata['id']} |
| 221 | |
| 222 | Create 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 Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame^] | 227 | \ Log To Console Creating Whitelist Entry ${e['serial_number']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 228 | \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e} |
| 229 | |
| 230 | Delete 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 | |
| 238 | Delete 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 | |
| 246 | Delete 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 | |
| 254 | Store 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 | |
| 270 | Send 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 | |
| 278 | CORD 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 | |
| 286 | CORD 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 | |
| 295 | CORD 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 |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 301 | [Return] ${resp} |