From 6eebdba780e945a2c8b318897dca9b4f09fa132d Mon Sep 17 00:00:00 2001 From: kishore Date: Tue, 3 Oct 2017 11:12:57 -0500 Subject: Add updated scripts Issue-ID:PORTAL-53 Signed-off-by: kishore Change-Id: I8a6d65877bbdeee196b187d60af3d0600ea4209f --- test/csit/plans/portal/testsuite/.env | 12 +- .../csit/plans/portal/testsuite/docker-compose.yml | 96 +++++++++++ test/csit/plans/portal/testsuite/setup.sh | 176 ++++++++++++++++++--- test/csit/plans/portal/testsuite/teardown.sh | 2 +- test/csit/plans/portal/testsuite/testplan.txt | 2 +- 5 files changed, 261 insertions(+), 27 deletions(-) create mode 100644 test/csit/plans/portal/testsuite/docker-compose.yml (limited to 'test/csit/plans') diff --git a/test/csit/plans/portal/testsuite/.env b/test/csit/plans/portal/testsuite/.env index fa3076859..8fb2357b6 100644 --- a/test/csit/plans/portal/testsuite/.env +++ b/test/csit/plans/portal/testsuite/.env @@ -2,7 +2,10 @@ # used by docker-compose AND by other shell scripts # Host directory with config files -PROJECT_DIR=/PROJECT/OpenSource/UbuntuEP + +LOGS_DIR=./logs +PROPS_DIR=./properties + # Directory within containers WEBAPPS_DIR=/opt/apache-tomcat-8.0.37/webapps @@ -11,7 +14,10 @@ WEBAPPS_DIR=/opt/apache-tomcat-8.0.37/webapps EP_IMG_NAME=portal-apps DB_IMG_NAME=portal-db WMS_IMG_NAME=portal-wms -# Tag all images with this -PORTAL_TAG=1.1.0 +CLI_IMG_NAME=onap/cli +# Tag all images with this +PORTAL_TAG=1.3.0 +DOCKER_IMAGE_VERSION=1.3-STAGING-latest +CLI_DOCKER_VERSION=1.1-STAGING-latest NEXUS_REPO=nexus3.onap.org:10003 diff --git a/test/csit/plans/portal/testsuite/docker-compose.yml b/test/csit/plans/portal/testsuite/docker-compose.yml new file mode 100644 index 000000000..f40a106e9 --- /dev/null +++ b/test/csit/plans/portal/testsuite/docker-compose.yml @@ -0,0 +1,96 @@ +# docker-compose for ONAP portal containers: database, microservice, portal apps. +# Relies on .env file in current directory. +# Works in multiple environments; does not pull from a Nexus registry. +# Exposes the portal apps docker (but not DB nor WMS dockers) on the host network. +# Images must be pulled from ONAP Nexus registry after logging in like this: +# docker login -u USER -p PASS nexus3.onap.org:10001 + +version: '2.0' + +services: + + cli: + image: ${CLI_IMG_NAME}:${PORTAL_TAG} + environment: + CLI_MODE: 'daemon' + expose: + - 80 + ports: + - 8080:80 + logging: + driver: json-file + + # Config files may use hostname "portal-db" + portal-db: + image: ${DB_IMG_NAME}:${PORTAL_TAG} + environment: + MYSQL_ROOT_PASSWORD: 'Aa123456' + expose: + - 3306 + volumes: + # Just specify a path and let the Engine create a volume + - /var/lib/mysql + logging: + driver: json-file + + # An environment variable here CAN override the database URL; + # instead the value in the config file uses hostname from above + portal-wms: + image: ${WMS_IMG_NAME}:${PORTAL_TAG} + expose: + - 8082 + links: + - portal-db + depends_on: + - portal-db + volumes: + - ${PROPS_DIR}/ECOMPWIDGETMS/application.properties:/application.properties + command: + - /wait-for.sh + - -t + - "300" + - portal-db:3306 + - -- + - /start-wms-cmd.sh + logging: + driver: json-file + + # Environment variables here CANNOT override the database URL because + # two apps use identical configuration keys with different values + portal-apps: + image: ${EP_IMG_NAME}:${PORTAL_TAG} + expose: + - 8989 + ports: + - 8989:8080 + - 8010:8009 + - 8006:8005 + links: + - portal-db + - portal-wms + depends_on: + - portal-db + - portal-wms + volumes: + - ${PROPS_DIR}/ECOMPPORTALAPP/system.properties:${WEBAPPS_DIR}/ECOMPPORTAL/WEB-INF/conf/system.properties + - ${PROPS_DIR}/ECOMPPORTALAPP/fusion.properties:${WEBAPPS_DIR}/ECOMPPORTAL/WEB-INF/fusion/conf/fusion.properties + - ${PROPS_DIR}/ECOMPPORTALAPP/portal.properties:${WEBAPPS_DIR}/ECOMPPORTAL/WEB-INF/classes/portal.properties + - ${PROPS_DIR}/ECOMPPORTALAPP/openid-connect.properties:${WEBAPPS_DIR}/ECOMPPORTAL/WEB-INF/classes/openid-connect.properties + - ${PROPS_DIR}/ECOMPPORTALAPP/logback.xml:${WEBAPPS_DIR}/ECOMPPORTAL/WEB-INF/classes/logback.xml + - ${PROPS_DIR}/ECOMPSDKAPP/fusion.properties:${WEBAPPS_DIR}/ECOMPSDKAPP/WEB-INF/fusion/conf/fusion.properties + - ${PROPS_DIR}/ECOMPSDKAPP/system.properties:${WEBAPPS_DIR}/ECOMPSDKAPP/WEB-INF/conf/system.properties + - ${PROPS_DIR}/ECOMPSDKAPP/portal.properties:${WEBAPPS_DIR}/ECOMPSDKAPP/WEB-INF/classes/portal.properties + - ${PROPS_DIR}/ECOMPDBCAPP/system.properties:${WEBAPPS_DIR}/ECOMPDBCAPP/WEB-INF/conf/system.properties + - ${PROPS_DIR}/ECOMPDBCAPP/portal.properties:${WEBAPPS_DIR}/ECOMPDBCAPP/WEB-INF/classes/portal.properties + - ${PROPS_DIR}/ECOMPDBCAPP/dbcapp.properties:${WEBAPPS_DIR}/ECOMPDBCAPP/WEB-INF/dbcapp/dbcapp.properties + - ${PROPS_DIR}/ECOMPDBCAPP/fusion.properties:${WEBAPPS_DIR}/ECOMPDBCAPP/WEB-INF/fusion/conf/fusion.properties + - ${LOGS_DIR}:/opt/apache-tomcat-8.0.37/logs + command: + - /wait-for.sh + - -t + - "300" + - portal-db:3306 + - -- + - /start-apps-cmd.sh + logging: + driver: json-file diff --git a/test/csit/plans/portal/testsuite/setup.sh b/test/csit/plans/portal/testsuite/setup.sh index a6c1ba483..c3e9e5160 100644 --- a/test/csit/plans/portal/testsuite/setup.sh +++ b/test/csit/plans/portal/testsuite/setup.sh @@ -1,40 +1,172 @@ #!/bin/bash -# Starts docker containers for ONAP Portal in Rackspace. -# Version for Amsterdam/R1 uses docker-compose. +# Starts docker containers for ONAP Portal +# This version for Amsterdam/R1 of Portal, uses docker-compose. +# Temporarily maintained in portal/deliveries area; +# replicated from the ONAP demo/boot area due to release concerns. + +# Start Xvfb +echo -e "Starting Xvfb on display ${DISPLAY} with res ${RES}" +Xvfb ${DISPLAY} -ac -screen 0 ${RES} +extension RANDR & +XVFBPID=$! +# Get pid of this spawned process to make sure we kill the correct process later + +#Get current IP of VM +HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') +export HOST_IP=${HOST_IP} + +if ! ifconfig docker0; then +if ! ifconfig ens3; then +echo "Could not determine IP address" +exit 1 +fi +export DOCKER_IP_IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +else +export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +fi +echo $DOCKER_IP + + +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +#ROBOT_VARIABLES="-v MOCK_IP:${MOCK_IP} -v IP:${IP} -v POLICY_IP:${POLICY_IP} -v DOCKER_IP:${DOCKER_IP}" +#export PORTAL_IP=${PORTAL_IP} +ROBOT_VARIABLES="-v MOCK_IP:${MOCK_IP} -v IP:${IP} -v DOCKER_IP:${DOCKER_IP}" +export DOCKER_IP=${DOCKER_IP} + + + + + + + # be verbose set -x # Establish environment variables -NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) -NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) -NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) -DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt) +NEXUS_USERNAME=docker +NEXUS_PASSWD=docker +NEXUS_DOCKER_REPO=nexus3.onap.org:10003 + + + +CURR="$(pwd)" +git clone http://gerrit.onap.org/r/portal # Refresh configuration and scripts -cd /opt/portal +cd portal git pull cd deliveries - +rm .env +rm docker-compose.yml +cp $CURR/.env . +cp $CURR/docker-compose.yml . +#cd properties_rackspace/ECOMPPORTALAPP +#rm system.properties +#cp $CURR/system.properties . +#cd ../.. # Get image names used below from docker-compose environment file -source .env +source $CURR/.env + +# Copy property files to new directory +mkdir -p $PROPS_DIR +cp -r properties_rackspace/* $PROPS_DIR +# Also create logs directory +mkdir -p $LOGS_DIR -# Copy property files -ETC=/PROJECT/OpenSource/UbuntuEP/etc -mkdir -p $ETC -cp -r properties_rackspace/* $ETC # Refresh images docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO -docker pull $NEXUS_DOCKER_REPO/openecomp/${DB_IMG_NAME}:$DOCKER_IMAGE_VERSION -docker pull $NEXUS_DOCKER_REPO/openecomp/${EP_IMG_NAME}:$DOCKER_IMAGE_VERSION -docker pull $NEXUS_DOCKER_REPO/openecomp/${WMS_IMG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/onap/${DB_IMG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/onap/${EP_IMG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/onap/${WMS_IMG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/$CLI_IMG_NAME:$CLI_DOCKER_VERSION # Tag them as expected by docker-compose file -docker tag $NEXUS_DOCKER_REPO/openecomp/${DB_IMG_NAME}:$DOCKER_IMAGE_VERSION $DB_IMG_NAME:$PORTAL_TAG -docker tag $NEXUS_DOCKER_REPO/openecomp/${EP_IMG_NAME}:$DOCKER_IMAGE_VERSION $EP_IMG_NAME:$PORTAL_TAG -docker tag $NEXUS_DOCKER_REPO/openecomp/${WMS_IMG_NAME}:$DOCKER_IMAGE_VERSION $WMS_IMG_NAME:$PORTAL_TAG +docker tag $NEXUS_DOCKER_REPO/onap/${DB_IMG_NAME}:$DOCKER_IMAGE_VERSION $DB_IMG_NAME:$PORTAL_TAG +docker tag $NEXUS_DOCKER_REPO/onap/${EP_IMG_NAME}:$DOCKER_IMAGE_VERSION $EP_IMG_NAME:$PORTAL_TAG +docker tag $NEXUS_DOCKER_REPO/onap/${WMS_IMG_NAME}:$DOCKER_IMAGE_VERSION $WMS_IMG_NAME:$PORTAL_TAG +docker tag $NEXUS_DOCKER_REPO/$CLI_IMG_NAME:$CLI_DOCKER_VERSION $CLI_IMG_NAME:$PORTAL_TAG + +# compose is not in /usr/bin +docker-compose down +docker-compose up -d + + +#${HOSTNAME}="portal.api.simpledemo.openecomp.org" +#echo "$HOST_IP ${HOSTNAME}" >> /etc/hosts + +#echo "$HOST_IP portal.api.simpledemo.openecomp.org" >> /etc/hosts +#sudo sed -i "2i$HOST_IP portal.api.simpledemo.openecomp.org" /etc/hosts + +#HOST="portal.api.simpledemo.openecomp.org" +#sudo sed -i "/$HOST/ s/.*/$HOST_IP\t$HOST/g" /etc/hosts + +# insert/update hosts entry +ip_address=$HOST_IP +host_name="portal.api.simpledemo.openecomp.org" +# find existing instances in the host file and save the line numbers +matches_in_hosts="$(grep -n $host_name /etc/hosts | cut -f1 -d:)" +host_entry="${ip_address} ${host_name}" + +echo "$host_entry" + +if [ ! -z "$matches_in_hosts" ] +then +echo "Updating existing hosts entry." +# iterate over the line numbers on which matches were found +while read -r line_number; do +# replace the text of each line with the desired host entry +sudo sed -i '' "${line_number}s/.*/${host_entry} /" /etc/hosts +echo "${line_number} ${host_entry}" +done <<< "$matches_in_hosts" +else +echo "Adding new hosts entry." +echo "$host_entry" | sudo tee -a /etc/hosts > /dev/null +fi + + + +# WAIT 5 minutes maximum and test every 5 seconds if Portal up using HealthCheck API +TIME_OUT=460 +INTERVAL=20 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://portal.api.simpledemo.openecomp.org:8989/ECOMPPORTAL/portalApi/healthCheck); echo $response + + if [ "$response" == "200" ]; then + echo Portal and its database well started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if Portal is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) +done + +if [ "$TIME" -ge "$TIME_OUT" ]; then + echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... +fi + +#sleep 3m + + + +#if [ "$TIME" -ge "$TIME_OUT" ]; then +# echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... +#fi + + + + + +#Get current IP of VM +HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') +export HOST_IP=${HOST_IP} + + +docker logs deliveries_portal-apps_1 +docker logs deliveries_portal-wms_1 + + + -# docker-compose is not in /usr/bin -/opt/docker/docker-compose down -/opt/docker/docker-compose up -d diff --git a/test/csit/plans/portal/testsuite/teardown.sh b/test/csit/plans/portal/testsuite/teardown.sh index 4214c8279..e0431a72f 100644 --- a/test/csit/plans/portal/testsuite/teardown.sh +++ b/test/csit/plans/portal/testsuite/teardown.sh @@ -15,6 +15,6 @@ # limitations under the License. # -kill-instance.sh i-mock +docker kill $(docker ps -q) diff --git a/test/csit/plans/portal/testsuite/testplan.txt b/test/csit/plans/portal/testsuite/testplan.txt index 5aba3164c..d7b18a5ce 100644 --- a/test/csit/plans/portal/testsuite/testplan.txt +++ b/test/csit/plans/portal/testsuite/testplan.txt @@ -1,3 +1,3 @@ # Test suites are relative paths under [integration.git]/test/csit/tests/. # Place the suites in run order. -portal/Healthcheck +portal/testsuites -- cgit 1.2.3-korg