Fix socker connection issue in qtip docker
[releng.git] / jjb / qtip / helpers / validate-deploy.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2016 ZTE and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 set -e
10
11 envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP}
12 -e NODE_NAME=${NODE_NAME} -e CI_DEBUG=${CI_DEBUG}"
13 ramfs=/tmp/qtip/ramfs
14 dir_imgstore="${HOME}/imgstore"
15 ramfs_volume="$ramfs:/mnt/ramfs"
16
17 echo "--------------------------------------------------------"
18 echo "POD: $NODE_NAME"
19 echo "INSTALLER: $INSTALLER_TYPE"
20 echo "Scenario: $DEPLOY_SCENARIO"
21 echo "--------------------------------------------------------"
22
23 echo "Qtip: Pulling docker image: opnfv/qtip:${DOCKER_TAG}"
24 docker pull opnfv/qtip:$DOCKER_TAG
25
26 # use ramfs to fix docker socket connection issue with overlay mode in centos
27 if [ ! -d $ramfs ]; then
28     mkdir -p $ramfs
29 fi
30
31 if [ ! -z $(df $ramfs | tail -n -1 | grep $ramfs) ]; then
32     sudo mount -t tmpfs -o size=32M tmpfs $ramfs
33 fi
34
35 # enable contro path in docker
36 echo <<EOF > /tmp/ansible.cfg
37 [defaults]
38 callback_whitelist = profile_tasks
39 [ssh_connection]
40 control_path=/mnt/ramfs/ansible-ssh-%%h-%%p-%%r
41 EOF
42
43 cmd=" docker run -id -e $envs -v ${ramfs_volume} opnfv/qtip:${DOCKER_TAG} /bin/bash"
44 echo "Qtip: Running docker command: ${cmd}"
45 ${cmd}
46
47 container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}" | awk '{print $1}' | head -1)
48 if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then
49     echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..."
50     exit 1
51 else
52     echo "The container ID is: ${container_id}"
53     QTIP_REPO=/home/opnfv/repos/qtip
54     docker cp /tmp/ansible.cfg ${container_id}:/home/opnfv/.ansible.cfg
55 # TODO(zhihui_wu): use qtip cli to execute benchmark test in the future
56     docker exec -t ${container_id} bash -c "cd ${QTIP_REPO}/qtip/runner/ &&
57     python runner.py -d /home/opnfv/qtip/results/ -b all"
58
59 fi
60
61 echo "Qtip done!"