blob: 9f8cbb2fafb85c090a44058ff5d48e1352cdf024 [file] [log] [blame]
Brian Freeman9bf28ee2019-04-11 12:28:52 -05001# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
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#!/bin/bash
16
17#
kaihlavie2903822019-05-10 08:57:14 +030018# Run the health-check testsuites for the tags discovered by helm list
Brian Freeman9bf28ee2019-04-11 12:28:52 -050019# Please clean up logs when you are done...
Brian Freeman9bf28ee2019-04-11 12:28:52 -050020#
21if [ "$1" == "" ] ; then
marekpl1b6baa42019-08-02 18:11:42 +020022 echo "Usage: eteHelm-k8s.sh [namespace] [execscript]"
kaihlavie87aac12019-05-09 16:31:15 +030023 echo " list projects via helm list and runs health-check with those tags except dev and dev-consul"
marekpl1b6baa42019-08-02 18:11:42 +020024 echo " [execscript] - optional parameter to execute user custom scripts located in scripts/helmscript directory"
Brian Freeman9bf28ee2019-04-11 12:28:52 -050025 exit
26fi
27
28set -x
29
30export NAMESPACE="$1"
31
32POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
33
DR695H6ad31602019-07-29 15:06:52 -040034PROJECTS=$(helm list | tail -n +3 | grep '-' | cut -d' ' -f1 | sed -E 's/\w+-(\w+)/health-\1/g' | grep -v consul | grep -v nfs-provision)
Brian Freeman9bf28ee2019-04-11 12:28:52 -050035
36TAGS=""
37for project in $PROJECTS ;
38do
39TAGS="$TAGS -i $project"
40done
41
marekpl1b6baa42019-08-02 18:11:42 +020042DIR=$(dirname "$0")
43SCRIPTDIR=scripts/helmscript
Brian Freeman9bf28ee2019-04-11 12:28:52 -050044
45ETEHOME=/var/opt/ONAP
marekpl1b6baa42019-08-02 18:11:42 +020046
47if [[ "${!#}" == "execscript" ]]; then
48 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
Brian Freeman9bf28ee2019-04-11 12:28:52 -050053export 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
DR695H1f1bf372019-08-02 15:42:32 -040057VARIABLEFILES="-V /share/config/robot_properties.py"
Brian Freeman9bf28ee2019-04-11 12:28:52 -050058VARIABLES="-v GLOBAL_BUILD_NUMBER:$$"
59
60kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM