3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2019 Nordix Foundation.
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.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
21 # @author Waqas Ikram (waqas.ikram@est.tech)
23 MAVEN_VERSION_DIR="apache-maven-3.3.9"
24 MAVEN_TAR_FILE="$MAVEN_VERSION_DIR-bin.tar.gz"
25 MAVEN_TAR_LOCATION="https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/$MAVEN_TAR_FILE"
27 SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28 SCRIPT_NAME=$(basename $0)
29 CONFIG_DIR=$SCRIPT_HOME/config
30 ENV_FILE=$CONFIG_DIR/env
31 TEMP_DIR_PATH=$SCRIPT_HOME/temp
32 TEST_LAB_DIR_PATH=$TEMP_DIR_PATH/test_lab
33 DOCKER_COMPOSE_FILE_PATH=$SCRIPT_HOME/docker-compose.yml
34 DOCKER_COMPOSE_LOCAL_OVERRIDE_FILE=$SCRIPT_HOME/docker-compose.local.yml
35 TEAR_DOWN_SCRIPT=$SCRIPT_HOME/teardown.sh
36 CAMUNDA_SQL_SCRIPT_NAME=mariadb_engine_7.10.0.sql
37 CAMUNDA_SQL_SCRIPT_DIR=$CONFIG_DIR/camunda-sql
38 TEST_LAB_SQL_SCRIPTS_DIR=$TEST_LAB_DIR_PATH/volumes/mariadb/docker-entrypoint-initdb.d/db-sql-scripts
40 MAVEN_DIR=$TEMP_DIR_PATH/maven
41 INSTALLED_MAVEN_DIR=$MAVEN_DIR/$MAVEN_VERSION_DIR
42 MVN=$INSTALLED_MAVEN_DIR/bin/mvn
44 MVN_SETTINGS_XML="$SCRIPT_HOME/settings.xml"
45 MVN_CLEAN_INSTALL="$MVN clean install"
46 SIMULATOR_MAVEN_PROJECT_POM="$SCRIPT_HOME/so-simulators/pom.xml"
47 WAIT_FOR_WORKAROUND_SCRIPT=$CONFIG_DIR/"wait-for-workaround-job.sh"
48 WAIT_FOR_POPULATE_AAI_SCRIPT=$CONFIG_DIR/"wait-for-aai-config-job.sh"
49 WAIT_FOR_CONTAINER_SCRIPT=$CONFIG_DIR/"wait-for-container.sh"
51 echo "Running $SCRIPT_HOME/$SCRIPT_NAME ..."
53 export $(egrep -v '^#' $ENV_FILE | xargs)
55 MANDATORY_VARIABLES_NAMES=( "NEXUS_DOCKER_REPO_MSO" "DOCKER_ENVIRONMENT" "TAG" "TIME_OUT_DEFAULT_VALUE_SEC" "PROJECT_NAME" "DEFAULT_NETWORK_NAME", "ETSI_CATALOG_IMAGE_VERSION", "SOL_003_ADAPTER_IMAGE_VERSION", "ETSI_NFVO_NS_LCM_IMAGE_VERSION", "MARIADB_VERSION")
57 for var in "${MANDATORY_VARIABLES_NAMES[@]}"
59 if [ -z "${!var}" ]; then
60 echo "Missing mandatory attribute $var in $ENV_FILE"
65 if [[ ! "$TEMP_DIR_PATH" || ! -d "$TEMP_DIR_PATH" ]]; then
66 echo "Creating temporary directory $TEMP_DIR_PATH"
70 echo "Could not create $TEMP_DIR_PATH"
75 echo "Will use ${TEMP_DIR_PATH} directory"
77 if [[ ! "$MAVEN_DIR" || ! -d "$MAVEN_DIR" ]]; then
78 echo "Creating temporary maven directory $MAVEN_DIR"
82 echo "Could not create $MAVEN_DIR"
86 echo "Will use ${MAVEN_DIR} directory for maven install"
88 if [[ ! "$INSTALLED_MAVEN_DIR" || ! -d "$INSTALLED_MAVEN_DIR" ]]; then
89 echo "Installing maven ..."
93 if [[ ! "$CURL" ]]; then
94 echo "curl command is not installed"
95 echo "Unable to execute test plan"
98 curl -O $MAVEN_TAR_LOCATION
101 if [[ ! "$TAR" ]]; then
102 echo "tar command is not installed"
103 echo "Unable to execute test plan"
107 tar -xzvf $MAVEN_TAR_FILE
109 echo "Finished installing maven ..."
112 echo "Maven installed under directory $INSTALLED_MAVEN_DIR"
116 if [ $? -ne 0 ]; then
117 echo "Unable to run mvn -v command"
123 echo "Will build simulator project using $MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML"
124 $MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML
126 if [ $? -ne 0 ]; then
127 echo "Maven build failed"
131 echo "Will clone docker-config project ... "
134 if [[ -d "$TEST_LAB_DIR_PATH" ]]; then
135 echo "$TEST_LAB_DIR_PATH already exists"
136 echo "Removing $TEST_LAB_DIR_PATH directory ..."
137 rm -rf $TEST_LAB_DIR_PATH
140 git clone http://gerrit.onap.org/r/so/docker-config.git $TEST_LAB_DIR_PATH
142 echo "Replacing $CAMUNDA_SQL_SCRIPT_NAME ..."
143 rm -rf $TEST_LAB_SQL_SCRIPTS_DIR/$CAMUNDA_SQL_SCRIPT_NAME
144 cp $CAMUNDA_SQL_SCRIPT_DIR/$CAMUNDA_SQL_SCRIPT_NAME $TEST_LAB_SQL_SCRIPTS_DIR
146 export TEST_LAB_DIR=$TEST_LAB_DIR_PATH
147 export CONFIG_DIR_PATH=$CONFIG_DIR
149 if [ "$DOCKER_ENVIRONMENT" == "remote" ]; then
150 echo "Starting docker containers with remote images ..."
151 docker-compose -f $DOCKER_COMPOSE_FILE_PATH -p $PROJECT_NAME up -d
152 elif [ "$DOCKER_ENVIRONMENT" == "local" ]; then
153 echo "Starting docker containers with local images ..."
154 docker-compose -f $DOCKER_COMPOSE_FILE_PATH -f $DOCKER_COMPOSE_LOCAL_OVERRIDE_FILE -p $PROJECT_NAME up -d
156 echo "DOCKER_ENVIRONMENT not set correctly in $ENV_FILE. Allowed values: local | remote"
160 echo "Sleeping for 3m"
165 echo "Will execute $WAIT_FOR_WORKAROUND_SCRIPT script"
166 $WAIT_FOR_WORKAROUND_SCRIPT
168 if [ $? -ne 0 ]; then
169 echo "ERROR: $WAIT_FOR_WORKAROUND_SCRIPT failed"
170 echo "Will stop running docker containers . . ."
175 echo "Will execute $WAIT_FOR_POPULATE_AAI_SCRIPT script"
176 $WAIT_FOR_POPULATE_AAI_SCRIPT
178 if [ $? -ne 0 ]; then
179 echo "ERROR: $WAIT_FOR_POPULATE_AAI_SCRIPT failed"
180 echo "Will stop running docker containers . . ."
185 PODS_NAMES=( "api-handler-infra" "modeling-etsicatalog" "so-etsi-nfvo-ns-lcm")
187 for pod in "${PODS_NAMES[@]}"
189 echo "Will execute $WAIT_FOR_CONTAINER_SCRIPT to wait for $pod container to start up"
190 $WAIT_FOR_CONTAINER_SCRIPT -c "$pod" -t "300" -n "$DEFAULT_NETWORK_NAME"
192 if [ $? -ne 0 ]; then
193 echo "ERROR: $WAIT_FOR_CONTAINER_SCRIPT for pod: $pod failed"
194 echo "Will stop running docker containers . . ."
201 ROBOT_VARIABLES="-v REPO_IP:${REPO_IP}"
203 # install required Robot libraries
204 pip install robotframework-archivelibrary
206 echo "Finished executing $SCRIPT_HOME/$SCRIPT_NAME"