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 | # need to increase modelpolicy creation timeout |
| 70 | Wait Until Keyword Succeeds ${timeout} 5s ModelPolicy completed |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 71 | ${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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 77 | |
| 78 | *** Keywords *** |
| 79 | |
| 80 | Validate 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 Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 86 | Log To Console ${length} Service Instances created, expecting ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 87 | Should Be Equal ${length} ${total} |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 88 | |
| 89 | ModelPolicy completed |
| 90 | [Documentation] Check that model_policies had run for all the items in the list |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 91 | # TODO print something to the console to notify the user that this test is still running |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 92 | ${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 Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 97 | |
| 98 | Setup |
| 99 | ${target} = Evaluate ${num_olts} * ${num_pon_ports} * ${num_onus} |
| 100 | Log Testing with ${target} ONUs |
Matteo Scandolo | 1a2f9dd | 2019-01-29 10:57:05 -0800 | [diff] [blame] | 101 | Log To Console Testing with ${target} ONUs |
Matteo Scandolo | 564009f | 2019-01-16 14:11:02 -0800 | [diff] [blame] | 102 | 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 | |
| 113 | Teardown |
| 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 | |
| 122 | Mock 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 | |
| 134 | Create 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 | |
| 143 | Create 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 | |
| 151 | Create 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 | |
| 159 | Create 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 | |
| 167 | Create 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 | |
| 174 | Delete 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 | |
| 182 | Delete 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 | |
| 190 | Delete 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 | |
| 198 | Store 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 | |
| 214 | Send 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 | |
| 222 | CORD 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 | |
| 230 | CORD 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 | |
| 239 | CORD 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 |
Kailash | 2abefa8 | 2019-02-01 12:40:07 -0800 | [diff] [blame] | 245 | [Return] ${resp} |