Add support for ODL credentials that have changed
[integration.git] / test / csit / plans / music / music-test-plan / setup.sh
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 #
17
18 #
19 # add here eventual scripts needed for music
20 #
21 echo "# music scripts calling";
22 source ${WORKSPACE}/test/csit/scripts/music/music-scripts/music_script.sh
23
24 #
25 # add here all the configuration steps eventually needed to be carried out for music CSIT testing
26 #
27 echo "# music configuration step";
28
29 CASS_IMG=nexus3.onap.org:10001/onap/music/cassandra_music:latest
30 TOMCAT_IMG=nexus3.onap.org:10001/library/tomcat:8.0
31 ZK_IMG=nexus3.onap.org:10001/library/zookeeper:3.4
32 MUSIC_IMG=nexus3.onap.org:10001/onap/music/music:latest
33 WORK_DIR=/tmp/music
34 CASS_USERNAME=nelson24
35 CASS_PASSWORD=winman123
36 MUSIC_SOURCE_PROPERTIES=${WORKSPACE}/test/csit/scripts/music/music-properties
37 MUSIC_PROPERTIES=/tmp/music/properties
38 MUSIC_LOGS=/tmp/music/logs
39 mkdir -p ${MUSIC_PROPERTIES}
40 mkdir -p ${MUSIC_LOGS}
41
42 cp ${MUSIC_SOURCE_PROPERTIES}/* ${WORK_DIR}/properties
43
44 # Create Volume for mapping war file and tomcat
45 docker volume create --name music-vol;
46
47 # Create a network for all the containers to run in.
48 docker network create music-net;
49
50 # Start Cassandra
51 docker 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};
52
53 CASSA_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-db`
54 echo "CASSANDRA_IP=${CASSA_IP}"
55 ${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${CASSA_IP} 9042
56
57 # Start Music war
58 docker run -d --name music-war -v music-vol:/app ${MUSIC_IMG};
59
60 # Start Zookeeper
61 docker run -d --name music-zk --network music-net -p "2181:2181" -p "2888:2888" -p "3888:3888" ${ZK_IMG};
62
63 ZOO_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-zk`
64 echo "ZOOKEEPER_IP=${ZOO_IP}"
65
66 # Delay  between Cassandra/Zookeeper and Tomcat
67 sleep 60;
68
69 # Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
70 docker 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};
71
72 # Connect tomcat to host bridge network so that its port can be seen. 
73 docker network connect bridge music-tomcat;
74
75 TOMCAT_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat`
76 echo "TOMCAT_IP=${TOMCAT_IP}"
77
78 ${WORKSPACE}/test/csit/scripts/music/music-scripts/wait_for_port.sh ${TOMCAT_IP} 8080
79
80
81 echo "inspect docker things for tracing purpose"
82 docker inspect music-db
83 docker inspect music-zk
84 docker inspect music-tomcat
85 docker inspect music-war
86 docker volume inspect music-vol
87 docker network inspect music-net
88
89 echo "dump music content just after music is started"
90 docker exec music-db /usr/bin/nodetool status
91 docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces'
92 docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master'
93
94
95 #
96 # add here all ROBOT_VARIABLES settings
97 #
98 echo "# music robot variables settings";
99 ROBOT_VARIABLES="-v MUSIC_HOSTNAME:http://${TOMCAT_IP} -v MUSIC_PORT:8080 -v COND_HOSTNAME:http://localhost -v COND_PORT:8091"
100
101 echo ${ROBOT_VARIABLES}
102
103
104