summaryrefslogtreecommitdiffstats
path: root/tests/cyclictest.sh
blob: 840adc6fbc0dac929d19b93ec1f5ed6d1d69a95d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
##############################################################################
## Copyright (c) 2015 Intel Corp.
##
## All rights reserved. This program and the accompanying materials
## are made available under the terms of the Apache License, Version 2.0
## which accompanies this distribution, and is available at
## http://www.apache.org/licenses/LICENSE-2.0
###############################################################################

usage () {
	echo "Usage: ${0} rpmdir image_dir"
	exit 1
}

if [[ $# -ne 2 ]]; then
    usage
fi

rpmdir=$1
imagedir=$2

ROOT_DIR=$(cd $(dirname "$0")/.. && pwd)
ENVDIR=${ROOT_DIR}/ci/envs/

cleanup () {
    docker  stop  $1
    docker  rm -v $1
    # We should have already remove running containers when pull the image
    docker rmi opnfv/yardstick
}

# Make sure we have latest image
docker ps | grep opnfv/yardstick-ci |\
	awk '{print $1}' | xargs -r docker stop &>/dev/null
	docker ps -a | grep opnfv/yardstick |\
		awk '{print $1}' | xargs -r  docker rm &>/dev/null
docker pull opnfv/yardstick

id=$(docker run \
--privileged=true \
-d \
-t \
-e "INSTALLER_TYPE=${INSTALLER_TYPE}" \
-e "INSTALLER_IP=${INSTALLER_IP}" \
opnfv/yardstick )

trap 'cleanup $id' SIGHUP SIGINT SIGTERM

${ROOT_DIR}/tests/update_yardstick.sh $id ${rpmdir} ${imagedir}

if [[ -z $? ]]
then
    echo "Failed to update the yardstick environment"
    exit 1
fi

docker exec $id sh -c "/opt/testexec.sh"

cleanup $id