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"
37 REPO_JSON="cm-repo.json"
43 NAMESPACE="ckhm" #kube namespace for simple-app
51 PREFIX=/onap/k8sparticipant
54 echo "usage: ./test.sh docker|(kube <cluster-ip>)"
57 if [ $1 == "docker" ]; then
60 URL="http://$USER:$PWD@$HOST:$PORT"$PREFIX
61 #URL="http://$HOST:$PORT"$PREFIX
67 elif [ $# -eq 2 ]; then
68 if [ $1 == "kube" ]; then
69 PORT=$(kubectl get svc helmmanagerservice -n nonrtric -o jsonpath='{...ports[?(@.name=="'http'")].nodePort}')
71 URL="http://$USER:$PWD@$HOST:$PORT"$PREFIX
72 #URL="http://$HOST:$PORT"$PREFIX
86 curl_cmd="curl -sw %{http_code} $PROXY_TAG $HM_PATH$@"
90 status=${res:${#res}-3}
91 if [ -z "$res" ]; then
92 body="<no-body-returned>"
93 elif [ ${#res} -gt 2 ]; then
94 body=${res:0:${#res}-3}
96 body="<no-body-returned>"
98 if [ $retcode -ne 0 ]; then
99 echo -e $RED" FAIL - Curl failed"$ERED
100 echo " Curl return code: $retcode"
101 OK="One or more tests failed"
103 if [[ $status -gt 199 ]] && [[ $status -lt 300 ]]; then
104 echo -e $GREEN" Curl OK"$EGREEN
105 echo " Response: "$status
108 echo -e $RED" FAIL, non 2XX response"$ERED
109 echo " Response: "$status
111 OK="One or more tests failed"
116 echo "================"
117 echo "Get apps - empty"
118 echo "================"
124 echo "================"
126 echo "================"
127 cmd="/helm/repo -X POST -H Content-Type:application/json -d @$REPO_JSON"
135 cmd="/helm/onboard/chart -X POST -F chart=@$APP_TGZ -F values=@$VALUES_YAML -F info=<$INFO_JSON"
140 echo "====================="
141 echo "Get apps - simple-app"
142 echo "====================="
151 cmd="/helm/install -X POST -H Content-Type:application/json -d @$INSTALL_JSON"
157 echo "====================="
158 echo "Get apps - simple-app"
159 echo "====================="
164 echo "================================================================="
165 echo "helm ls to list installed app - simpleapp chart should be visible"
166 echo "================================================================="
170 echo "=========================================="
171 echo "sleep 30 - give the app some time to start"
172 echo "=========================================="
175 echo "============================"
176 echo "List svc and pod of the app"
177 echo "============================"
178 kubectl get svc -n $NAMESPACE
179 kubectl get po -n $NAMESPACE
182 echo "========================"
183 echo "Uninstall app simple-app"
184 echo "========================"
185 cmd="/helm/uninstall/simple-app/0.1.0 -X DELETE"
189 echo "==========================================="
190 echo "sleep 30 - give the app some time to remove"
191 echo "==========================================="
194 echo "============================================================"
195 echo "List svc and pod of the app - should be gone or terminating"
196 echo "============================================================"
197 kubectl get svc -n $NAMESPACE
198 kubectl get po -n $NAMESPACE
202 echo "====================="
203 echo "Get apps - simple-app"
204 echo "====================="
212 cmd="/helm/chart/simple-app/0.1.0 -X DELETE"
216 echo "================"
217 echo "Get apps - empty"
218 echo "================"
223 echo -e "Test result $BOLD $OK $EBOLD"