blob: f6c2e7d511223f5bbb1d630f446c870b03a72b7e [file] [log] [blame]
Leonardo Bellinid4521922018-03-01 08:48:10 -06001#!/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 Bellinid280c262018-03-09 04:26:58 -060017echo "### This is ${WORKSPACE}/test/csit/scripts/optf-has/has/has_script.sh"
Leonardo Bellinid4521922018-03-01 08:48:10 -060018#
19# add here whatever commands is needed to prepare the optf/has CSIT testing
20#
21
Leonardo Bellinid280c262018-03-09 04:26:58 -060022# assume the base is /tmp dir
23DIR=/tmp
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060024
25# the directory of the script
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060026echo ${DIR}
27cd ${DIR}
28
29# the temp directory used, within $DIR
30# omit the -p parameter to create a temporal directory in the default location
31WORK_DIR=`mktemp -d -p "$DIR"`
32echo ${WORK_DIR}
33
34cd ${WORK_DIR}
35
36# check if tmp dir was created
37if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
38 echo "Could not create temp dir"
39 exit 1
40fi
41
Leonardo Bellinic26cb0b2018-03-19 11:49:36 -050042#git clone https://gerrit.onap.org/r/optf/has
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060043cd has
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060044
Leonardo Bellinib0995b42018-03-17 05:26:31 -050045echo "i am ${USER} : only non jenkins users may need proxy settings"
Leonardo Bellinib63ed792018-03-13 08:37:24 -050046if [ ${USER} != 'jenkins' ]; then
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060047
Leonardo Bellinib0995b42018-03-17 05:26:31 -050048 # add proxy settings into this script when you work behind a proxy
49 ${WORKSPACE}/test/csit/scripts/optf-has/has/has_proxy_settings.sh ${WORK_DIR}
Leonardo Bellinib63ed792018-03-13 08:37:24 -050050
51fi
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060052
Leonardo Bellinib0995b42018-03-17 05:26:31 -050053# check Dockerfile content
Leonardo Bellinic26cb0b2018-03-19 11:49:36 -050054# cat conductor/docker/Dockerfile
Leonardo Bellinib0995b42018-03-17 05:26:31 -050055
Leonardo Bellinic26cb0b2018-03-19 11:49:36 -050056#./build-dockers.sh
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060057
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060058# create directory for volume and copy configuration file
Leonardo Bellinib0995b42018-03-17 05:26:31 -050059# run docker containers
60COND_CONF=/tmp/conductor/properties/conductor.conf
61LOG_CONF=/tmp/conductor/properties/log.conf
Leonardo Bellinic26cb0b2018-03-19 11:49:36 -050062IMAGE_NAME=nexus3.onap.org:10001/onap/optf-has
Leonardo Bellinib0995b42018-03-17 05:26:31 -050063CERT=/tmp/conductor/properties/cert.cer
64KEY=/tmp/conductor/properties/cert.key
65BUNDLE=/tmp/conductor/properties/cert.pem
66
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060067mkdir -p /tmp/conductor/properties
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050068mkdir -p /tmp/conductor/logs
Leonardo Bellinid280c262018-03-09 04:26:58 -060069cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/conductor.conf.onap /tmp/conductor/properties/conductor.conf
Leonardo Bellinib0995b42018-03-17 05:26:31 -050070cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/log.conf.onap /tmp/conductor/properties/log.conf
Leonardo Bellinid280c262018-03-09 04:26:58 -060071cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.cer /tmp/conductor/properties/cert.cer
72cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.key /tmp/conductor/properties/cert.key
73cp ${WORKSPACE}/test/csit/scripts/optf-has/has/has-properties/cert.pem /tmp/conductor/properties/cert.pem
Leonardo Bellinib63ed792018-03-13 08:37:24 -050074#chmod -R 777 /tmp/conductor/properties
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060075
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050076MUSIC_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat`
77echo "MUSIC_IP=${MUSIC_IP}"
78
Leonardo Bellinib0995b42018-03-17 05:26:31 -050079# change MUSIC reference to the local instance
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050080sed -i -e "s%localhost:8080/MUSIC%${MUSIC_IP}:8080/MUSIC%g" /tmp/conductor/properties/conductor.conf
81
Leonardo Bellinib0995b42018-03-17 05:26:31 -050082docker run -d --name cond-cont -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-controller --config-file=/usr/local/bin/conductor.conf
83docker run -d --name cond-api -p "8091:8091" -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-api --port=8091 -- --config-file=/usr/local/bin/conductor.conf
84docker run -d --name cond-solv -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-solver --config-file=/usr/local/bin/conductor.conf
85docker run -d --name cond-resv -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-reservation --config-file=/usr/local/bin/conductor.conf
86docker run -d --name cond-data -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${CERT}:/usr/local/bin/cert.cer -v ${KEY}:/usr/local/bin/cert.key -v ${BUNDLE}:/usr/local/bin/cert.pem ${IMAGE_NAME}:latest python /usr/local/bin/conductor-data --config-file=/usr/local/bin/conductor.conf
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060087
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050088COND_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' cond-api`
89${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${COND_IP} 8091
90
Leonardo Bellini3a275ec2018-03-08 11:48:47 -060091# wait a while before continuing
92sleep 30
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050093
94echo "inspect docker things for tracing purpose"
95docker inspect cond-data
96docker inspect cond-cont
97docker inspect cond-api
98docker inspect cond-solv
99docker inspect cond-resv
100
101docker exec -it music-db /usr/bin/nodetool status
102docker exec -it music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces'
103docker exec -it music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master'