Cyclictest invokation script
[kvmfornfv.git] / tests / cyclictest.sh
1 #!/bin/bash
2 ##############################################################################
3 ## Copyright (c) 2015 Intel Corp.
4 ##
5 ## All rights reserved. This program and the accompanying materials
6 ## are made available under the terms of the Apache License, Version 2.0
7 ## which accompanies this distribution, and is available at
8 ## http://www.apache.org/licenses/LICENSE-2.0
9 ###############################################################################
10
11 usage () {
12         echo "Usage: ${0} rpmdir image_dir"
13         exit 1
14 }
15
16 if [[ $# -ne 2 ]]; then
17     usage
18 fi
19
20 rpmdir=$1
21 imagedir=$2
22
23 ROOT_DIR=$(cd $(dirname "$0")/.. && pwd)
24 ENVDIR=${ROOT_DIR}/ci/envs/
25
26 cleanup () {
27     docker  stop  $1
28     docker  rm -v $1
29     # We should have already remove running containers when pull the image
30     docker rmi opnfv/yardstick
31 }
32
33 # Make sure we have latest image
34 docker ps | grep opnfv/yardstick-ci |\
35         awk '{print $1}' | xargs -r docker stop &>/dev/null
36         docker ps -a | grep opnfv/yardstick |\
37                 awk '{print $1}' | xargs -r  docker rm &>/dev/null
38 docker pull opnfv/yardstick
39
40 id=$(docker run \
41 --privileged=true \
42 -d \
43 -t \
44 -e "INSTALLER_TYPE=${INSTALLER_TYPE}" \
45 -e "INSTALLER_IP=${INSTALLER_IP}" \
46 opnfv/yardstick )
47
48 trap 'cleanup $id' SIGHUP SIGINT SIGTERM
49
50 ${ROOT_DIR}/tests/update_yardstick.sh $id ${rpmdir} ${imagedir}
51
52 if [[ -z $? ]]
53 then
54     echo "Failed to update the yardstick environment"
55     exit 1
56 fi
57
58 docker exec $id sh -c "/opt/testexec.sh"
59
60 cleanup $id