3 # ============LICENSE_START===============================================
4 # Copyright (C) 2021 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
27 GREEN="\033[32m\033[1m"
33 APP_TGZ="simple-app-0.1.0.tgz"
34 VALUES_YAML="simple-app-values.yaml"
35 INFO_JSON="simple-app.json"
36 INSTALL_JSON="simple-app-installation.json"
42 NAMESPACE="ckhm" #kube namespace for simple-app
48 echo "usage: ./test.sh docker|(kube <cluster-ip>)"
51 if [ $1 == "docker" ]; then
54 URL="http://$HOST:$PORT"
60 elif [ $# -eq 2 ]; then
61 if [ $1 == "kube" ]; then
62 PORT=$(kubectl get svc helmmanagerservice -n nonrtric -o jsonpath='{...ports[?(@.name=="'http'")].nodePort}')
64 URL="http://$HOST:$PORT"
78 curl_cmd="curl -sw %{http_code} $PROXY_TAG $HM_PATH$@"
82 status=${res:${#res}-3}
83 if [ -z "$res" ]; then
84 body="<no-body-returned>"
85 elif [ ${#res} -gt 2 ]; then
86 body=${res:0:${#res}-3}
88 body="<no-body-returned>"
90 if [ $retcode -ne 0 ]; then
91 echo -e $RED" FAIL - Curl failed"$ERED
92 echo " Curl return code: $retcode"
93 OK="One or more tests failed"
95 if [[ $status -gt 199 ]] && [[ $status -lt 300 ]]; then
96 echo -e $GREEN" Curl OK"$EGREEN
97 echo " Response: "$status
100 echo -e $RED" FAIL, non 2XX response"$ERED
101 echo " Response: "$status
103 OK="One or more tests failed"
108 echo "================"
109 echo "Get apps - empty"
110 echo "================"
119 cmd="/helm/charts -X POST -F chart=@$APP_TGZ -F values=@$VALUES_YAML -F info=<$INFO_JSON"
124 echo "====================="
125 echo "Get apps - simple-app"
126 echo "====================="
135 cmd="/helm/install -X POST -H Content-Type:application/json -d @$INSTALL_JSON"
141 echo "====================="
142 echo "Get apps - simple-app"
143 echo "====================="
148 echo "================================================================="
149 echo "helm ls to list installed app - simpleapp chart should be visible"
150 echo "================================================================="
154 echo "=========================================="
155 echo "sleep 30 - give the app some time to start"
156 echo "=========================================="
159 echo "============================"
160 echo "List svc and pod of the app"
161 echo "============================"
162 kubectl get svc -n $NAMESPACE
163 kubectl get po -n $NAMESPACE
166 echo "========================"
167 echo "Uninstall app simple-app"
168 echo "========================"
169 cmd="/helm/uninstall/simple-app/0.1.0 -X DELETE"
173 echo "==========================================="
174 echo "sleep 30 - give the app some time to remove"
175 echo "==========================================="
178 echo "============================================================"
179 echo "List svc and pod of the app - should be gone or terminating"
180 echo "============================================================"
181 kubectl get svc -n $NAMESPACE
182 kubectl get po -n $NAMESPACE
186 echo "====================="
187 echo "Get apps - simple-app"
188 echo "====================="
196 cmd="/helm/charts/simple-app/0.1.0 -X DELETE"
200 echo "================"
201 echo "Get apps - empty"
202 echo "================"
207 echo -e "Test result $BOLD $OK $EBOLD"