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 |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 17 | ${num_olts} 1 |
| 18 | ${num_pon_ports} 1 |
| 19 | ${num_onus} 1 |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 20 | ${timeout} 300s |
| 21 | |
| 22 | *** Test Cases *** |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 23 | Check 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 | |
| 30 | Check 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 | |
| 37 | Check 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 | |
| 44 | Check 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 | |
| 51 | Check 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 | |
| 58 | Activate 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 Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 63 | ${start} = Get Time |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 64 | Wait Until Keyword Succeeds ${timeout} 5s Validate ATT_SI Number ${events} |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 65 | Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 66 | ${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 Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 72 | Authenticate 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 | |
| 90 | DHCP 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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 106 | |
| 107 | *** Keywords *** |
| 108 | |
| 109 | Validate 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 Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 115 | Log To Console ${length} Service Instances created, expecting ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 116 | Should Be Equal ${length} ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 117 | |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 118 | DHCPCompleted |
| 119 | [Documentation] Check that all ATT_SI have an ip address |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 120 | ${res} = CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |
| 121 | ${jsondata} = To Json ${res.content} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 122 | Log To Console Checking DHCP |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 123 | : FOR ${i} IN @{jsondata['items']} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 124 | \ Should Not Be Empty ${i['ip_address']} |
| 125 | |
| 126 | AuthCompleted |
| 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 | |
| 134 | ModelPolicy 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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 142 | |
| 143 | Setup |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 144 | # TODO remove all JSON files that a previous run may have left around |
Kailash | 48ef41a | 2019-03-05 13:08:37 -0800 | [diff] [blame] | 145 | ${cord_kafka}= Get Environment Variable CORD_KAFKA_IP cord-kafka |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 146 | ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus} |
| 147 | Log Testing with ${target} ONUs |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 148 | Log To Console Testing with ${target} ONUs |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 149 | 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 | |
| 160 | Teardown |
| 161 | [Documentation] Delete all models created |
| 162 | Log Teardown |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 163 | Log To Console Teardown |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 164 | Delete OLTs |
| 165 | Delete Whitelist |
| 166 | Delete ServiceInstances |
| 167 | Delete All Sessions |
| 168 | Clean Storage |
| 169 | |
| 170 | Mock 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 | |
| 182 | Create Olts |
| 183 | [Documentation] Stub OLT for the test |
| 184 | ${olts} = Get Rest Olts |
| 185 | : FOR ${OLT} IN @{olts} |
| 186 | \ Log ${OLT} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 187 | \ Log To Console Creating OLT ${OLT['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 188 | \ ${res} = CORD Post /xosapi/v1/volt/oltdevices ${OLT} |
| 189 | \ ${jsondata} = To Json ${res.content} |
| 190 | \ Update Olt Id ${OLT} ${jsondata['id']} |
| 191 | |
| 192 | Create Pon Ports |
| 193 | ${pon_ports} = Get Rest Pon Ports |
| 194 | : FOR ${port} IN @{pon_ports} |
| 195 | \ Log ${port} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 196 | \ Log To Console Creating PON Port ${port['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 197 | \ ${res} = CORD Post /xosapi/v1/volt/ponports ${port} |
| 198 | \ ${jsondata} = To Json ${res.content} |
| 199 | \ Update Pon Port Id ${port} ${jsondata['id']} |
| 200 | |
| 201 | Create Onus |
| 202 | ${onus} = Get Rest Onus |
| 203 | : FOR ${onu} IN @{onus} |
| 204 | \ Log ${onu} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 205 | \ Log To Console Creating ONU ${onu['serial_number']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 206 | \ ${res} = CORD Post /xosapi/v1/volt/onudevices ${onu} |
| 207 | \ ${jsondata} = To Json ${res.content} |
| 208 | \ Update Onu Id ${onu} ${jsondata['id']} |
| 209 | |
| 210 | Create Unis |
| 211 | ${unis} = Get Rest Unis |
| 212 | : FOR ${uni} IN @{unis} |
| 213 | \ Log ${uni} |
Matteo Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 214 | \ Log To Console Creating UNI ${uni['name']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 215 | \ ${res} = CORD Post /xosapi/v1/volt/uniports ${uni} |
| 216 | \ ${jsondata} = To Json ${res.content} |
| 217 | \ Update Uni Id ${uni} ${jsondata['id']} |
| 218 | |
| 219 | Create 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 Scandolo | 6ccc990 | 2019-03-01 13:07:35 -0800 | [diff] [blame] | 224 | \ Log To Console Creating Whitelist Entry ${e['serial_number']} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 225 | \ ${res} = CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${e} |
| 226 | |
| 227 | Delete 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 | |
| 235 | Delete 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 | |
| 243 | Delete 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 | |
| 251 | Store 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 | |
| 267 | Send 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 | |
| 275 | CORD 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 | |
| 283 | CORD 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 | |
| 292 | CORD 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 |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 298 | [Return] ${resp} |