Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -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 | # |
| 17 | |
| 18 | # |
| 19 | # add here eventual scripts needed for music |
| 20 | # |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 21 | echo "# music scripts calling"; |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 22 | source ${WORKSPACE}/test/csit/scripts/music/music-scripts/music_script.sh |
| 23 | |
| 24 | # |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 25 | # add here all the configuration steps eventually needed to be carried out for music CSIT testing |
| 26 | # |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 27 | echo "# music configuration step"; |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 28 | |
| 29 | CASS_IMG=nexus3.onap.org:10001/onap/music/cassandra_music:latest |
Nelson,Thomas(tn1381)(arthurdent3) | 9f3cab8 | 2018-09-05 14:06:45 -0400 | [diff] [blame^] | 30 | TOMCAT_IMG=nexus3.onap.org:10001/library/tomcat:8.5 |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 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 |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 36 | MUSIC_SOURCE_PROPERTIES=${WORKSPACE}/test/csit/scripts/music/music-properties |
| 37 | MUSIC_PROPERTIES=/tmp/music/properties |
| 38 | MUSIC_LOGS=/tmp/music/logs |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 39 | mkdir -p ${MUSIC_PROPERTIES} |
| 40 | mkdir -p ${MUSIC_LOGS} |
Nelson,Thomas(tn1381)(arthurdent3) | 9f3cab8 | 2018-09-05 14:06:45 -0400 | [diff] [blame^] | 41 | mkdir -p ${MUSIC_LOGS}/MUSIC |
| 42 | |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 43 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 44 | cp ${MUSIC_SOURCE_PROPERTIES}/* ${WORK_DIR}/properties |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 45 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 46 | # Create Volume for mapping war file and tomcat |
| 47 | docker volume create --name music-vol; |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 48 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 49 | # Create a network for all the containers to run in. |
| 50 | docker network create music-net; |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 51 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 52 | # Start Cassandra |
| 53 | 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}; |
| 54 | |
Leonardo Bellini | 6515d69 | 2018-04-03 09:48:43 -0500 | [diff] [blame] | 55 | CASSA_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-db` |
| 56 | echo "CASSANDRA_IP=${CASSA_IP}" |
| 57 | ${WORKSPACE}/test/csit/scripts/optf-has/has/wait_for_port.sh ${CASSA_IP} 9042 |
| 58 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 59 | # Start Music war |
| 60 | docker run -d --name music-war -v music-vol:/app ${MUSIC_IMG}; |
| 61 | |
| 62 | # Start Zookeeper |
| 63 | docker run -d --name music-zk --network music-net -p "2181:2181" -p "2888:2888" -p "3888:3888" ${ZK_IMG}; |
| 64 | |
Leonardo Bellini | 6515d69 | 2018-04-03 09:48:43 -0500 | [diff] [blame] | 65 | ZOO_IP=`docker inspect -f '{{ $network := index .NetworkSettings.Networks "music-net" }}{{ $network.IPAddress}}' music-zk` |
| 66 | echo "ZOOKEEPER_IP=${ZOO_IP}" |
| 67 | |
| 68 | # Delay between Cassandra/Zookeeper and Tomcat |
| 69 | sleep 60; |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 70 | |
| 71 | # Start Up tomcat - Needs to have properties,logs dir and war file volume mapped. |
| 72 | 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}; |
| 73 | |
| 74 | # Connect tomcat to host bridge network so that its port can be seen. |
| 75 | docker network connect bridge music-tomcat; |
| 76 | |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 77 | TOMCAT_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat` |
| 78 | echo "TOMCAT_IP=${TOMCAT_IP}" |
| 79 | |
Leonardo Bellini | 293263e | 2018-03-09 07:34:07 -0600 | [diff] [blame] | 80 | ${WORKSPACE}/test/csit/scripts/music/music-scripts/wait_for_port.sh ${TOMCAT_IP} 8080 |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 81 | |
Nelson,Thomas(tn1381)(arthurdent3) | 9f3cab8 | 2018-09-05 14:06:45 -0400 | [diff] [blame^] | 82 | sleep 20; |
| 83 | echo "get the tomcat logs to make sure its running music properly" |
| 84 | echo "======== TOMCAT Logs ==============" |
| 85 | docker logs music-tomcat |
| 86 | # Needed only if we need to look at localhost logs. |
| 87 | #echo "===== MUSIC localhost Log ====================" |
| 88 | #docker exec music-tomcat /bin/bash -c "cat /usr/local/tomcat/logs/localhost*" |
| 89 | |
| 90 | echo "===== MUSIC Log ====================" |
| 91 | ls -al $MUSIC_LOGS/MUSIC |
| 92 | docker exec music-tomcat /bin/bash -c "cat /opt/app/music/logs/MUSIC/music.log" |
| 93 | echo "===== MUSIC error log ==================" |
| 94 | docker exec music-tomcat /bin/bash -c "cat /opt/app/music/logs/MUSIC/error.log" |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 95 | |
Leonardo Bellini | d573946 | 2018-03-14 03:59:33 -0500 | [diff] [blame] | 96 | echo "inspect docker things for tracing purpose" |
| 97 | docker inspect music-db |
| 98 | docker inspect music-zk |
| 99 | docker inspect music-tomcat |
| 100 | docker inspect music-war |
| 101 | docker volume inspect music-vol |
| 102 | docker network inspect music-net |
Leonardo Bellini | de47fd4 | 2018-03-07 12:07:30 -0600 | [diff] [blame] | 103 | |
Leonardo Bellini | 6515d69 | 2018-04-03 09:48:43 -0500 | [diff] [blame] | 104 | echo "dump music content just after music is started" |
| 105 | docker exec music-db /usr/bin/nodetool status |
| 106 | docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces' |
Nelson,Thomas(tn1381)(arthurdent3) | 9f3cab8 | 2018-09-05 14:06:45 -0400 | [diff] [blame^] | 107 | docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'DESCRIBE keyspace admin' |
Leonardo Bellini | 6515d69 | 2018-04-03 09:48:43 -0500 | [diff] [blame] | 108 | docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master' |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 109 | |
| 110 | |
| 111 | # |
| 112 | # add here all ROBOT_VARIABLES settings |
| 113 | # |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 114 | echo "# music robot variables settings"; |
Leonardo Bellini | 293263e | 2018-03-09 07:34:07 -0600 | [diff] [blame] | 115 | ROBOT_VARIABLES="-v MUSIC_HOSTNAME:http://${TOMCAT_IP} -v MUSIC_PORT:8080 -v COND_HOSTNAME:http://localhost -v COND_PORT:8091" |
Leonardo Bellini | 4dfc5ca | 2018-03-01 10:56:57 -0600 | [diff] [blame] | 116 | |
| 117 | echo ${ROBOT_VARIABLES} |
| 118 | |
| 119 | |
| 120 | |