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 |
| 9 | Library ./utils/devices.py |
| 10 | Suite Setup Setup |
| 11 | Suite 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 | |
| 26 | Check 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 | |
| 33 | Check 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 | |
| 40 | Check 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 | |
| 47 | Check 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 | |
| 54 | Check 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 | |
| 61 | Activate 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 | |
| 70 | Validate 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 | |
| 79 | ModelPolicy 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 | |
| 86 | Setup |
| 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 | |
| 100 | Teardown |
| 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 | |
| 109 | Mock 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 | |
| 121 | Create 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 | |
| 130 | Create 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 | |
| 138 | Create 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 | |
| 146 | Create 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 | |
| 154 | Create 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 | |
| 161 | Delete 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 | |
| 169 | Delete 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 | |
| 177 | Delete 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 | |
| 185 | Store 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 | |
| 201 | Send 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 | |
| 209 | CORD 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 | |
| 217 | CORD 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 | |
| 226 | CORD 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} |