Leonardo Bellini | d452192 | 2018-03-01 08:48:10 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Leonardo Bellini | d280c26 | 2018-03-09 04:26:58 -0600 | [diff] [blame] | 17 | echo "### This is ${WORKSPACE}/test/csit/scripts/optf-has/has/has_script.sh" |
Leonardo Bellini | d452192 | 2018-03-01 08:48:10 -0600 | [diff] [blame] | 18 | # |
| 19 | # add here whatever commands is needed to prepare the optf/has CSIT testing |
| 20 | # |
| 21 | |
Leonardo Bellini | d280c26 | 2018-03-09 04:26:58 -0600 | [diff] [blame] | 22 | # assume the base is /tmp dir |
| 23 | DIR=/tmp |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 24 | |
| 25 | # the directory of the script |
| 26 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 27 | echo ${DIR} |
| 28 | cd ${DIR} |
| 29 | |
| 30 | # the temp directory used, within $DIR |
| 31 | # omit the -p parameter to create a temporal directory in the default location |
| 32 | WORK_DIR=`mktemp -d -p "$DIR"` |
| 33 | echo ${WORK_DIR} |
| 34 | |
| 35 | cd ${WORK_DIR} |
| 36 | |
| 37 | # check if tmp dir was created |
| 38 | if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then |
| 39 | echo "Could not create temp dir" |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 43 | git clone https://gerrit.onap.org/r/optf/has |
| 44 | cd has |
| 45 | cd conductor/docker |
| 46 | |
Leonardo Bellini | b63ed79 | 2018-03-13 08:37:24 -0500 | [diff] [blame] | 47 | echo "i am ${USER} : only non jenkins users need proxy settings" |
| 48 | if [ ${USER} != 'jenkins' ]; then |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 49 | |
Leonardo Bellini | b63ed79 | 2018-03-13 08:37:24 -0500 | [diff] [blame] | 50 | # Comment sed for true integration lab |
Leonardo Bellini | 50ee9d6 | 2018-03-15 04:39:25 -0500 | [diff] [blame] | 51 | sed -i -e "s%FROM python:2\.7%FROM python:2\.7\\nENV http_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV https_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV no_proxy localhost,0,1,2,3,4,5,6,7,8,9%g" api/Dockerfile |
| 52 | sed -i -e "s%FROM python:2\.7%FROM python:2\.7\\nENV http_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV https_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV no_proxy localhost,0,1,2,3,4,5,6,7,8,9%g" controller/Dockerfile |
| 53 | sed -i -e "s%FROM python:2\.7%FROM python:2\.7\\nENV http_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV https_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV no_proxy localhost,0,1,2,3,4,5,6,7,8,9%g" data/Dockerfile |
| 54 | sed -i -e "s%FROM python:2\.7%FROM python:2\.7\\nENV http_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV https_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV no_proxy localhost,0,1,2,3,4,5,6,7,8,9%g" reservation/Dockerfile |
| 55 | sed -i -e "s%FROM python:2\.7%FROM python:2\.7\\nENV http_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV https_proxy http:\/\/one\.proxy\.att\.com:8080\\nENV no_proxy localhost,0,1,2,3,4,5,6,7,8,9%g" solver/Dockerfile |
Leonardo Bellini | b63ed79 | 2018-03-13 08:37:24 -0500 | [diff] [blame] | 56 | |
| 57 | fi |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 58 | |
| 59 | # ./build-dockers.sh |
| 60 | docker build -t api api/ |
| 61 | docker build -t controller controller/ |
| 62 | docker build -t data data/ |
| 63 | docker build -t solver solver/ |
| 64 | docker build -t reservation reservation/ |
| 65 | |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 66 | # create directory for volume and copy configuration file |
| 67 | mkdir -p /tmp/conductor/properties |
Leonardo Bellini | 50ee9d6 | 2018-03-15 04:39:25 -0500 | [diff] [blame] | 68 | mkdir -p /tmp/conductor/logs |
Leonardo Bellini | d280c26 | 2018-03-09 04:26:58 -0600 | [diff] [blame] | 69 | cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/conductor.conf.onap /tmp/conductor/properties/conductor.conf |
| 70 | cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.cer /tmp/conductor/properties/cert.cer |
| 71 | cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.key /tmp/conductor/properties/cert.key |
| 72 | cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.pem /tmp/conductor/properties/cert.pem |
Leonardo Bellini | b63ed79 | 2018-03-13 08:37:24 -0500 | [diff] [blame] | 73 | #chmod -R 777 /tmp/conductor/properties |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 74 | |
Leonardo Bellini | 50ee9d6 | 2018-03-15 04:39:25 -0500 | [diff] [blame] | 75 | MUSIC_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat` |
| 76 | echo "MUSIC_IP=${MUSIC_IP}" |
| 77 | |
| 78 | # change MUSIC reference |
| 79 | sed -i -e "s%localhost:8080/MUSIC%${MUSIC_IP}:8080/MUSIC%g" /tmp/conductor/properties/conductor.conf |
| 80 | |
| 81 | |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 82 | # run docker containers |
Leonardo Bellini | d280c26 | 2018-03-09 04:26:58 -0600 | [diff] [blame] | 83 | docker run -d --name cond-data -v /tmp/conductor/properties/conductor.conf:/usr/local/bin/conductor.conf -v /tmp/conductor/properties/cert.key:/usr/local/bin/cert.key -v /tmp/conductor/properties/cert.cer:/usr/local/bin/cert.cer -v /tmp/conductor/properties/cert.pem:/usr/local/bin/cert.pem data |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 84 | docker run -d --name cond-cont -v /tmp/conductor/properties/conductor.conf:/usr/local/bin/conductor.conf controller |
| 85 | docker run -d --name cond-api -p 8091:8091 -v /tmp/conductor/properties/conductor.conf:/usr/local/bin/conductor.conf api |
| 86 | docker run -d --name cond-solv -v /tmp/conductor/properties/conductor.conf:/usr/local/bin/conductor.conf solver |
| 87 | docker run -d --name cond-resv -v /tmp/conductor/properties/conductor.conf:/usr/local/bin/conductor.conf reservation |
| 88 | |
Leonardo Bellini | 50ee9d6 | 2018-03-15 04:39:25 -0500 | [diff] [blame] | 89 | COND_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' cond-api` |
| 90 | ${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${COND_IP} 8091 |
| 91 | |
Leonardo Bellini | 3a275ec | 2018-03-08 11:48:47 -0600 | [diff] [blame] | 92 | # wait a while before continuing |
| 93 | sleep 30 |
Leonardo Bellini | 50ee9d6 | 2018-03-15 04:39:25 -0500 | [diff] [blame] | 94 | |
| 95 | echo "inspect docker things for tracing purpose" |
| 96 | docker inspect cond-data |
| 97 | docker inspect cond-cont |
| 98 | docker inspect cond-api |
| 99 | docker inspect cond-solv |
| 100 | docker inspect cond-resv |
| 101 | |
| 102 | docker exec -it music-db /usr/bin/nodetool status |
| 103 | docker exec -it music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces' |
| 104 | docker exec -it music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master' |