Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -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 | |
| 16 | *** Settings *** |
| 17 | Documentation Test suite to validate K8s in the experimental ControlKube Scenario |
| 18 | Suite Setup Setup |
| 19 | Library OperatingSystem |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 20 | Library CORDRobot |
| 21 | Library ImportResource resources=CORDRobot |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 22 | |
| 23 | *** Variables *** |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 24 | ${deployment} physical |
| 25 | @{physical_nodes} node1 node2 node3 |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 26 | @{minikube_nodes} minikube |
| 27 | ${resources_file} ${CURDIR}/data/k8resources.json |
| 28 | |
| 29 | |
| 30 | *** Test Cases *** |
| 31 | Validate K8 Nodes |
| 32 | [Documentation] Validates that all nodes that are running in the K8 are healthy |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 33 | [Tags] nodes |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 34 | ${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 | |
| 53 | Validate 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 | |
| 61 | Validate 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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 69 | Validate 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 Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 77 | Validate 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 | |
| 85 | Validate XOS Core Deployments |
| 86 | [Documentation] Validates that all xos-core deployments successfully rolled out and available |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 87 | [Tags] xos-core |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 88 | Validate Deployments xos- ${core_deployments} |
| 89 | |
| 90 | Validate RCord-Lite Deployments |
| 91 | [Documentation] Validates that all rcord-lite deployments successfully rolled out and available |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 92 | [Tags] rcord-lite |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 93 | Validate Deployments rcord-lite- ${rcord_lite_deployments} |
| 94 | |
| 95 | Validate ONOS-Fabric Deployments |
| 96 | [Documentation] Validates that all onos-fabric deployments successfully rolled out and available |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 97 | [Tags] onos-fabric |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 98 | Validate Deployments onos-fabric ${onos_fabric_deployments} |
| 99 | |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 100 | Validate 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 Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 105 | Validate XOS Core Services |
| 106 | [Documentation] Validates that all expected xos-core services that are running in K8s |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 107 | [Tags] xos-core |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 108 | ${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 | |
| 118 | Validate ONOS-Fabric Services |
| 119 | [Documentation] Validates that all expected onos-fabric services that are running in K8s |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 120 | [Tags] onos-fabric |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 121 | ${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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 131 | Validate 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 Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 144 | *** Keywords *** |
| 145 | Setup |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 146 | Log Parsing the datafile for Kubernetes resources for each helm chart |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 147 | @{core_containers}= Create List |
| 148 | @{rcord_lite_containers}= Create List |
| 149 | @{onos_fabric_containers}= Create List |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 150 | @{voltha_containers}= Create List |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 151 | @{core_deployments}= Create List |
| 152 | @{rcord_lite_deployments}= Create List |
| 153 | @{onos_fabric_deployments}= Create List |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 154 | @{voltha_deployments}= Create List |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 155 | @{xos_core_services}= Create List |
| 156 | @{onos_fabric_services}= Create List |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 157 | @{voltha_services}= Create List |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 158 | ${xos-core_containers} CORDRobot.jsonToList ${resources_file} xos-core-containers |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 159 | : FOR ${container} IN @{xos-core_containers} |
| 160 | \ Append To List ${core_containers} ${container} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 161 | ${rcord_containers} CORDRobot.jsonToList ${resources_file} rcord-lite-containers |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 162 | : FOR ${container} IN @{rcord_containers} |
| 163 | \ Append To List ${rcord_lite_containers} ${container} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 164 | ${onosfabric_containers} CORDRobot.jsonToList ${resources_file} onos-fabric-containers |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 165 | : FOR ${container} IN @{onosfabric_containers} |
| 166 | \ Append To List ${onos_fabric_containers} ${container} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 167 | ${volthaContainers} CORDRobot.jsonToList ${resources_file} voltha-containers |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 168 | : FOR ${container} IN @{volthaContainers} |
| 169 | \ Append To List ${voltha_containers} ${container} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 170 | ${xos-core_deployments} CORDRobot.jsonToList ${resources_file} xos-core-deployments |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 171 | : FOR ${deployment} IN @{xos-core_containers} |
| 172 | \ Append To List ${core_deployments} ${deployment} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 173 | ${rcord_deployments} CORDRobot.jsonToList ${resources_file} rcord-lite-deployments |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 174 | : FOR ${deployment} IN @{rcord_deployments} |
| 175 | \ Append To List ${rcord_lite_deployments} ${deployment} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 176 | ${onosfabric_deployments} CORDRobot.jsonToList ${resources_file} onos-fabric-deployments |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 177 | : FOR ${deployment} IN @{onosfabric_deployments} |
| 178 | \ Append To List ${onos_fabric_deployments} ${deployment} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 179 | ${volthaDeployments} CORDRobot.jsonToList ${resources_file} voltha-deployments |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 180 | : FOR ${deployment} IN @{volthaDeployments} |
| 181 | \ Append To List ${voltha_deployments} ${deployment} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 182 | ${core_services} CORDRobot.jsonToList ${resources_file} xos-core-services |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 183 | : FOR ${service} IN @{core_services} |
| 184 | \ Append To List ${xos_core_services} ${service} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 185 | ${onos_services} CORDRobot.jsonToList ${resources_file} onos-fabric-services |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 186 | : FOR ${service} IN @{onos_services} |
| 187 | \ Append To List ${onos_fabric_services} ${service} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 188 | ${volthaServices} CORDRobot.jsonToList ${resources_file} voltha-services |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 189 | : FOR ${service} IN @{volthaServices} |
| 190 | \ Append To List ${voltha_services} ${service} |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 191 | 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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 199 | Set Suite Variable @{voltha_containers} |
| 200 | Set Suite Variable @{voltha_services} |
| 201 | Set Suite Variable @{voltha_deployments} |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 202 | |
| 203 | Get 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 | |
| 217 | Validate 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 Khalasi | 615940e | 2018-06-18 10:29:16 -0700 | [diff] [blame] | 230 | \ Continue For Loop If 'tosca-loader' in '''${name}''' |
Kailash Khalasi | d314adb | 2018-07-23 11:42:45 -0700 | [diff] [blame] | 231 | \ Continue For Loop If '-test' in '''${name}''' |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 232 | \ ${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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 238 | \ Run Keyword and Continue On Failure Should Be Equal As Integers ${restartCount} 0 |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 239 | \ ${container_name}= Get From Dictionary ${cstatus} name |
| 240 | \ ${state}= Get From Dictionary ${cstatus} state |
Kailash Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 241 | \ Run Keyword and Continue On Failure Should Contain ${state} running |
| 242 | \ Run Keyword and Continue On Failure Should Not Contain ${state} stopped |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 243 | \ Log ${state} |
| 244 | \ Append To List ${container_names} ${container_name} |
| 245 | [Return] ${container_names} |
| 246 | |
| 247 | Validate 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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 254 | \ Run Keyword and Continue On Failure Should Be Equal ${rollout_status} deployment "${i}" successfully rolled out |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 255 | \ ##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 Khalasi | 55c65a7 | 2018-06-05 11:28:20 -0700 | [diff] [blame] | 258 | \ Run Keyword and Continue On Failure Should Be Equal ${desired} ${available} |
Kailash Khalasi | 2713931 | 2018-05-29 08:43:50 -0700 | [diff] [blame] | 259 | #validates that all expected deployments to exist |
| 260 | : FOR ${i} IN @{expected_deployments} |
Kailash Khalasi | d314adb | 2018-07-23 11:42:45 -0700 | [diff] [blame] | 261 | \ Run Keyword and Continue On Failure List Should Contain Value ${deployments} ${i} |