blob: f433c31018224f6afaf3c661a905871f46410b87 [file] [log] [blame]
Kailash Khalasi27139312018-05-29 08:43:50 -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
16*** Settings ***
17Documentation Test suite to validate K8s in the experimental ControlKube Scenario
18Suite Setup Setup
19Library OperatingSystem
Zack Williams821c5022020-01-15 15:11:46 -070020Library CORDRobot
21Library ImportResource resources=CORDRobot
Kailash Khalasi27139312018-05-29 08:43:50 -070022
23*** Variables ***
Kailash Khalasi55c65a72018-06-05 11:28:20 -070024${deployment} physical
25@{physical_nodes} node1 node2 node3
Kailash Khalasi27139312018-05-29 08:43:50 -070026@{minikube_nodes} minikube
27${resources_file} ${CURDIR}/data/k8resources.json
28
29
30*** Test Cases ***
31Validate K8 Nodes
32 [Documentation] Validates that all nodes that are running in the K8 are healthy
Kailash Khalasi55c65a72018-06-05 11:28:20 -070033 [Tags] nodes
Kailash Khalasi27139312018-05-29 08:43:50 -070034 ${nodes}= Run kubectl get nodes -o json
35 Log ${nodes}
36 @{nodes}= Get Names ${nodes}
37 ##set nodes based on deployment
38 @{nodes_expected}= Set Variable If '${deployment}' == 'physical' ${physical_nodes} ${minikube_nodes}
39 Log ${nodes_expected}
40 #validates that all expected nodes to be running
41 : FOR ${i} IN @{nodes_expected}
42 \ List Should Contain Value ${nodes} ${i}
43 : FOR ${i} IN @{nodes}
44 \ ${status}= Run kubectl get nodes ${i} -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
45 \ ${outofdisk}= Run kubectl get nodes ${i} -o jsonpath='{.status.conditions[?(@.type=="OutOfDisk")].status}'
46 \ ${memorypressure}= Run kubectl get nodes ${i} -o jsonpath='{.status.conditions[?(@.type=="MemoryPressure")].status}'
47 \ ${diskpressure}= Run kubectl get nodes ${i} -o jsonpath='{.status.conditions[?(@.type=="DiskPressure")].status}'
48 \ Should Be Equal ${status} True
49 \ Should Be Equal ${outofdisk} False
50 \ Should Be Equal ${memorypressure} False
51 \ Should Be Equal ${diskpressure} False
52
53Validate XOS Core Containers
54 [Documentation] Validates that all xos core containers that are running in the K8 Pods are healthy
55 [Tags] xos-core
56 @{core_container_names}= Run Keyword and Continue on Failure Validate Pods xos-
57 #validates that all expected containers to be running are in one of the pods inspected above
58 : FOR ${i} IN @{core_containers}
59 \ Run Keyword and Continue on Failure List Should Contain Value ${core_container_names} ${i}
60
61Validate RCord-Lite Containers
62 [Documentation] Validates that all rcord-lite containers that are running in the K8 Pods are healthy
63 [Tags] rcord-lite
64 @{rcord_container_names}= Run Keyword and Continue on Failure Validate Pods rcord-lite-
65 #validates that all expected containers to be running are in one of the pods inspected above
66 : FOR ${i} IN @{rcord_lite_containers}
67 \ Run Keyword and Continue on Failure List Should Contain Value ${rcord_container_names} ${i}
68
Kailash Khalasi55c65a72018-06-05 11:28:20 -070069Validate Voltha Containers
70 [Documentation] Validates that all voltha containers that are running in the K8 Pods are healthy
71 [Tags] voltha
72 @{voltha_container_names}= Run Keyword and Continue on Failure Validate Pods voltha-
73 #validates that all expected containers to be running are in one of the pods inspected above
74 : FOR ${i} IN @{voltha_containers}
75 \ Run Keyword and Continue on Failure List Should Contain Value ${voltha_container_names} ${i}
76
Kailash Khalasi27139312018-05-29 08:43:50 -070077Validate ONOS-Fabric Containers
78 [Documentation] Validates that all onos-fabric containers that are running in the K8 Pods are healthy
79 [Tags] onos-fabric
80 @{onos_container_names}= Run Keyword and Continue on Failure Validate Pods onos-fabric
81 #validates that all expected containers to be running are in one of the pods inspected above
82 : FOR ${i} IN @{onos_fabric_containers}
83 \ Run Keyword and Continue on Failure List Should Contain Value ${onos_container_names} ${i}
84
85Validate XOS Core Deployments
86 [Documentation] Validates that all xos-core deployments successfully rolled out and available
Kailash Khalasi55c65a72018-06-05 11:28:20 -070087 [Tags] xos-core
Kailash Khalasi27139312018-05-29 08:43:50 -070088 Validate Deployments xos- ${core_deployments}
89
90Validate RCord-Lite Deployments
91 [Documentation] Validates that all rcord-lite deployments successfully rolled out and available
Kailash Khalasi55c65a72018-06-05 11:28:20 -070092 [Tags] rcord-lite
Kailash Khalasi27139312018-05-29 08:43:50 -070093 Validate Deployments rcord-lite- ${rcord_lite_deployments}
94
95Validate ONOS-Fabric Deployments
96 [Documentation] Validates that all onos-fabric deployments successfully rolled out and available
Kailash Khalasi55c65a72018-06-05 11:28:20 -070097 [Tags] onos-fabric
Kailash Khalasi27139312018-05-29 08:43:50 -070098 Validate Deployments onos-fabric ${onos_fabric_deployments}
99
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700100Validate Voltha Deployments
101 [Documentation] Validates that all voltha deployments successfully rolled out and available
102 [Tags] voltha
103 Validate Deployments voltha ${voltha_deployments}
104
Kailash Khalasi27139312018-05-29 08:43:50 -0700105Validate XOS Core Services
106 [Documentation] Validates that all expected xos-core services that are running in K8s
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700107 [Tags] xos-core
Kailash Khalasi27139312018-05-29 08:43:50 -0700108 ${services}= Run kubectl get services -o json
109 Log ${services}
110 @{services}= Get Names ${services}
111 #validates that all expected services are running
112 : FOR ${i} IN @{xos_core_services}
113 \ Run Keyword and Continue on Failure List Should Contain Value ${services} ${i}
114 ##check for appropriate ports for each service and match with values in helm charts
115 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].port}'
116 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].targetPort}'
117
118Validate ONOS-Fabric Services
119 [Documentation] Validates that all expected onos-fabric services that are running in K8s
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700120 [Tags] onos-fabric
Kailash Khalasi27139312018-05-29 08:43:50 -0700121 ${services}= Run kubectl get services -o json
122 Log ${services}
123 @{services}= Get Names ${services}
124 #validates that all expected services are running
125 : FOR ${i} IN @{onos_fabric_services}
126 \ Run Keyword and Continue on Failure List Should Contain Value ${services} ${i}
127 ##check for appropriate ports for each service and match with values in helm charts
128 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].port}'
129 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].targetPort}'
130
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700131Validate Voltha Services
132 [Documentation] Validates that all expected voltha services that are running in K8s
133 [Tags] voltha
134 ${services}= Run kubectl get services -o json
135 Log ${services}
136 @{services}= Get Names ${services}
137 #validates that all expected services are running
138 : FOR ${i} IN @{voltha_services}
139 \ Run Keyword and Continue on Failure List Should Contain Value ${services} ${i}
140 ##check for appropriate ports for each service and match with values in helm charts
141 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].port}'
142 ## eg. kubectl get svc xos-core -o jsonpath='{.spec.ports[?(@.name=="secure")].targetPort}'
143
Kailash Khalasi27139312018-05-29 08:43:50 -0700144*** Keywords ***
145Setup
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700146 Log Parsing the datafile for Kubernetes resources for each helm chart
Kailash Khalasi27139312018-05-29 08:43:50 -0700147 @{core_containers}= Create List
148 @{rcord_lite_containers}= Create List
149 @{onos_fabric_containers}= Create List
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700150 @{voltha_containers}= Create List
Kailash Khalasi27139312018-05-29 08:43:50 -0700151 @{core_deployments}= Create List
152 @{rcord_lite_deployments}= Create List
153 @{onos_fabric_deployments}= Create List
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700154 @{voltha_deployments}= Create List
Kailash Khalasi27139312018-05-29 08:43:50 -0700155 @{xos_core_services}= Create List
156 @{onos_fabric_services}= Create List
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700157 @{voltha_services}= Create List
Zack Williams821c5022020-01-15 15:11:46 -0700158 ${xos-core_containers} CORDRobot.jsonToList ${resources_file} xos-core-containers
Kailash Khalasi27139312018-05-29 08:43:50 -0700159 : FOR ${container} IN @{xos-core_containers}
160 \ Append To List ${core_containers} ${container}
Zack Williams821c5022020-01-15 15:11:46 -0700161 ${rcord_containers} CORDRobot.jsonToList ${resources_file} rcord-lite-containers
Kailash Khalasi27139312018-05-29 08:43:50 -0700162 : FOR ${container} IN @{rcord_containers}
163 \ Append To List ${rcord_lite_containers} ${container}
Zack Williams821c5022020-01-15 15:11:46 -0700164 ${onosfabric_containers} CORDRobot.jsonToList ${resources_file} onos-fabric-containers
Kailash Khalasi27139312018-05-29 08:43:50 -0700165 : FOR ${container} IN @{onosfabric_containers}
166 \ Append To List ${onos_fabric_containers} ${container}
Zack Williams821c5022020-01-15 15:11:46 -0700167 ${volthaContainers} CORDRobot.jsonToList ${resources_file} voltha-containers
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700168 : FOR ${container} IN @{volthaContainers}
169 \ Append To List ${voltha_containers} ${container}
Zack Williams821c5022020-01-15 15:11:46 -0700170 ${xos-core_deployments} CORDRobot.jsonToList ${resources_file} xos-core-deployments
Kailash Khalasi27139312018-05-29 08:43:50 -0700171 : FOR ${deployment} IN @{xos-core_containers}
172 \ Append To List ${core_deployments} ${deployment}
Zack Williams821c5022020-01-15 15:11:46 -0700173 ${rcord_deployments} CORDRobot.jsonToList ${resources_file} rcord-lite-deployments
Kailash Khalasi27139312018-05-29 08:43:50 -0700174 : FOR ${deployment} IN @{rcord_deployments}
175 \ Append To List ${rcord_lite_deployments} ${deployment}
Zack Williams821c5022020-01-15 15:11:46 -0700176 ${onosfabric_deployments} CORDRobot.jsonToList ${resources_file} onos-fabric-deployments
Kailash Khalasi27139312018-05-29 08:43:50 -0700177 : FOR ${deployment} IN @{onosfabric_deployments}
178 \ Append To List ${onos_fabric_deployments} ${deployment}
Zack Williams821c5022020-01-15 15:11:46 -0700179 ${volthaDeployments} CORDRobot.jsonToList ${resources_file} voltha-deployments
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700180 : FOR ${deployment} IN @{volthaDeployments}
181 \ Append To List ${voltha_deployments} ${deployment}
Zack Williams821c5022020-01-15 15:11:46 -0700182 ${core_services} CORDRobot.jsonToList ${resources_file} xos-core-services
Kailash Khalasi27139312018-05-29 08:43:50 -0700183 : FOR ${service} IN @{core_services}
184 \ Append To List ${xos_core_services} ${service}
Zack Williams821c5022020-01-15 15:11:46 -0700185 ${onos_services} CORDRobot.jsonToList ${resources_file} onos-fabric-services
Kailash Khalasi27139312018-05-29 08:43:50 -0700186 : FOR ${service} IN @{onos_services}
187 \ Append To List ${onos_fabric_services} ${service}
Zack Williams821c5022020-01-15 15:11:46 -0700188 ${volthaServices} CORDRobot.jsonToList ${resources_file} voltha-services
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700189 : FOR ${service} IN @{volthaServices}
190 \ Append To List ${voltha_services} ${service}
Kailash Khalasi27139312018-05-29 08:43:50 -0700191 Set Suite Variable @{core_containers}
192 Set Suite Variable @{rcord_lite_containers}
193 Set Suite Variable @{onos_fabric_containers}
194 Set Suite Variable @{core_deployments}
195 Set Suite Variable @{rcord_lite_deployments}
196 Set Suite Variable @{onos_fabric_deployments}
197 Set Suite Variable @{xos_core_services}
198 Set Suite Variable @{onos_fabric_services}
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700199 Set Suite Variable @{voltha_containers}
200 Set Suite Variable @{voltha_services}
201 Set Suite Variable @{voltha_deployments}
Kailash Khalasi27139312018-05-29 08:43:50 -0700202
203Get Names
204 [Documentation] Gets names of K8 resources running
205 [Arguments] ${output}
206 @{names}= Create List
207 ${output}= To JSON ${output}
208 ${len}= Get Length ${output}
209 ${length}= Get Length ${output['items']}
210 : FOR ${INDEX} IN RANGE 0 ${length}
211 \ ${item}= Get From List ${output['items']} ${INDEX}
212 \ ${metadata}= Get From Dictionary ${item} metadata
213 \ ${name}= Get From Dictionary ${metadata} name
214 \ Append To List ${names} ${name}
215 [Return] @{names}
216
217Validate Pods
218 [Arguments] ${component}
219 @{container_names}= Create List
220 ${pods}= Run kubectl get pods -o json
221 Log ${pods}
222 ${pods}= To JSON ${pods}
223 ${len}= Get Length ${pods}
224 ${length}= Get Length ${pods['items']}
225 : FOR ${INDEX} IN RANGE 0 ${length}
226 \ ${item}= Get From List ${pods['items']} ${INDEX}
227 \ ${metadata}= Get From Dictionary ${item} metadata
228 \ ${name}= Get From Dictionary ${metadata} name
229 \ Continue For Loop If '${component}' not in '''${name}'''
Kailash Khalasi615940e2018-06-18 10:29:16 -0700230 \ Continue For Loop If 'tosca-loader' in '''${name}'''
Kailash Khalasid314adb2018-07-23 11:42:45 -0700231 \ Continue For Loop If '-test' in '''${name}'''
Kailash Khalasi27139312018-05-29 08:43:50 -0700232 \ ${status}= Get From Dictionary ${item} status
233 \ ${containerStatuses}= Get From Dictionary ${status} containerStatuses
234 \ Log ${containerStatuses}
235 \ ${cstatus}= Get From List ${containerStatuses} 0
236 \ Log ${cstatus}
237 \ ${restartCount}= Get From Dictionary ${cstatus} restartCount
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700238 \ Run Keyword and Continue On Failure Should Be Equal As Integers ${restartCount} 0
Kailash Khalasi27139312018-05-29 08:43:50 -0700239 \ ${container_name}= Get From Dictionary ${cstatus} name
240 \ ${state}= Get From Dictionary ${cstatus} state
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700241 \ Run Keyword and Continue On Failure Should Contain ${state} running
242 \ Run Keyword and Continue On Failure Should Not Contain ${state} stopped
Kailash Khalasi27139312018-05-29 08:43:50 -0700243 \ Log ${state}
244 \ Append To List ${container_names} ${container_name}
245 [Return] ${container_names}
246
247Validate Deployments
248 [Arguments] ${component} ${expected_deployments}
249 ${deployments}= Run kubectl get deployments -o json
250 @{deployments}= Get Names ${deployments}
251 : FOR ${i} IN @{deployments}
252 \ Continue For Loop If '${component}' not in '''${i}'''
253 \ ${rollout_status}= Run kubectl rollout status deployment/${i}
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700254 \ Run Keyword and Continue On Failure Should Be Equal ${rollout_status} deployment "${i}" successfully rolled out
Kailash Khalasi27139312018-05-29 08:43:50 -0700255 \ ##validate replication sets
256 \ ${desired}= Run kubectl get deployments ${i} -o jsonpath='{.status.replicas}'
257 \ ${available}= Run kubectl get deployments ${i} -o jsonpath='{.status.availableReplicas}'
Kailash Khalasi55c65a72018-06-05 11:28:20 -0700258 \ Run Keyword and Continue On Failure Should Be Equal ${desired} ${available}
Kailash Khalasi27139312018-05-29 08:43:50 -0700259 #validates that all expected deployments to exist
260 : FOR ${i} IN @{expected_deployments}
Kailash Khalasid314adb2018-07-23 11:42:45 -0700261 \ Run Keyword and Continue On Failure List Should Contain Value ${deployments} ${i}