Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Test various E2E conditions for seba-in-a-box |
| 17 | Suite Setup Setup |
| 18 | Suite Teardown Teardown |
| 19 | Library Collections |
| 20 | Library String |
| 21 | Library OperatingSystem |
| 22 | Library XML |
| 23 | Library RequestsLibrary |
| 24 | Library bbsim_utils.py |
| 25 | Library ../../Framework/utils/utils.py |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 26 | Library ../../Framework/restApi.py |
| 27 | Resource ../../Framework/Subscriber.robot |
| 28 | Resource ../../Framework/ATTWorkFlowDriver.robot |
| 29 | Resource ../../Framework/Kubernetes.robot |
| 30 | Resource ../../Framework/ONU.robot |
| 31 | Resource ../../Framework/DHCP.robot |
| 32 | Variables ../../Properties/RestApiProperties.py |
| 33 | |
| 34 | *** Variables *** |
| 35 | ${number_of_onus} 16 |
| 36 | |
| 37 | *** Test Cases *** |
| 38 | Create Subscriber and Whitelist for ONUs |
| 39 | [Documentation] Creates whitelists in ATT-WF for each onu device |
| 40 | [Tags] create |
| 41 | ${att_workflow_service_id}= Get Service Owner Id ${ATT_SERVICE} |
| 42 | ${volt_service_id}= Get Service Owner Id ${VOLT_SERVICE} |
| 43 | ${rcord_service_id}= Get Service Owner Id /xosapi/v1/rcord/rcordservices |
| 44 | CORD Post ${VOLT_DEVICE} {'device_type': 'openolt', 'host': 'bbsim.voltha.svc', 'port': 50060, 'switch_datapath_id': 'of:0000000000000002', 'switch_port': '3', 'outer_tpid': '0x8100', 'uplink': '65536', 'nas_id': 'NAS_ID', 'serial_number': 'bbsim.voltha.svc:50060', 'volt_service_id': ${volt_service_id}} |
| 45 | @{subscribers}= Generate Subscribers ${number_of_onus} ${rcord_service_id} |
| 46 | : FOR ${subscriber} IN @{subscribers} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 47 | \ CORD Post ${VOLT_SUBSCRIBER} ${subscriber} |
| 48 | @{whitelists}= Generate Whitelists ${number_of_onus} ${att_workflow_service_id} |
| 49 | : FOR ${whitelist} IN @{whitelists} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 50 | \ CORD Post ${ATT_WHITELIST} ${whitelist} |
| 51 | |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 52 | Validate ONUs in VOLTHA |
| 53 | [Tags] voltha |
| 54 | Wait Until Keyword Succeeds 120s 5s Validate Voltha ${number_of_onus} |
| 55 | |
| 56 | Validate ONUs in XOS |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 57 | [Documentation] Validates All ONU Devices are discovered and retrieve SNs |
| 58 | [Tags] onudiscovery |
| 59 | Wait Until Keyword Succeeds 120s 5s Validate Number of ONU Devices ${number_of_onus} |
| 60 | |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 61 | Validate ONU States in XOS |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 62 | [Documentation] Validates All ONU Device states are "enabled" and "active" |
| 63 | [Tags] onustates |
| 64 | : FOR ${onu} IN @{serial_numbers} |
| 65 | \ Wait Until Keyword Succeeds 120s 5s Validate ONU States ACTIVE ENABLED ${onu} |
| 66 | |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 67 | *** Keywords *** |
| 68 | Setup |
| 69 | ${server_ip}= Get Environment Variable SERVER_IP localhost |
| 70 | ${port}= Get Environment Variable SERVER_PORT 30001 |
| 71 | ${auth} = Create List ${XOS_USER} ${XOS_PASSWD} |
| 72 | ${HEADERS} Create Dictionary Content-Type=application/json |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 73 | Create Session XOS http://${server_ip}:${port} auth=${AUTH} headers=${HEADERS} |
| 74 | Create Session VOLTHA http://${server_ip}:30125 headers=${HEADERS} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 75 | @{container_list}= Create List |
| 76 | Append To List ${container_list} att-workflow-att-workflow-driver |
| 77 | Append To List ${container_list} seba-services-volt |
| 78 | Append To List ${container_list} seba-services-rcord |
| 79 | Append To List ${container_list} seba-services-fabric-crossconnect |
| 80 | Append To List ${container_list} seba-services-onos-service |
| 81 | Append To List ${container_list} xos-core |
| 82 | Append To List ${container_list} vcore |
| 83 | Set Suite Variable ${container_list} |
| 84 | |
| 85 | Teardown |
| 86 | Wait Until Keyword Succeeds 60s 2s Clean Up Objects ${VOLT_SUBSCRIBER} |
| 87 | Wait Until Keyword Succeeds 60s 2s Clean Up Objects ${ATT_WHITELIST} |
| 88 | Wait Until Keyword Succeeds 60s 2s Clean Up Objects ${VOLT_DEVICE} |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 89 | Wait Until Keyword Succeeds 60s 2s Clean Up Objects ${ATT_SERVICEINSTANCES} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 90 | Delete All Sessions |
| 91 | #Get Pod Logs |
| 92 | |
| 93 | Get Pod Logs |
| 94 | : FOR ${pod} IN @{container_list} |
| 95 | \ ${full_pod_name}= Run kubectl get pods --all-namespaces | grep '${pod}' | head -1 | awk '{print $2}' |
| 96 | \ ${namespace}= Run kubectl get pods --all-namespaces | grep ' ${pod}' | head -1 | awk '{print $1}' |
| 97 | \ ${output}= Run kubectl logs --timestamps -n ${namespace} ${full_pod_name} |
| 98 | \ Log ${output} |
| 99 | |
| 100 | Validate Number of ONU Devices |
| 101 | [Arguments] ${expected_onus} |
| 102 | ${resp}= CORD Get ${ONU_DEVICE} |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 103 | Validate ONUs in Response ${resp} ${expected_onus} |
| 104 | |
| 105 | Validate Voltha |
| 106 | [Arguments] ${expected_onus} |
| 107 | ${resp}= Get Request VOLTHA api/v1/devices |
| 108 | Log ${resp.content} |
| 109 | Should Be Equal As Strings ${resp.status_code} 200 |
| 110 | Validate ONUs in Response ${resp} ${expected_onus} |
| 111 | |
| 112 | Validate ONUs in Response |
| 113 | [Arguments] ${resp} ${expected_onus} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 114 | ${jsondata}= To Json ${resp.content} |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 115 | Should Not Be Empty ${jsondata['items']} |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 116 | ${length}= Get Length ${jsondata['items']} |
| 117 | @{serial_numbers}= Create List |
| 118 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 119 | \ ${value}= Get From List ${jsondata['items']} ${INDEX} |
| 120 | \ ${sn}= Get From Dictionary ${value} serial_number |
| 121 | \ ${contains}= Evaluate "BBSM" in """${sn}""" |
| 122 | \ Run Keyword if '${contains}' == 'True' Append To List ${serial_numbers} ${sn} |
| 123 | Set Suite Variable ${serial_numbers} |
| 124 | ${length_of_bbsim_onus}= Get Length ${serial_numbers} |
| 125 | Should Be Equal as Integers ${length_of_bbsim_onus} ${expected_onus} |
| 126 | |
Kailash | 498bf1c | 2019-03-18 21:05:05 -0700 | [diff] [blame^] | 127 | CORD Get |
| 128 | [Documentation] Make a GET call to XOS |
| 129 | [Arguments] ${service} |
| 130 | ${resp}= Get Request XOS ${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 XOS uri=${service} data=${data} |
| 140 | Log ${resp.content} |
| 141 | Should Be Equal As Strings ${resp.status_code} 200 |
| 142 | [Return] ${resp} |