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 |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 8 | Resource ../../Framework/utils/utils.robot |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 9 | Suite Setup Setup |
| 10 | Suite Teardown Teardown |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 11 | Test Template Send Event and Verify |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 12 | |
| 13 | *** Variables *** |
Kailash | 1b6595f | 2019-05-03 09:46:42 -0700 | [diff] [blame] | 14 | ${xos_chameleon_url} xos-chameleon |
| 15 | ${xos_chameleon_port} 30006 |
| 16 | ${subscriber_api} /xosapi/v1/rcord/rcordsubscribers |
| 17 | ${att_wf_api} /xosapi/v1/att-workflow-driver/attworkflowdriverservices |
| 18 | ${volt_api} /xosapi/v1/volt/voltservices |
| 19 | ${att_si_api} /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |
| 20 | ${att_whitelist_api} /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries |
| 21 | ${onu_device_api} /xosapi/v1/volt/onudevices |
| 22 | ${olt_api} /xosapi/v1/volt/oltdevices |
| 23 | ${pon_ports_api} /xosapi/v1/volt/ponports |
| 24 | ${uni_ports_api} /xosapi/v1/volt/uniports |
| 25 | ${onu_serial_no} onudevice123 |
| 26 | ${onu_invalid_sn} invalid_serial_no |
| 27 | ${deviceId} of:robot_test |
| 28 | ${ponportno} 10 |
| 29 | ${uniportno} 100 |
| 30 | ${mac_address} 00:AA:00:00:00:01 |
| 31 | ${ip_address} 192.168.3.5 |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 32 | |
| 33 | *** Test Cases *** |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 34 | Activate Non-Whitelisted ONU onu.events {'status': 'activated', 'serial_number': '${onu_invalid_sn}','uni_port_id': 100, 'of_dpid': '${deviceId}'} onu_serial_number=${onu_invalid_sn} onu_state=DISABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 35 | [Documentation] Validate that activating an ONU not in whitelist sets onu device to DISABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 36 | |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 37 | Activate Whitelisted ONU in Wrong Location onu.events {'status': 'activated', 'serial_number': '${onu_serial_no}','uni_port_id': 52, 'of_dpid': 'wrongofdpid'} onu_serial_number=${onu_serial_no} onu_state=DISABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 38 | [Documentation] Validate that activating an ONU in the whitelist but in the wrong location DISABLES the onu device |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 39 | |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 40 | Activate Whitelisted ONU onu.events {'status': 'activated', 'serial_number': '${onu_serial_no}','uni_port_id': ${uniportno}, 'of_dpid': '${deviceId}'} onu_serial_number=${onu_serial_no} onu_state=ENABLED |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 41 | [Documentation] Validate that activating an ONU in the whitelist creates a attworkflow-driver-serviceinstance |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 42 | |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 43 | Send Auth Request authentication.events {'authenticationState': 'APPROVED', 'deviceId': '${deviceId}','portNumber': ${uniportno}} onu_serial_number=${onu_serial_no} subscriber_state=enabled service_instance_state=APPROVED service_instance_count=1 service_instance_dhcp_state=AWAITING |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 44 | [Documentation] Validate that sending an auth request to the onu will enable the subscriber and create a service chain |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 45 | |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 46 | Send DHCP Request dhcp.events {'macAddress': '${mac_address}','ipAddress': '${ip_address}', 'deviceId': '${deviceId}', 'portNumber': ${uniportno}, 'messageType': 'DHCPACK'} onu_serial_number=${onu_serial_no} service_instance_state=APPROVED service_instance_dhcp_state=DHCPACK |
| 47 | [Documentation] Validate that sending an dhcp request to update the subscriber's mac+ip address |
| 48 | |
| 49 | Send Denied Auth Request authentication.events {'authenticationState': 'DENIED', 'deviceId': '${deviceId}','portNumber': ${uniportno}} onu_serial_number=${onu_serial_no} subscriber_state=auth-failed service_instance_state=DENIED service_instance_dhcp_state=DHCPACK |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 50 | [Documentation] Validate that denied auth request to the onu will disable the subscriber and remove a service chain |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 51 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 52 | Create New Whitelist Entry |
| 53 | [Documentation] Validate that creating a new whitelist entry for the "invalid" onu device will enable the onu |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 54 | [Template] None |
| 55 | ${resp}= CORD Post ${att_whitelist_api} {"serial_number": "${onu_invalid_sn}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 56 | ${whitelist_entry2_id}= Get Json Value ${resp.content} /id |
| 57 | Set Suite Variable ${whitelist_entry2_id} |
| 58 | Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} ENABLED |
| 59 | |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 60 | Remove Whitelist Entry |
| 61 | [Documentation] Validate that removing a whitelist entry for an onu device will disable the subscriber and remove it's service chain |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 62 | [Template] None |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 63 | CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id} |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 64 | Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed |
| 65 | 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] | 66 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 67 | *** Keywords *** |
| 68 | Setup |
Kailash | f09b0b9 | 2019-05-03 08:36:36 -0700 | [diff] [blame] | 69 | ${cord_kafka}= Get Environment Variable CORD_KAFKA_IP cord-kafka |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 70 | Connect Producer ${cord_kafka}:9092 onu.events |
| 71 | Connect Producer ${cord_kafka}:9092 authentication.events |
| 72 | Connect Producer ${cord_kafka}:9092 dhcp.events |
| 73 | ${auth} = Create List admin@opencord.org letmein |
| 74 | ${HEADERS} Create Dictionary Content-Type=application/json |
Kailash | 37727fa | 2019-05-03 10:30:01 -0700 | [diff] [blame] | 75 | Create Session ${xos_chameleon_url} http://${xos_chameleon_url}:${xos_chameleon_port} auth=${AUTH} headers=${HEADERS} |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 76 | Create OLT, ONU, Subscribers, and Whitelists |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 77 | |
| 78 | Teardown |
Kailash Khalasi | 8f42b32 | 2018-08-21 09:36:53 -0700 | [diff] [blame] | 79 | [Documentation] Delete all models created |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 80 | CORD Get /xosapi/v1/rcord/rcordsubscribers |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 81 | Clean Up Objects ${subscriber_api} |
| 82 | Clean Up Objects ${att_si_api} |
| 83 | Clean Up Objects ${subscriber_api} |
| 84 | Wait Until Keyword Succeeds 60s 1s Clean Up Objects ${olt_api} |
| 85 | Clean Up Objects ${att_whitelist_api} |
| 86 | |
| 87 | Create OLT, ONU, Subscribers, and Whitelists |
| 88 | [Documentation] Create two onu devices to be tested for valid/invalid paths |
| 89 | ${resp}= CORD Get ${volt_api} |
| 90 | ${jsondata}= To Json ${resp.content} |
| 91 | ${voltservice}= Get From List ${jsondata['items']} 0 |
| 92 | ${voltservice_id}= Get From Dictionary ${voltservice} id |
| 93 | ${resp}= CORD Get ${att_wf_api} |
| 94 | ${jsondata}= To Json ${resp.content} |
| 95 | ${attworkflowservice}= Get From List ${jsondata['items']} 0 |
| 96 | ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id |
| 97 | Set Suite Variable ${attworkflowservice_id} |
| 98 | ${resp}= CORD Post ${subscriber_api} {"onu_device": "${onu_serial_no}", "status": "pre-provisioned"} |
| 99 | ${subscriber_id}= Get Json Value ${resp.content} /id |
| 100 | Set Suite Variable ${subscriber_id} |
| 101 | ${resp}= CORD Post ${olt_api} {"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"} |
| 102 | ${oltdevice_id}= Get Json Value ${resp.content} /id |
| 103 | Set Suite Variable ${oltdevice_id} |
| 104 | ${resp}= CORD Post ${pon_ports_api} {"olt_device_id": ${oltdevice_id}, "port_no": "${ponportno}", "name": "testponport1"} |
| 105 | ${ponport_id}= Get Json Value ${resp.content} /id |
| 106 | Set Suite Variable ${ponport_id} |
| 107 | ${resp}= CORD Post ${onu_device_api} {"serial_number": "${onu_serial_no}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"} |
| 108 | ${onu_device1_id}= Get Json Value ${resp.content} /id |
| 109 | Set Suite Variable ${onu_device1_id} |
| 110 | ${resp}= CORD Post ${uni_ports_api} {"onu_device_id": "${onu_device1_id}", "port_no": ${uniportno}, "name": "testuniport"} |
| 111 | ${uni_port_id}= Get Json Value ${resp.content} /id |
| 112 | Set Suite Variable ${uni_port_id} |
| 113 | ${resp}= CORD Post ${onu_device_api} {"serial_number": "${onu_invalid_sn}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"} |
| 114 | ${onu_device2_id}= Get Json Value ${resp.content} /id |
| 115 | Set Suite Variable ${onu_device2_id} |
| 116 | ${resp}= CORD Post ${att_whitelist_api} {"serial_number": "${onu_serial_no}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}} |
| 117 | ${whitelist_entry_id}= Get Json Value ${resp.content} /id |
| 118 | Set Suite Variable ${whitelist_entry_id} |
| 119 | |
| 120 | Send Event and Verify |
| 121 | [Arguments] ${topic} ${event} ${onu_serial_number}=${EMPTY} ${onu_state}=${EMPTY} ${subscriber_state}=${EMPTY} ${service_instance_state}=${EMPTY} ${service_instance_count}=${EMPTY} ${service_instance_dhcp_state}=${EMPTY} |
| 122 | Send Kafka Event ${topic} ${event} |
| 123 | Run Keyword If '${topic}' == 'onu.events' Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_serial_number} ${onu_state} |
| 124 | Run Keyword If '${topic}' == 'authentication.events' Wait Until Keyword Succeeds 30s 5s Validate Subscriber Status ${onu_serial_number} ${subscriber_state} |
| 125 | Run Keyword If '${topic}' == 'authentication.events' Wait Until Keyword Succeeds 30s 5s Validate Subscriber Service Chain ${onu_serial_number} ${service_instance_count} |
| 126 | Run Keyword If '${topic}' == 'authentication.events' Wait Until Keyword Succeeds 30s 5s Validate ATT Service Instance ${onu_serial_number} ${service_instance_state} ${service_instance_dhcp_state} |
| 127 | Run Keyword If '${topic}' == 'dhcp.events' Wait Until Keyword Succeeds 30s 5s Validate ATT Service Instance ${onu_serial_number} ${service_instance_state} ${service_instance_dhcp_state} |
| 128 | Run Keyword If '${topic}' == 'dhcp.events' Wait Until Keyword Succeeds 30s 5s Validate Subscriber Settings ${onu_serial_number} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 129 | |
| 130 | Send Kafka Event |
| 131 | [Documentation] Send event |
| 132 | [Arguments] ${topic} ${message} |
| 133 | Log Sending event |
| 134 | ${event}= evaluate json.dumps(${message}) json |
| 135 | Send ${topic} ${event} |
| 136 | Flush |
| 137 | |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 138 | Validate ATT Service Instance |
| 139 | [Documentation] Validates the states in the ATT-WF-SI per onu |
| 140 | [Arguments] ${serial_no} ${auth_state} ${dhcp_state} |
Kailash | 37727fa | 2019-05-03 10:30:01 -0700 | [diff] [blame] | 141 | ${resp}= Get Request ${xos_chameleon_url} ${att_si_api} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 142 | Log ${resp.content} |
| 143 | Should Be Equal As Strings ${resp.status_code} 200 |
| 144 | ## validate sn exists |
| 145 | Should Contain ${resp.content} ${serial_no} |
| 146 | ${jsondata}= To Json ${resp.content} |
| 147 | Log ${jsondata} |
| 148 | ${length}= Get Length ${jsondata['items']} |
| 149 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 150 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 151 | \ ${id}= Get From Dictionary ${value} id |
| 152 | \ ${sn}= Get From Dictionary ${value} serial_number |
| 153 | \ ${as}= Get From Dictionary ${value} authentication_state |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 154 | \ ${dp}= Get From Dictionary ${value} dhcp_state |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 155 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 156 | Should Be Equal ${dp} ${dhcp_state} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 157 | Should Be Equal ${as} ${auth_state} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 158 | |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 159 | Validate Subscriber Status |
| 160 | [Arguments] ${serial_no} ${expected_status} |
| 161 | ${resp}= CORD Get ${subscriber_api} |
| 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 | \ ${status}= Get From Dictionary ${value} status |
| 168 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 169 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 170 | Should Be Equal ${status} ${expected_status} |
| 171 | |
| 172 | Validate Subscriber Service Chain |
Kailash Khalasi | c53eee9 | 2018-08-21 11:49:19 -0700 | [diff] [blame] | 173 | [Arguments] ${serial_no} ${expected_no_sc}=${EMPTY} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 174 | ${resp}= CORD Get ${subscriber_api} |
| 175 | ${jsondata}= To Json ${resp.content} |
| 176 | Log ${jsondata} |
| 177 | ${length}= Get Length ${jsondata['items']} |
| 178 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 179 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 180 | \ ${sl}= Get From Dictionary ${value} subscribed_links_ids |
Kailash Khalasi | 5cd95a5 | 2018-08-22 08:55:04 -0700 | [diff] [blame] | 181 | \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0 |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 182 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 183 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 184 | Run Keyword If '${expected_no_sc}' != '${EMPTY}' Should Not Be Equal As Strings ${result} FAIL |
| 185 | Run Keyword If '${expected_no_sc}' != '${EMPTY}' Should Not Be Empty ${result} ELSE Should Be Empty ${sl} |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 186 | |
| 187 | Validate ONU Device Status |
| 188 | [Arguments] ${serial_no} ${expected_status} |
| 189 | ${resp}= CORD Get ${onu_device_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 | \ ${status}= Get From Dictionary ${value} admin_state |
| 196 | \ ${sn}= Get From Dictionary ${value} serial_number |
| 197 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
| 198 | Should Be Equal ${status} ${expected_status} |
| 199 | |
| 200 | Validate Subscriber Settings |
| 201 | [Arguments] ${serial_no} |
| 202 | ${resp}= CORD Get ${subscriber_api} |
| 203 | ${jsondata}= To Json ${resp.content} |
| 204 | Log ${jsondata} |
| 205 | ${length}= Get Length ${jsondata['items']} |
| 206 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 207 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 208 | \ ${macAddress}= Get From Dictionary ${value} mac_address |
Kailash Khalasi | e6629eb | 2018-08-17 11:53:57 -0700 | [diff] [blame] | 209 | \ ${sn}= Get From Dictionary ${value} onu_device |
| 210 | \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop |
Kailash | 2dd4d9d | 2019-05-01 14:00:11 -0700 | [diff] [blame] | 211 | Should Be Equal ${macAddress} ${mac_address} |