blob: 75e75275f5f729b5104d13b24fd455927bdc9b38 [file] [log] [blame]
waqas.ikramb01df8b2019-07-09 16:14:17 +00001#!/bin/bash
2#
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END=========================================================
20
21# @author Waqas Ikram (waqas.ikram@est.tech)
22
23MAVEN_VERSION_DIR="apache-maven-3.3.9"
24MAVEN_TAR_FILE="$MAVEN_VERSION_DIR-bin.tar.gz"
25MAVEN_TAR_LOCATION="http://apache.claz.org/maven/maven-3/3.3.9/binaries/$MAVEN_TAR_FILE"
26
27SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28SCRIPT_NAME=$(basename $0)
waqas.ikram7d753292019-07-18 16:41:17 +000029CONFIG_DIR=$SCRIPT_HOME/config
30ENV_FILE=$CONFIG_DIR/env
waqas.ikramb01df8b2019-07-09 16:14:17 +000031TEMP_DIR_PATH=$SCRIPT_HOME/temp
waqas.ikram7d753292019-07-18 16:41:17 +000032TEST_LAB_DIR_PATH=$TEMP_DIR_PATH/test_lab
33DOCKER_COMPOSE_FILE_PATH=$SCRIPT_HOME/docker-compose.yml
waqas.ikramb01df8b2019-07-09 16:14:17 +000034
35MAVEN_DIR=$TEMP_DIR_PATH/maven
36INSTALLED_MAVEN_DIR=$MAVEN_DIR/$MAVEN_VERSION_DIR
37MVN=$INSTALLED_MAVEN_DIR/bin/mvn
38MVN_VERSION="$MVN -v"
39MVN_SETTINGS_XML="$SCRIPT_HOME/settings.xml"
40MVN_CLEAN_INSTALL="$MVN clean install"
41SIMULATOR_MAVEN_PROJECT_POM="$SCRIPT_HOME/so-simulators/pom.xml"
42
43echo "Running $SCRIPT_HOME/$SCRIPT_NAME ..."
44
waqas.ikram7d753292019-07-18 16:41:17 +000045export $(egrep -v '^#' $ENV_FILE | xargs)
46
waqas.ikramb01df8b2019-07-09 16:14:17 +000047if [[ ! "$TEMP_DIR_PATH" || ! -d "$TEMP_DIR_PATH" ]]; then
48 echo "Creating temporary directory $TEMP_DIR_PATH"
49 mkdir $TEMP_DIR_PATH
50
51 if [ $? -ne 0 ]; then
52 echo "Could not create $TEMP_DIR_PATH"
53 exit 1
54 fi
55
56fi
57echo "Will use ${TEMP_DIR_PATH} directory"
58
59if [[ ! "$MAVEN_DIR" || ! -d "$MAVEN_DIR" ]]; then
60 echo "Creating temporary maven directory $MAVEN_DIR"
61 mkdir $MAVEN_DIR
62
63 if [ $? -ne 0 ]; then
64 echo "Could not create $MAVEN_DIR"
65 exit 1
66 fi
67fi
68echo "Will use ${MAVEN_DIR} directory for maven install"
69
70if [[ ! "$INSTALLED_MAVEN_DIR" || ! -d "$INSTALLED_MAVEN_DIR" ]]; then
71 echo "Installing maven ..."
72 cd $MAVEN_DIR
73
74 CURL=`which curl`
75 if [[ ! "$CURL" ]]; then
76 echo "curl command is not installed"
77 echo "Unable to execute test plan"
78 exit 1
79 fi
80 curl -O $MAVEN_TAR_LOCATION
81
82 TAR=`which tar`
83 if [[ ! "$TAR" ]]; then
84 echo "tar command is not installed"
85 echo "Unable to execute test plan"
86 exit 1
87 fi
88
89 tar -xzvf apache-maven-3.3.9-bin.tar.gz
90
91 echo "Finished installing maven ..."
92fi
93
94echo "Maven installed under directory $INSTALLED_MAVEN_DIR"
95
96$MVN_VERSION
97
98if [ $? -ne 0 ]; then
99 echo "Unable to run mvn -v command"
100 exit 1
101fi
102
103cd $SCRIPT_HOME
104
105echo "Will build simulator project using $MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML"
106$MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML
107
waqas.ikram7d753292019-07-18 16:41:17 +0000108if [ $? -ne 0 ]; then
109 echo "Maven build failed"
110 exit 1
111fi
waqas.ikramb01df8b2019-07-09 16:14:17 +0000112
waqas.ikram7d753292019-07-18 16:41:17 +0000113echo "Will clone docker-config project ... "
waqas.ikramb01df8b2019-07-09 16:14:17 +0000114
waqas.ikram7d753292019-07-18 16:41:17 +0000115
116if [[ -d "$TEST_LAB_DIR_PATH" ]]; then
117 echo "$TEST_LAB_DIR_PATH already exists"
118 echo "Removing $TEST_LAB_DIR_PATH directory ..."
119 rm -rf $TEST_LAB_DIR_PATH
120fi
121
122git clone http://gerrit.onap.org/r/so/docker-config.git $TEST_LAB_DIR_PATH
123
124
125export TEST_LAB_DIR=$TEST_LAB_DIR_PATH
126export CONFIG_DIR_PATH=$CONFIG_DIR
127
128docker-compose -f $DOCKER_COMPOSE_FILE_PATH up -d
129
130echo "Sleeping for 3m"
131sleep 3m
waqas.ikramb01df8b2019-07-09 16:14:17 +0000132
133REPO_IP='127.0.0.1'
134ROBOT_VARIABLES="-v REPO_IP:${REPO_IP}"
135
136echo "Finished executing $SCRIPT_HOME/$SCRIPT_NAME"