blob: 98ba2bd6a638d7f81a71e78ca908053c50d4871e [file] [log] [blame]
Gary Wucbddc2b2018-01-22 13:33:21 -08001#!/bin/bash -x
Gary Wucbddc2b2018-01-22 13:33:21 -08002
3if [ -z "$WORKSPACE" ]; then
4 export WORKSPACE=`git rev-parse --show-toplevel`
5fi
6
7if [ "$#" -ne 1 ]; then
8 echo "Usage: $0 <env-name>"
9 exit 1
10fi
11ENV_FILE=$1
12
Gary Wu0d28fe62018-05-24 20:54:28 -070013SSH_KEY=~/.ssh/onap_key
14
Gary Wu808b13d2018-02-13 18:28:37 -080015source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
16
Gary Wu11c98742018-05-02 16:19:04 -070017SO_ENCRYPTION_KEY=aa3871669d893c7fb8abbcda31b88b4f
18export OS_PASSWORD_ENCRYPTED=$(echo -n "$OS_PASSWORD" | openssl aes-128-ecb -e -K "$SO_ENCRYPTION_KEY" -nosalt | xxd -c 256 -p)
19
Gary Wucbddc2b2018-01-22 13:33:21 -080020for n in $(seq 1 5); do
21 $WORKSPACE/test/ete/scripts/teardown-onap.sh
22
23 cd $WORKSPACE/deployment/heat/onap-oom
Gary Wu374498a2018-02-06 17:31:04 -080024 envsubst < $ENV_FILE > $ENV_FILE~
Gary Wud2579972018-05-23 12:36:46 -070025
26 if ! openstack stack create -t ./onap-oom.yaml -e $ENV_FILE~ onap-oom; then
27 break
28 fi
29
30 while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value onap-oom)" ]; do
31 sleep 20
32 done
33
34 STATUS=$(openstack stack show -c stack_status -f value onap-oom)
35 echo $STATUS
36 if [ "CREATE_COMPLETE" != "$STATUS" ]; then
37 break
38 fi
Gary Wucbddc2b2018-01-22 13:33:21 -080039
Gary Wuae7c7642018-04-19 17:22:34 -070040 for i in $(seq 1 30); do
41 sleep 30
Gary Wucbddc2b2018-01-22 13:33:21 -080042 RANCHER_IP=$(openstack stack output show onap-oom rancher_vm_ip -c output_value -f value)
Gary Wud2579972018-05-23 12:36:46 -070043 K8S_IP=$(openstack stack output show onap-oom k8s_1_vm_ip -c output_value -f value)
Gary Wu14a6b302018-05-01 15:59:28 -070044 timeout 1 ping -c 1 "$RANCHER_IP" && break
Gary Wucbddc2b2018-01-22 13:33:21 -080045 done
46
Gary Wu14a6b302018-05-01 15:59:28 -070047 timeout 1 ping -c 1 "$RANCHER_IP" && break
Gary Wucbddc2b2018-01-22 13:33:21 -080048
Gary Wu14a6b302018-05-01 15:59:28 -070049 echo Error: OpenStack infrastructure issue: unable to reach rancher "$RANCHER_IP"
Gary Wucbddc2b2018-01-22 13:33:21 -080050 sleep 10
51done
52
Gary Wu14a6b302018-05-01 15:59:28 -070053if ! timeout 1 ping -c 1 "$RANCHER_IP"; then
Gary Wucbddc2b2018-01-22 13:33:21 -080054 exit 2
55fi
56
Gary Wud3337f02018-05-24 10:51:23 -070057ssh-keygen -R $RANCHER_IP
58
Gary Wu0d28fe62018-05-24 20:54:28 -070059ssh -o StrictHostKeychecking=no -i $SSH_KEY ubuntu@$RANCHER_IP "sed -u '/Cloud-init.*finished/q' <(tail -n+0 -f /var/log/cloud-init-output.log)"
Gary Wud2579972018-05-23 12:36:46 -070060
Gary Wu5627a692018-05-08 19:13:59 -070061for n in $(seq 1 6); do
Gary Wu0d28fe62018-05-24 20:54:28 -070062 timeout 15m ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -l root -c "/root/oom/kubernetes/robot/ete-k8s.sh onap health"'
Gary Wucbddc2b2018-01-22 13:33:21 -080063 RESULT=$?
64 if [ $RESULT -eq 0 ]; then
65 break
66 fi
67 sleep 15m
68done
Gary Wu0d28fe62018-05-24 20:54:28 -070069ROBOT_POD=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl --namespace onap get pods"' | grep robot | sed 's/ .*//')
Gary Wud2579972018-05-23 12:36:46 -070070if [ "$ROBOT_POD" == "" ]; then
71 exit 1
72fi
Gary Wu36e42dd2018-05-03 07:29:53 -070073
Gary Wud2579972018-05-23 12:36:46 -070074LOG_DIR=$(echo "kubectl exec -n onap $ROBOT_POD -- ls -1t /share/logs | grep {robot-tag} | head -1" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su)
75if [ "$LOG_DIR" == "" ]; then
76 exit 1
77fi
78
79echo "kubectl cp -n onap $ROBOT_POD:share/logs/$LOG_DIR /tmp/robot/logs/$LOG_DIR" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su
80rsync -e "ssh -i $SSH_KEY" -avtz ubuntu@$RANCHER_IP:/tmp/robot/logs/$LOG_DIR/ $WORKSPACE/archives/
81
82echo "Browse Robot results at http://$K8S_IP:30209/logs/$LOG_DIR/"
83
Gary Wucbddc2b2018-01-22 13:33:21 -080084exit 0