blob: 1b4896ef686478375c297e5511a6663be0f5568d [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/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#
17
18#
19# add here eventual scripts needed for music
20#
21echo "########## music scripts calling ##########";
Gary Wu13111e92018-09-27 11:31:33 -070022source ${WORKSPACE}/scripts/music/music-scripts/music_script.sh
Gary Wu9abb61c2018-09-27 10:38:50 -070023
24#
25# add here all the configuration steps eventually needed to be carried out for music CSIT testing
26#
27echo "########## music configuration step ##########";
Thomas Nelson4a9119a2018-10-22 02:26:04 -040028CASS_IMG=nexus3.onap.org:10001/onap/music/cassandra_3_11:3.0.23
29CASS_IMG_JOB=nexus3.onap.org:10001/onap/music/cassandra_job:3.0.23
Gary Wu9abb61c2018-09-27 10:38:50 -070030TOMCAT_IMG=nexus3.onap.org:10001/library/tomcat:8.5
31ZK_IMG=nexus3.onap.org:10001/library/zookeeper:3.4
32BUSYBOX_IMG=nexus3.onap.org:10001/library/busybox:latest
Thomas Nelson4a9119a2018-10-22 02:26:04 -040033MUSIC_IMG=nexus3.onap.org:10001/onap/music/music:3.0.23
Gary Wu9abb61c2018-09-27 10:38:50 -070034TT=10
35WORK_DIR=/tmp/music
36CASS_USERNAME=nelson24
37CASS_PASSWORD=winman123
Gary Wu13111e92018-09-27 11:31:33 -070038MUSIC_SOURCE_PROPERTIES=${WORKSPACE}/scripts/music/music-properties
Gary Wu9abb61c2018-09-27 10:38:50 -070039MUSIC_PROPERTIES=/tmp/music/properties
40MUSIC_LOGS=/tmp/music/logs
Gary Wu13111e92018-09-27 11:31:33 -070041CQL_FILES=${WORKSPACE}/scripts/music/cql
Gary Wu9abb61c2018-09-27 10:38:50 -070042MUSIC_TRIGGER_DIR=/tmp/triggers
43TRIGGER_JAR=musictrigger-0.1.0.jar
44TRIGGER_JAR_URL=https://nexus.onap.org/service/local/repositories/autorelease-72298/content/org/onap/music/musictrigger/0.1.0/musictrigger-0.1.0.jar
45
46mkdir -p ${MUSIC_PROPERTIES}
47mkdir -p ${MUSIC_LOGS}
48mkdir -p ${MUSIC_LOGS}/MUSIC
49mkdir -p /tmp/triggers
50
51# Get Trigger
52echo "########## Get Trigger Jar ##########"
53curl -o $MUSIC_TRIGGER_DIR/$TRIGGER_JAR $TRIGGER_JAR_URL
54
55cp ${MUSIC_SOURCE_PROPERTIES}/* ${WORK_DIR}/properties
56
57# Create Volume for mapping war file and tomcat
58echo "########## create music-vol ##########"
59docker volume create --name music-vol;
60
61# Create a network for all the containers to run in.
62echo "########## create music-net ##########"
63docker network create music-net;
64
65# Start Cassandra
66echo "########## Start Cassandra (music-db) ##########"
67docker run -d --name music-db --network music-net -p "7000:7000" -p "7001:7001" -p "7199:7199" -p "9042:9042" -p "9160:9160" \
68-v $MUSIC_TRIGGER_DIR/$TRIGGER_JAR:/etc/cassandra/triggers/$TRIGGER_JAR \
69${CASS_IMG};
70
Tschaen, Brendana8bbfd32018-11-05 17:17:01 -050071# See if cassandra is up.
72echo "########## Running Test to see if Cassandra is up ##########"
Gary Wu9abb61c2018-09-27 10:38:50 -070073CASSA_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-db`
74echo "CASSANDRA_IP=${CASSA_IP}"
Gary Wu13111e92018-09-27 11:31:33 -070075${WORKSPACE}/scripts/optf-has/has/wait_for_port.sh ${CASSA_IP} 9042
Gary Wu9abb61c2018-09-27 10:38:50 -070076
Thomas Nelson4a9119a2018-10-22 02:26:04 -040077# Sleep 60 seconds to ensure Cassandra is up and running.
78sleep 60;
Tschaen, Brendana8bbfd32018-11-05 17:17:01 -050079
Gary Wu9abb61c2018-09-27 10:38:50 -070080# Check to see if Keyspaces are there.
81docker exec music-db cqlsh -u cassandra -p cassandra -e "DESCRIBE keyspaces;"
82
Gary Wu9abb61c2018-09-27 10:38:50 -070083# Load data into Cassandra via Cassandra Job
84echo "########## Running Cassandra Job (music-job) to load cql files ##########"
85docker run -d --name music-job --network music-net \
86-v $CQL_FILES/admin.cql:/cql/admin.cql \
87-v $CQL_FILES/admin_pw.cql:/cql/admin_pw.cql \
88-v $CQL_FILES/extra:/cql/extra \
89-e PORT=9042 \
90-e CASS_HOSTNAME=music-db \
91-e USERNAME=$CASS_USERNAME \
92-e PASSWORD=$CASS_PASSWORD \
Thomas Nelson4a9119a2018-10-22 02:26:04 -040093$CASS_IMG_JOB
94
95sleep 70;
96
Gary Wu9abb61c2018-09-27 10:38:50 -070097# Logs
98echo "########## Cassandra Job logs ##########"
99docker logs music-job
Thomas Nelson4a9119a2018-10-22 02:26:04 -0400100# Check to see if Keyspaces are there.
101# "############## Check if new username and password work ##########"
102docker exec music-db cqlsh -u $CASS_USERNAME -p $CASS_PASSWORD -e "DESCRIBE keyspaces;"
103# Check to see if Keyspaces are there.
104# "############## Check if original username and password work ##########"
105docker exec music-db cqlsh -u cassandra -p cassandra -e "DESCRIBE keyspaces;"
106# Check to see if Keyspaces are there.
107# "############## Check if new cassandra username and password work ##########"
108docker exec music-db cqlsh -u cassandra -p SomeLongRandomStringNoonewillthinkof -e "DESCRIBE keyspaces;"
109
Gary Wu9abb61c2018-09-27 10:38:50 -0700110
111# Start Music war
112echo "########## Start music-war ##########"
113docker run -d --name music-war -v music-vol:/app ${MUSIC_IMG};
114
115# Start Zookeeper
116echo "########## Start zookeeper (music-zk) ##########"
117docker run -d --name music-zk --network music-net -p "2181:2181" -p "2888:2888" -p "3888:3888" ${ZK_IMG};
118
119ZOO_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-zk`
120echo "ZOOKEEPER_IP=${ZOO_IP}"
121
122# Delay between Cassandra/Zookeeper and Tomcat
Thomas Nelson4a9119a2018-10-22 02:26:04 -0400123sleep 120;
Gary Wu9abb61c2018-09-27 10:38:50 -0700124
125# Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
126echo "########## Start Tomcat (music-tomcat) ##########"
127docker 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};
128
129# Connect tomcat to host bridge network so that its port can be seen.
130echo "########## Create Bridge for Tomcat ##########"
131docker network connect bridge music-tomcat;
132
133TOMCAT_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat`
134echo "TOMCAT_IP=${TOMCAT_IP}"
135
Gary Wu13111e92018-09-27 11:31:33 -0700136${WORKSPACE}/scripts/music/music-scripts/wait_for_port.sh ${TOMCAT_IP} 8080
Gary Wu9abb61c2018-09-27 10:38:50 -0700137
138sleep 20;
139echo "########## TOMCAT Logs ##########"
140docker logs music-tomcat
141# Needed only if we need to look at localhost logs.
142echo "########## MUSIC localhost Log ##########"
143docker exec music-tomcat /bin/bash -c "cat /usr/local/tomcat/logs/localhost*"
144
145echo "########## MUSIC Log ##########"
146ls -al $MUSIC_LOGS/MUSIC
147docker exec music-tomcat /bin/bash -c "cat /opt/app/music/logs/MUSIC/music.log"
148#echo "########## MUSIC error log ##########"
149#docker exec music-tomcat /bin/bash -c "cat /opt/app/music/logs/MUSIC/error.log"
150
151echo "########## inspect docker things for tracing purpose ##########"
152docker inspect music-db
153docker inspect music-zk
154docker inspect music-tomcat
155docker inspect music-war
156docker volume inspect music-vol
157docker network inspect music-net
158
159echo "########## dump music content just after music is started ##########"
160docker exec music-db /usr/bin/nodetool status
161docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces'
162docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'DESCRIBE keyspace admin'
163docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master'
164
165
166#
167# add here all ROBOT_VARIABLES settings
168#
169echo "########## music robot variables settings ##########";
170ROBOT_VARIABLES="-v MUSIC_HOSTNAME:http://${TOMCAT_IP} -v MUSIC_PORT:8080 -v COND_HOSTNAME:http://localhost -v COND_PORT:8091"
171
172echo ${ROBOT_VARIABLES}
173
174
175