blob: 29a52e92ab29fefb42943dcc68861fe540f7f338 [file] [log] [blame]
Kailash22179672019-03-18 20:24:55 -07001# 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 ***
16Documentation Test various E2E conditions for seba-in-a-box
17Suite Setup Setup
18Suite Teardown Teardown
19Library Collections
20Library String
21Library OperatingSystem
22Library XML
23Library RequestsLibrary
24Library bbsim_utils.py
25Library ../../Framework/utils/utils.py
Kailash22179672019-03-18 20:24:55 -070026Library ../../Framework/restApi.py
27Resource ../../Framework/Subscriber.robot
28Resource ../../Framework/ATTWorkFlowDriver.robot
29Resource ../../Framework/Kubernetes.robot
30Resource ../../Framework/ONU.robot
31Resource ../../Framework/DHCP.robot
32Variables ../../Properties/RestApiProperties.py
33
34*** Variables ***
35${number_of_onus} 16
36
37*** Test Cases ***
38Create 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}
Kailash22179672019-03-18 20:24:55 -070047 \ CORD Post ${VOLT_SUBSCRIBER} ${subscriber}
48 @{whitelists}= Generate Whitelists ${number_of_onus} ${att_workflow_service_id}
49 : FOR ${whitelist} IN @{whitelists}
Kailash22179672019-03-18 20:24:55 -070050 \ CORD Post ${ATT_WHITELIST} ${whitelist}
51
Kailash498bf1c2019-03-18 21:05:05 -070052Validate ONUs in VOLTHA
53 [Tags] voltha
54 Wait Until Keyword Succeeds 120s 5s Validate Voltha ${number_of_onus}
55
56Validate ONUs in XOS
Kailash22179672019-03-18 20:24:55 -070057 [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
Kailash498bf1c2019-03-18 21:05:05 -070061Validate ONU States in XOS
Kailash22179672019-03-18 20:24:55 -070062 [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
Kailash22179672019-03-18 20:24:55 -070067*** Keywords ***
68Setup
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
Kailash498bf1c2019-03-18 21:05:05 -070073 Create Session XOS http://${server_ip}:${port} auth=${AUTH} headers=${HEADERS}
74 Create Session VOLTHA http://${server_ip}:30125 headers=${HEADERS}
Kailash22179672019-03-18 20:24:55 -070075 @{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
85Teardown
Kailash15560ff2019-03-19 06:59:52 -070086 #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}
89 #Wait Until Keyword Succeeds 60s 2s Clean Up Objects ${ATT_SERVICEINSTANCES}
Kailash22179672019-03-18 20:24:55 -070090 Delete All Sessions
91 #Get Pod Logs
92
93Get 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
100Validate Number of ONU Devices
101 [Arguments] ${expected_onus}
102 ${resp}= CORD Get ${ONU_DEVICE}
Kailash498bf1c2019-03-18 21:05:05 -0700103 Validate ONUs in Response ${resp} ${expected_onus}
104
105Validate 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
112Validate ONUs in Response
113 [Arguments] ${resp} ${expected_onus}
Kailash22179672019-03-18 20:24:55 -0700114 ${jsondata}= To Json ${resp.content}
Kailash498bf1c2019-03-18 21:05:05 -0700115 Should Not Be Empty ${jsondata['items']}
Kailash22179672019-03-18 20:24:55 -0700116 ${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
Kailash498bf1c2019-03-18 21:05:05 -0700127CORD 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
135CORD 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}