blob: 1e978c2f9639cc813371606e7b24bb7803ce18e2 [file] [log] [blame]
Leonardo Bellini50ee9d62018-03-15 04:39:25 -05001#!/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#
17echo "### This is ${WORKSPACE}/test/csit/scripts/optf-has/has/music_script.sh"
18#
19# add here whatever commands is needed to prepare the music setup for optf-has CSIT testing
20#
21
22#
23# add here all the configuration steps eventually needed to be carried out for music CSIT testing
24#
25echo "# music configuration step";
26
27CASS_IMG=nexus3.onap.org:10001/onap/music/cassandra_music:latest
28TOMCAT_IMG=nexus3.onap.org:10001/library/tomcat:8.0
29ZK_IMG=nexus3.onap.org:10001/library/zookeeper:3.4
30MUSIC_IMG=nexus3.onap.org:10001/onap/music/music:latest
31WORK_DIR=/tmp/music
32CASS_USERNAME=nelson24
33CASS_PASSWORD=winman123
34MUSIC_SOURCE_PROPERTIES=${WORKSPACE}/test/csit/scripts/optf-has/has/music-properties
35MUSIC_PROPERTIES=/tmp/music/properties
36MUSIC_LOGS=/tmp/music/logs
37mkdir -p ${MUSIC_PROPERTIES}
38mkdir -p ${MUSIC_LOGS}
39
40cp ${MUSIC_SOURCE_PROPERTIES}/* ${WORK_DIR}/properties
41
42# Create Volume for mapping war file and tomcat
43docker volume create --name music-vol;
44
45# Create a network for all the containers to run in.
46docker network create music-net;
47
48# Start Cassandra
49docker run -d --name music-db --network music-net -p "7000:7000" -p "7001:7001" -p "7199:7199" -p "9042:9042" -p "9160:9160" -e CASSUSER=${CASS_USERNAME} -e CASSPASS=${CASS_PASSWORD} ${CASS_IMG};
Leonardo Bellini67bebbd2018-04-03 03:58:40 -050050#CASSA_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-db`
51CASSA_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-db`
52echo "CASSANDRA_IP=${CASSA_IP}"
53${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${CASSA_IP} 9042
Dileep Ranganathanefea1b52018-07-25 05:40:08 -070054sleep 60
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050055# Start Music war
56docker run -d --name music-war -v music-vol:/app ${MUSIC_IMG};
Dileep Ranganathanefea1b52018-07-25 05:40:08 -070057sleep 15
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050058# Start Zookeeper
59docker run -d --name music-zk --network music-net -p "2181:2181" -p "2888:2888" -p "3888:3888" ${ZK_IMG};
Leonardo Bellini67bebbd2018-04-03 03:58:40 -050060#ZOO_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-zk`
61ZOO_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-zk`
62echo "ZOOKEEPER_IP=${ZOO_IP}"
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050063
Leonardo Bellini67bebbd2018-04-03 03:58:40 -050064# Delay between Cassandra/Zookeeper and Tomcat
65sleep 60;
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050066
67# Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
68docker run -d --name music-tomcat --network music-net -p "8080:8080" -v music-vol:/usr/local/tomcat/webapps -v ${WORK_DIR}/properties:/opt/app/music/etc:ro -v ${WORK_DIR}/logs:/opt/app/music/logs ${TOMCAT_IMG};
69
70# Connect tomcat to host bridge network so that its port can be seen.
71docker network connect bridge music-tomcat;
72
73#
74# add here below the start of all docker containers needed for music CSIT testing
75#
76
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050077TOMCAT_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat`
78echo "TOMCAT_IP=${TOMCAT_IP}"
79
80${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${TOMCAT_IP} 8080
81
Leonardo Bellini853238d2018-03-27 05:42:06 -050082# wait a while to make sure music is totally up and configured
Dileep Ranganathanefea1b52018-07-25 05:40:08 -070083sleep 60
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050084
85echo "inspect docker things for tracing purpose"
86docker inspect music-db
87docker inspect music-zk
88docker inspect music-tomcat
89docker inspect music-war
90docker volume inspect music-vol
91docker network inspect music-net
92
Leonardo Bellini67bebbd2018-04-03 03:58:40 -050093echo "dump music content just after music is started"
94docker exec music-db /usr/bin/nodetool status
95docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces'
96docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master'
Leonardo Bellini50ee9d62018-03-15 04:39:25 -050097
98
99
100