Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [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 | # |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 17 | echo "### This is ${WORKSPACE}/scripts/optf-has/has/has_script.sh" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 18 | # |
| 19 | # add here whatever commands is needed to prepare the optf/has CSIT testing |
| 20 | # |
| 21 | |
| 22 | # assume the base is /tmp dir |
| 23 | DIR=/tmp |
| 24 | |
| 25 | # the directory of the script |
| 26 | echo ${DIR} |
| 27 | cd ${DIR} |
| 28 | |
| 29 | # create directory for volume and copy configuration file |
| 30 | # run docker containers |
| 31 | COND_CONF=/tmp/conductor/properties/conductor.conf |
| 32 | LOG_CONF=/tmp/conductor/properties/log.conf |
| 33 | IMAGE_NAME=nexus3.onap.org:10001/onap/optf-has |
Ruoyu | 2740084 | 2018-11-28 05:30:34 +0000 | [diff] [blame] | 34 | IMAGE_VER=1.2.5-SNAPSHOT-latest |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 35 | BUNDLE=/tmp/conductor/properties/AAF_RootCA.cer |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 36 | |
| 37 | mkdir -p /tmp/conductor/properties |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 38 | mkdir -p /tmp/sms/properties |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 39 | mkdir -p /tmp/conductor/logs |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 40 | cp ${WORKSPACE}/scripts/optf-has/has/has-properties/conductor.conf.onap /tmp/conductor/properties/conductor.conf |
| 41 | cp ${WORKSPACE}/scripts/optf-has/has/has-properties/log.conf.onap /tmp/conductor/properties/log.conf |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 42 | cp ${WORKSPACE}/scripts/optf-has/has/has-properties/AAF_RootCA.cer /tmp/conductor/properties/AAF_RootCA.cer |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 43 | cp ${WORKSPACE}/scripts/optf-has/has/has-properties/has.json /tmp/sms/properties/has.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 44 | #chmod -R 777 /tmp/conductor/properties |
| 45 | |
| 46 | MUSIC_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat` |
| 47 | echo "MUSIC_IP=${MUSIC_IP}" |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 48 | SMS_IP=`get-instance-ip.sh sms` |
| 49 | echo "SMS_IP=${SMS_IP}" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 50 | |
| 51 | # change MUSIC reference to the local instance |
| 52 | sed -i -e "s%localhost:8080/MUSIC%${MUSIC_IP}:8080/MUSIC%g" /tmp/conductor/properties/conductor.conf |
| 53 | |
| 54 | AAISIM_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' aaisim` |
| 55 | echo "AAISIM_IP=${AAISIM_IP}" |
| 56 | |
| 57 | # change AAI reference to the local instance |
| 58 | sed -i -e "s%localhost:8081/%${AAISIM_IP}:8081/%g" /tmp/conductor/properties/conductor.conf |
| 59 | |
| 60 | MULTICLOUDSIM_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' multicloudsim` |
| 61 | echo "MULTICLOUDSIM_IP=${MULTICLOUDSIM_IP}" |
| 62 | |
| 63 | # change MULTICLOUD reference to the local instance |
| 64 | sed -i -e "s%msb.onap.org:8082/%${MULTICLOUDSIM_IP}:8082/%g" /tmp/conductor/properties/conductor.conf |
| 65 | |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 66 | AAFSIM_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' aafsim` |
| 67 | echo "AAFSIM_IP=${AAFSIM_IP}" |
| 68 | |
| 69 | # change AAF reference to the local instance |
| 70 | sed -i -e "s%localhost:8100/%${AAFSIM_IP}:8100/%g" /tmp/conductor/properties/conductor.conf |
| 71 | |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 72 | #SMS |
| 73 | sed -i -e "s%aaf-sms.onap:10443%${SMS_IP}:10443%g" /tmp/conductor/properties/conductor.conf |
| 74 | #Preload secrets |
| 75 | docker exec -i sms /bin/sh -c "mkdir -p /preload/config" |
| 76 | docker cp /tmp/sms/properties/has.json sms:/preload/config/has.json |
| 77 | docker exec -i sms /bin/sh -c "/sms/bin/preload -cacert /sms/certs/aaf_root_ca.cer -jsondir /preload/config -serviceport 10443 -serviceurl http://localhost" |
| 78 | docker logs vault |
| 79 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 80 | #onboard conductor into music |
| 81 | echo "Query MUSIC to check for reachability. Query Version" |
| 82 | curl -vvvvv --noproxy "*" --request GET http://${MUSIC_IP}:8080/MUSIC/rest/v2/version -H "Content-Type: application/json" |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 83 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 84 | echo "Onboard conductor into music" |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 85 | curl -vvvvv --noproxy "*" --request POST http://${MUSIC_IP}:8080/MUSIC/rest/v2/admin/onboardAppWithMusic -H "Content-Type: application/json" -H "Authorization: Basic Y29uZHVjdG9yOmMwbmR1Y3Qwcg==" --data @${WORKSPACE}/tests/optf-has/has/data/onboard.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 86 | |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 87 | docker run -d --name cond-cont -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${BUNDLE}:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${IMAGE_VER} python /usr/local/bin/conductor-controller --config-file=/usr/local/bin/conductor.conf |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 88 | sleep 15 |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 89 | docker run -d --name cond-api -p "8091:8091" -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${BUNDLE}:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${IMAGE_VER} python /usr/local/bin/conductor-api --port=8091 -- --config-file=/usr/local/bin/conductor.conf |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 90 | sleep 15 |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 91 | docker run -d --name cond-solv -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${BUNDLE}:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${IMAGE_VER} python /usr/local/bin/conductor-solver --config-file=/usr/local/bin/conductor.conf |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 92 | sleep 15 |
Dileep Ranganathan | 425ba92 | 2018-10-04 15:34:34 -0700 | [diff] [blame] | 93 | docker run -d --name cond-resv -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${BUNDLE}:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${IMAGE_VER} python /usr/local/bin/conductor-reservation --config-file=/usr/local/bin/conductor.conf |
Dileep Ranganathan | 5dc29ae | 2018-10-06 16:35:11 -0700 | [diff] [blame] | 94 | sleep 5 |
| 95 | docker run -d --name cond-data -v ${COND_CONF}:/usr/local/bin/conductor.conf -v ${LOG_CONF}:/usr/local/bin/log.conf -v ${BUNDLE}:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${IMAGE_VER} python /usr/local/bin/conductor-data --config-file=/usr/local/bin/conductor.conf |
| 96 | sleep 15 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 97 | |
| 98 | COND_IP=`docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' cond-api` |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 99 | ${WORKSPACE}/scripts/optf-has/has/wait_for_port.sh ${COND_IP} 8091 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 100 | |
| 101 | echo "inspect docker things for tracing purpose" |
| 102 | docker inspect cond-data |
| 103 | docker inspect cond-cont |
| 104 | docker inspect cond-api |
| 105 | docker inspect cond-solv |
| 106 | docker inspect cond-resv |
| 107 | |
| 108 | echo "dump music content just after conductor is started" |
| 109 | docker exec music-db /usr/bin/nodetool status |
| 110 | docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM system_schema.keyspaces' |
| 111 | docker exec music-db /usr/bin/cqlsh -unelson24 -pwinman123 -e 'SELECT * FROM admin.keyspace_master' |