blob: d5e2fa41c3a5575c8c3bb6117a4ad02b6acbab60 [file] [log] [blame]
Guillaume Lambert824f9962021-03-09 16:56:08 +01001#!/bin/bash
2
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +01003# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010017#
18# Run the health-check testsuites for the tags discovered by helm list
19# Please clean up logs when you are done...
20#
Guillaume Lambert5f4af052021-03-09 21:52:32 +010021if [ "$1" = "" ] ; then
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010022 echo "Usage: eteHelm-k8s.sh [namespace] [execscript]"
23 echo " list projects via helm list and runs health-check with those tags except dev and dev-consul"
24 echo " [execscript] - optional parameter to execute user custom scripts located in scripts/helmscript directory"
25 exit
26fi
27
28set -x
29
30export NAMESPACE="$1"
31
32POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
33
34PROJECTS=$(helm list | tail -n +3 | grep '-' | cut -d' ' -f1 | sed -E 's/\w+-(\w+)/health-\1/g' | grep -v consul | grep -v nfs-provision)
35
36TAGS=""
37for project in $PROJECTS ;
38do
39TAGS="$TAGS -i $project"
40done
41
42DIR=$(dirname "$0")
43SCRIPTDIR=scripts/helmscript
44
45ETEHOME=/var/opt/ONAP
46
Guillaume Lambertba6e50f2021-04-26 21:46:56 +020047if [ "${!#}" = "execscript" ]; then
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010048 for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
49 [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && source "$DIR/$SCRIPTDIR/$script"
50 done
51fi
52
53export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
54OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_ete_helmlist
55DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
56
57VARIABLEFILES="-V /share/config/robot_properties.py"
58VARIABLES="-v GLOBAL_BUILD_NUMBER:$$"
59
60kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM