-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest-platform.sh
60 lines (55 loc) · 2 KB
/
test-platform.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Scripts tests layer by layer
#
set -eu
set -o pipefail
CHART_DIR=./charts/
if [ "$1" != "" ]; then
INFRASTRUCTURE=$1
echo testing platform: $INFRASTRUCTURE
else
echo please pass infrastructure variable
echo example: test-platform.sh kind
exit 1
fi
TLC_FILE="/tmp/$INFRASTRUCTURE-top-layer-changed"
[ -f $TLC_FILE ] && top=$(cat $TLC_FILE) || echo "no top layer file '$TLC_FILE'"
[ -n "$top" ] && echo "the top layer changed is $top"
cat /tmp/layers-sorted | while read layer || [[ -n $layer ]];
do
echo current layer is $layer
if [ -f /tmp/$layer-$INFRASTRUCTURE ]; then
CHARTS_CHANGED_FILE="/tmp/$layer-$INFRASTRUCTURE-changed "
if [ -f /tmp/$layer-$INFRASTRUCTURE-changed ]; then
echo "Testing changes on $INFRASTRUCTURE in layer: $layer"
charts_changed_in_layer=$(cat /tmp/$layer-$INFRASTRUCTURE-changed)
ct install --config ct.yaml --charts $(awk '{print $1}' /tmp/$layer-$INFRASTRUCTURE-changed | paste -s -d, -)
else
echo "No changes to test on $INFRASTRUCTURE in layer $layer"
fi
if [[ -n "$top" && "$top" > "$layer" ]]; then
echo "Installing layer: $layer"
charts_in_layer=$(cat /tmp/$layer-$INFRASTRUCTURE)
echo "Installing charts for layer $layer: ( $charts_in_layer )"
for dir in $charts_in_layer; do
release=${dir##*/}
helm dependency build $dir
echo Helm install: $release
helm install -n wego-system $release $dir
done
else
[ -n "$top" ] && echo "$layer is after $top"
echo "Skip installing layer $layer"
fi
fi
done
# Tests profiles without a layer
NO_LAYERS_FILE="/tmp/null-$INFRASTRUCTURE-changed"
echo "NO LAYERS FILE '$NO_LAYERS_FILE'"
if [ -f $NO_LAYERS_FILE ]; then
CHARTS_TO_TEST=$(awk '{print $1}' /tmp/null-$INFRASTRUCTURE-changed | paste -s -d, -)
echo "Testing charts without layers ( $CHARTS_TO_TEST )"
ct install --config ct.yaml --charts $CHARTS_TO_TEST
else
echo "No charts without layers to test - file not found $NO_LAYERS_FILE"
fi