You Wang | 0c2b366 | 2018-10-01 16:56:17 -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 Library of functions related to kubectl and helm |
| 17 | Library SSHLibrary |
| 18 | Library Collections |
| 19 | Library String |
| 20 | Library OperatingSystem |
| 21 | Library RequestsLibrary |
| 22 | Library utils/utils.py |
| 23 | Library restApi.py |
You Wang | 8fff6a0 | 2018-10-15 16:26:54 -0700 | [diff] [blame] | 24 | Resource ../../Framework/utils/utils.robot |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 25 | |
| 26 | *** Keywords *** |
| 27 | Helm Chart is Removed |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 28 | [Arguments] ${helm_chart} |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 29 | [Documentation] Verify the specified helm chart has been removed |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 30 | ${rc}= Run And Return Rc ${export_kubeconfig}; helm ls -q | grep ${helm_chart} |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 31 | Should Be Equal As Integers ${rc} 1 |
| 32 | |
| 33 | Kubernetes PODs in Namespace are Removed |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 34 | [Arguments] ${namespace} |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 35 | [Documentation] Verify all Kubernetes pods in specified namespace have been removed |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 36 | ${rc} ${output}= Run And Return Rc And Output ${export_kubeconfig}; kubectl get pods --no-headers -n ${namespace} |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 37 | Should Contain ${output} No resources found |
| 38 | |
| 39 | Kubernetes PODs in Namespace are Running |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 40 | [Arguments] ${namespace} ${pod_num} |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 41 | [Documentation] Verify the number of Kubernetes pods that are running in specified namespace is as expected |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 42 | ${rc} ${output}= Run And Return Rc And Output ${export_kubeconfig}; kubectl get pods -n ${namespace} | grep -i running | grep 1/1 | wc -l |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 43 | Should Be Equal As Integers ${output} ${pod_num} |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 44 | |
| 45 | Reinstall Voltha |
| 46 | Run ${export_kubeconfig}; helm delete --purge voltha |
| 47 | Wait Until Keyword Succeeds 60s 10s Helm Chart is Removed voltha |
| 48 | Wait Until Keyword Succeeds 120s 10s Kubernetes PODs in Namespace are Removed voltha |
You Wang | ddd0424 | 2018-11-29 16:41:31 -0800 | [diff] [blame] | 49 | Sleep 10s |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 50 | Run ${export_kubeconfig}; cd ${HELM_CHARTS_DIR}; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 51 | Run ${export_kubeconfig}; cd ${HELM_CHARTS_DIR}; helm dep up voltha |
You Wang | ddd0424 | 2018-11-29 16:41:31 -0800 | [diff] [blame] | 52 | Run ${export_kubeconfig}; helm install -n voltha -f ${KUBERNETES_YAML} ${HELM_CHARTS_DIR}/voltha |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 53 | Wait Until Keyword Succeeds 60s 10s Kubernetes PODs in Namespace are Running voltha ${VOLTHA_POD_NUM} |
| 54 | Sleep 10s |
You Wang | 8fff6a0 | 2018-10-15 16:26:54 -0700 | [diff] [blame] | 55 | |
| 56 | Get Current Datetime On Kubernetes Node |
| 57 | [Arguments] ${ip} ${user} ${pass} |
| 58 | ${result}= Login And Run Command On Remote System date +"%Y-%m-%dT%H:%M:%S.%NZ" ${ip} ${user} ${pass} |
| 59 | ${result}= Get Line ${result} 0 |
| 60 | [Return] ${result} |
| 61 | |
| 62 | Log Kubernetes Container Log Since Time |
You Wang | 41ca537 | 2018-10-19 13:36:12 -0700 | [diff] [blame] | 63 | [Arguments] ${datetime} ${pod_prefix} |
| 64 | ${rc} ${namespace}= Run And Return Rc And Output ${export_kubeconfig}; kubectl get pods --all-namespaces | grep ' ${pod_prefix}' | head -1 | awk '{print $1}' |
| 65 | ${rc} ${pod_name}= Run And Return Rc And Output ${export_kubeconfig}; kubectl get pods --all-namespaces | grep ' ${pod_prefix}' | head -1 | awk '{print $2}' |
| 66 | ${rc} ${output}= Run Keyword If '${pod_prefix}' == 'onos' Run And Return Rc And Output ${export_kubeconfig}; kubectl logs --timestamps -n ${namespace} --since-time=${datetime} ${pod_name} -c onos |
| 67 | ... ELSE Run And Return Rc And Output ${export_kubeconfig}; kubectl logs --timestamps -n ${namespace} --since-time=${datetime} ${pod_name} |
You Wang | 8fff6a0 | 2018-10-15 16:26:54 -0700 | [diff] [blame] | 68 | Log ${output} |
| 69 | |
| 70 | Log Kubernetes Containers Logs Since Time |
You Wang | 41ca537 | 2018-10-19 13:36:12 -0700 | [diff] [blame] | 71 | [Arguments] ${datetime} ${pod_list} |
| 72 | : FOR ${pod_prefix} IN @{pod_list} |
| 73 | \ Log Kubernetes Container Log Since Time ${datetime} ${pod_prefix} |
You Wang | 8fff6a0 | 2018-10-15 16:26:54 -0700 | [diff] [blame] | 74 | |
| 75 | Get Kubernetes POD Name By Prefix |
| 76 | [Arguments] ${prefix} |
| 77 | [Documentation] Return the first POD name that starts with the specified prefix |
Kailash Khalasi | bf1478b | 2018-10-17 11:58:58 -0700 | [diff] [blame] | 78 | ${rc} ${output}= Run And Return Rc And Output ${export_kubeconfig}; kubectl get pods --all-namespaces | grep '${prefix}' | head -1 | awk '{print $2}' |
You Wang | 8fff6a0 | 2018-10-15 16:26:54 -0700 | [diff] [blame] | 79 | [Return] ${output} |