Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library KafkaLibrary |
| 3 | Library RequestsLibrary |
| 4 | Library HttpLibrary.HTTP |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library OperatingSystem |
| 8 | Suite Setup Setup |
| 9 | Suite Teardown Teardown |
| 10 | |
| 11 | *** Variables *** |
| 12 | ${cord_kafka} cord-kafka |
| 13 | ${server_ip} xos-chameleon |
| 14 | ${server_port} 9101 |
| 15 | ${subscriber_api} /xosapi/v1/rcord/rcordsubscribers |
| 16 | ${att_si_api} /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |
| 17 | ${onu_device_api} /xosapi/v1/volt/onudevices |
| 18 | ${onu_serial_no} onudevice123 |
| 19 | ${onu_invalid_sn} invalid_serial_no |
| 20 | ${mac_address} 00:AA:00:00:00:01 |
| 21 | ${ip_address} 192.168.3.5 |
| 22 | ${deviceId} of:robot_test |
| 23 | ${ponportno} 10 |
| 24 | ${uniportno} 100 |
| 25 | |
| 26 | *** Test Cases *** |
| 27 | Create Two ONU Devices |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 28 | [Documentation] Create two onu devices to be tested for valid/invalid paths |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 29 | ${resp}= CORD Get /xosapi/v1/volt/voltservices |
| 30 | ${jsondata}= To Json ${resp.content} |
| 31 | ${voltservice}= Get From List ${jsondata['items']} 0 |
| 32 | ${voltservice_id}= Get From Dictionary ${voltservice} id |
| 33 | ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices |
| 34 | ${jsondata}= To Json ${resp.content} |
| 35 | ${attworkflowservice}= Get From List ${jsondata['items']} 0 |
| 36 | ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id |
| 37 | Set Suite Variable ${attworkflowservice_id} |
| 38 | ${resp}= CORD Post /xosapi/v1/rcord/rcordsubscribers {"onu_device": "${onu_serial_no}", "status": "pre-provisioned"} |
| 39 | ${subscriber_id}= Get Json Value ${resp.content} /id |
| 40 | Set Suite Variable ${subscriber_id} |
Kailash Khalasi | 1fefd6a | 2018-09-05 15:00:20 -0700 | [diff] [blame] | 41 | ${resp}= CORD Post /xosapi/v1/volt/oltdevices {"volt_service_id": ${voltservice_id}, "name": "testoltdevice1", "device_type": "ponism", "host": "172.17.0.1", "port": 50060, "switch_port": "1", "dp_id": "${deviceId}", "outer_tpid": "0x8100", "uplink": "128"} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 42 | ${oltdevice_id}= Get Json Value ${resp.content} /id |
| 43 | Set Suite Variable ${oltdevice_id} |
| 44 | ${resp}= CORD Post /xosapi/v1/volt/ponports {"olt_device_id": ${oltdevice_id}, "port_no": "${ponportno}", "name": "testponport1"} |
| 45 | ${ponport_id}= Get Json Value ${resp.content} /id |
| 46 | Set Suite Variable ${ponport_id} |
| 47 | ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_serial_no}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"} |
| 48 | ${onu_device1_id}= Get Json Value ${resp.content} /id |
| 49 | Set Suite Variable ${onu_device1_id} |
| 50 | ${resp}= CORD Post /xosapi/v1/volt/uniports {"onu_device_id": "${onu_device1_id}", "port_no": ${uniportno}, "name": "testuniport"} |
| 51 | ${uni_port_id}= Get Json Value ${resp.content} /id |
| 52 | Set Suite Variable ${uni_port_id} |
| 53 | ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_invalid_sn}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"} |
| 54 | ${onu_device2_id}= Get Json Value ${resp.content} /id |
| 55 | Set Suite Variable ${onu_device2_id} |
| 56 | ${resp}= CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries {"serial_number": "${onu_serial_no}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}} |
| 57 | ${whitelist_entry_id}= Get Json Value ${resp.content} /id |
| 58 | Set Suite Variable ${whitelist_entry_id} |
| 59 | |
| 60 | Activate Non-Whitelisted ONU |
| 61 | [Documentation] Validate that activating an ONU not in whitelist sets onu device to DISABLED |
Hardik Windlass | 3638c61 | 2019-03-30 20:46:02 +0530 | [diff] [blame^] | 62 | Send Kafka Event onu.events {'status': 'activated','serialNumber': '${onu_invalid_sn}','portNumber': ${uniportno}, 'deviceId': '${deviceId}'} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 63 | Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} DISABLED |
| 64 | |
| 65 | Activate Whitelisted ONU in Wrong Location |
| 66 | [Documentation] Validate that activating an ONU in the whitelist but in the wrong location DISABLES the onu device |
Hardik Windlass | 3638c61 | 2019-03-30 20:46:02 +0530 | [diff] [blame^] | 67 | Send Kafka Event onu.events {'status': 'activated', 'serialNumber': '${onu_serial_no}','portNumber': 52, 'deviceId': 'wrongofdpid'} |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 68 | Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_serial_no} DISABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 69 | |
| 70 | Activate Whitelisted ONU |
| 71 | [Documentation] Validate that activating an ONU in the whitelist creates a attworkflow-driver-serviceinstance |
Hardik Windlass | 3638c61 | 2019-03-30 20:46:02 +0530 | [diff] [blame^] | 72 | Send Kafka Event onu.events {'status': 'activated','serialNumber': '${onu_serial_no}','portNumber': ${uniportno}, 'deviceId': '${deviceId}'} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 73 | ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} AWAITING |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 74 | Wait Until Keyword Succeeds 60s 5s Validate ONU Device Status ${onu_serial_no} ENABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 75 | |
| 76 | Send Auth Request |
| 77 | [Documentation] Validate that sending an auth request to the onu will enable the subscriber and create a service chain |
| 78 | Send Kafka Event authentication.events {'authenticationState': 'APPROVED', 'deviceId': '${deviceId}','portNumber': ${uniportno}} |
| 79 | Wait Until Keyword Succeeds 30s 5s Validate Subscriber Status ${onu_serial_no} enabled |
| 80 | Wait Until Keyword Succeeds 30s 5s Validate Subscriber Service Chain ${onu_serial_no} 1 |
| 81 | ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} APPROVED |
| 82 | |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 83 | Send Denied Auth Request |
| 84 | [Documentation] Validate that denied auth request to the onu will disable the subscriber and remove a service chain |
| 85 | Send Kafka Event authentication.events {'authenticationState': 'DENIED', 'deviceId': '${deviceId}','portNumber': ${uniportno}} |
| 86 | Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed |
| 87 | Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no} |
| 88 | ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} DENIED |
| 89 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 90 | Create New Whitelist Entry |
| 91 | [Documentation] Validate that creating a new whitelist entry for the "invalid" onu device will enable the onu |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 92 | ${resp}= CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries {"serial_number": "${onu_invalid_sn}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}} |
| 93 | ${whitelist_entry2_id}= Get Json Value ${resp.content} /id |
| 94 | Set Suite Variable ${whitelist_entry2_id} |
| 95 | Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} ENABLED |
| 96 | |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 97 | Remove Whitelist Entry |
| 98 | [Documentation] Validate that removing a whitelist entry for an onu device will disable the subscriber and remove it's service chain |
| 99 | CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id} |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 100 | Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed |
| 101 | Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no} |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 102 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 103 | *** Keywords *** |
| 104 | Setup |
| 105 | Connect Producer ${cord_kafka}:9092 onu.events |
| 106 | Connect Producer ${cord_kafka}:9092 authentication.events |
| 107 | Connect Producer ${cord_kafka}:9092 dhcp.events |
| 108 | ${auth} = Create List admin@opencord.org letmein |
| 109 | ${HEADERS} Create Dictionary Content-Type=application/json |
| 110 | Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS} |
| 111 | |
| 112 | Teardown |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 113 | [Documentation] Delete all models created |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 114 | CORD Get /xosapi/v1/rcord/rcordsubscribers |
| 115 | CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id} |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 116 | Wait Until Keyword Succeeds 60s 5s CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 117 | CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id} |
| 118 | |
| 119 | Send Kafka Event |
| 120 | [Documentation] Send event |
| 121 | [Arguments] ${topic} ${message} |
| 122 | Log Sending event |
| 123 | ${event}= evaluate json.dumps(${message}) json |
| 124 | Send ${topic} ${event} |
| 125 | Flush |
| 126 | |
| 127 | CORD Get |
| 128 | [Documentation] Make a GET call to XOS |
| 129 | [Arguments] ${service} |
| 130 | ${resp}= Get Request ${server_ip} ${service} |
| 131 | Log ${resp.content} |
| 132 | Should Be Equal As Strings ${resp.status_code} 200 |
| 133 | [Return] ${resp} |
| 134 | |
| 135 | CORD Post |
| 136 | [Documentation] Make a POST call to XOS |
| 137 | [Arguments] ${service} ${data} |
| 138 | ${data}= Evaluate json.dumps(${data}) json |
| 139 | ${resp}= Post Request ${server_ip} uri=${service} data=${data} |
| 140 | Log ${resp.content} |
| 141 | Should Be Equal As Strings ${resp.status_code} 200 |
| 142 | ${id}= Get Json Value ${resp.content} /id |
| 143 | Set Suite Variable ${id} |
| 144 | [Return] ${resp} |
| 145 | |
| 146 | CORD Delete |
| 147 | [Documentation] Make a DELETE call to the CORD controller |
| 148 | [Arguments] ${service} ${data_id} |
| 149 | ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id} |
| 150 | Log ${resp.content} |
| 151 | Should Be Equal As Strings ${resp.status_code} 200 |
| 152 | [Return] ${resp} |
| 153 | |
| 154 | Get ATT Service Instance ID |
| 155 | [Documentation] Returns the id of the newly created onu's att workflow service instance |
| 156 | [Arguments] ${serial_no} ${auth_state} |
| 157 | ${resp}= Get Request ${server_ip} ${att_si_api} |
| 158 | Log ${resp.content} |
| 159 | Should Be Equal As Strings ${resp.status_code} 200 |
| 160 | ## validate sn exists |
| 161 | Should Contain ${resp.content} ${serial_no} |
| 162 | ${jsondata}= To Json ${resp.content} |
| 163 | Log ${jsondata} |
| 164 | ${length}= Get Length ${jsondata['items']} |
| 165 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 166 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 167 | \ ${id}= Get From Dictionary ${value} id |
| 168 | \ ${sn}= Get From Dictionary ${value} serial_number |
| 169 | \ ${as}= Get From Dictionary ${value} authentication_state |
| 170 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 171 | Should Be Equal ${as} ${auth_state} |
| 172 | [Return] ${id} |
| 173 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 174 | Validate Subscriber Status |
| 175 | [Arguments] ${serial_no} ${expected_status} |
| 176 | ${resp}= CORD Get ${subscriber_api} |
| 177 | ${jsondata}= To Json ${resp.content} |
| 178 | Log ${jsondata} |
| 179 | ${length}= Get Length ${jsondata['items']} |
| 180 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 181 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 182 | \ ${status}= Get From Dictionary ${value} status |
| 183 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 184 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 185 | Should Be Equal ${status} ${expected_status} |
| 186 | |
| 187 | Validate Subscriber Service Chain |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 188 | [Arguments] ${serial_no} ${expected_no_sc}=${EMPTY} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 189 | ${resp}= CORD Get ${subscriber_api} |
| 190 | ${jsondata}= To Json ${resp.content} |
| 191 | Log ${jsondata} |
| 192 | ${length}= Get Length ${jsondata['items']} |
| 193 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 194 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 195 | \ ${sl}= Get From Dictionary ${value} subscribed_links_ids |
Kailash Khalasi | 5cd95a5 | 2018-08-22 08:55:04 -0700 | [diff] [blame] | 196 | \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0 |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 197 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 198 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 199 | Run Keyword If '${expected_no_sc}' != '${EMPTY}' Should Be Equal As Integers ${slinks} ${expected_no_sc} ELSE Should Be Empty ${sl} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 200 | |
| 201 | Validate ONU Device Status |
| 202 | [Arguments] ${serial_no} ${expected_status} |
| 203 | ${resp}= CORD Get ${onu_device_api} |
| 204 | ${jsondata}= To Json ${resp.content} |
| 205 | Log ${jsondata} |
| 206 | ${length}= Get Length ${jsondata['items']} |
| 207 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 208 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 209 | \ ${status}= Get From Dictionary ${value} admin_state |
| 210 | \ ${sn}= Get From Dictionary ${value} serial_number |
| 211 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 212 | Should Be Equal ${status} ${expected_status} |
| 213 | |
| 214 | Validate Subscriber Settings |
| 215 | [Arguments] ${serial_no} |
| 216 | ${resp}= CORD Get ${subscriber_api} |
| 217 | ${jsondata}= To Json ${resp.content} |
| 218 | Log ${jsondata} |
| 219 | ${length}= Get Length ${jsondata['items']} |
| 220 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 221 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 222 | \ ${macAddress}= Get From Dictionary ${value} mac_address |
| 223 | \ ${ipAddress}= Get From Dictionary ${value} ip_address |
| 224 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 225 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 226 | Should Be Equal ${macAddress} ${mac_address} |
Kailash Khalasi | 80e27db | 2018-08-20 16:58:47 -0700 | [diff] [blame] | 227 | Should Be Equal ${ipAddress} ${ip_address} |