Fixing CSIT tests for vnfsdk-refrepo and vnfsdk-marketplace.
[integration/csit.git] / plans / vnfsdk-marketplace / testsuites / setup.sh
similarity index 57%
rename from plans/vnfsdk-refrepo/sanity-check/setup.sh
rename to plans/vnfsdk-marketplace/testsuites/setup.sh
index ed39d67..a30a682 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/bash
 #
 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
+# Copyright 2020 Nokia.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # limitations under the License.
 #
 # These scripts are sourced by run-csit.sh.
-VNFSDK_REFREPO_DOCKER_VERSION=1.3-STAGING-latest
 
-#Start postgres database
-docker run -d -i -t --name=postgres   -p 5432:5432 nexus3.onap.org:10001/onap/vnfsdk/refrepo/postgres:latest
+REFREPO_IMAGE_TAG=1.6.0-STAGING-latest \
+POSTGRES_IMAGE_TAG=latest \
+NETWORK_DRIVER_MTU=1450 \
+docker-compose up -d
 
-POSTGRES=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' postgres`
-
-#Start market place
-docker run -d -i -t --name=refrepo -e POSTGRES_SERVICE_HOST=$POSTGRES  -p 8702:8702 nexus3.onap.org:10001/onap/vnfsdk/refrepo:$VNFSDK_REFREPO_DOCKER_VERSION
+DOCKER_IP=`get-docker-network-ip.sh`
 
 # Wait for Market place initialization
 echo Wait for VNF Repository initialization
-for i in {1..30}; do
-    sleep 1
+# Active waiting with healthcheck and max retry count
+MAX_RETRY=30
+TRY=1
+while (( $(curl -s -o /dev/null -w ''%{http_code}'' ${DOCKER_IP}:8702/onapapi/vnfsdk-marketplace/v1/PackageResource/healthcheck) != 200 )) && (($TRY < $MAX_RETRY)); do
+  sleep 4
+  TRY=$[$TRY+1]
 done
 
-REPO_IP=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' refrepo`
-
+# Get refrepo logs for easier debug in case of failure
+docker logs refrepo
+REFREPO_IP=`get-instance-ip.sh refrepo`
 
 # Pass any variables required by Robot test suites in ROBOT_VARIABLES
-ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS} -v REPO_IP:${REPO_IP}"
+ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS} -v REPO_IP:${REFREPO_IP}"
 echo ${ROBOT_VARIABLES}