2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 function _checks_args {
17 echo "Missing CSAR ID argument"
20 if [[ -z $CSAR_DIR ]]; then
21 echo "CSAR_DIR global environment value is empty"
24 mkdir -p ${CSAR_DIR}/${1}
27 # destroy_deployment() - This function ensures that a specific deployment is
28 # destroyed in Kubernetes
29 function destroy_deployment {
30 local deployment_name=$1
32 kubectl delete deployment $deployment_name --ignore-not-found=true --now
33 while kubectl get deployment $deployment_name &>/dev/null; do
34 echo "$(date +%H:%M:%S) - $deployment_name : Destroying deployment"
38 # recreate_deployment() - This function destroys an existing deployment and
39 # creates an new one based on its yaml file
40 function recreate_deployment {
41 local deployment_name=$1
43 destroy_deployment $deployment_name
44 kubectl create -f $deployment_name.yaml
47 # wait_deployment() - Wait process to Running status on the Deployment's pods
48 function wait_deployment {
49 local deployment_name=$1
52 while [[ $status_phase != "Running" ]]; do
53 new_phase=$(kubectl get pods | grep $deployment_name | awk '{print $3}')
54 if [[ $new_phase != $status_phase ]]; then
55 echo "$(date +%H:%M:%S) - $deployment_name : $new_phase"
56 status_phase=$new_phase
58 if [[ $new_phase == "Err"* ]]; then
64 # setup() - Base testing setup shared among functional tests
66 for deployment_name in $@; do
67 recreate_deployment $deployment_name
70 for deployment_name in $@; do
71 wait_deployment $deployment_name
75 # teardown() - Base testing teardown function
77 for deployment_name in $@; do
78 destroy_deployment $deployment_name
82 if ! $(kubectl version &>/dev/null); then
83 echo "This funtional test requires kubectl client"