summaryrefslogtreecommitdiffstats
path: root/tests/ci/launch_containers_by_testsuite.sh
blob: 08b80028633f1bb5fc9650a0ad85dbf8966573ee (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
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /bin/bash
##############################################################################
# Copyright (c) 2017 ZTE and others.
# 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
##############################################################################

export ENV_FILE="${WORKSPACE}/env_file"

if [[ -e $ENV_FILE ]];then
    rm $ENV_FILE
fi

case $INSTALLER_TYPE in
    apex)
        INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1`
        ;;
esac

echo "INSTALLER_TYPE=$INSTALLER_TYPE" >> $ENV_FILE
echo "INSTALLER_IP=$INSTALLER_IP" >> $ENV_FILE
echo "NODE_NAME=$NODE_NAME" >> $ENV_FILE
echo "SCENARIO=$DEPLOY_SCENARIO" >> $ENV_FILE
echo "TESTAPI_URL=$TESTAPI_URL" >> $ENV_FILE

if [[ "$TEST_SUITE" == 'compute' ]];then

    echo "--------------------------------------------------------"
    cat $ENV_FILE
    echo "--------------------------------------------------------"

    echo "Qtip: Pulling docker image: opnfv/qtip:${DOCKER_TAG}"
    docker pull opnfv/qtip:$DOCKER_TAG >/dev/null

    envs="--env-file $ENV_FILE"
    vols=""
    if [[ "$INSTALLER_TYPE" == "apex" ]];then     vols="-v /root/.ssh:/root/.ssh"
    fi

    container_name="qtip-${TEST_SUITE}"
    if [[ -n $(docker ps -a|grep ${container_name}) ]]; then
        echo "QTIP: cleaning existing container"
        docker stop ${container_name}
        docker rm ${container_name}
    fi

    cmd="sudo docker run -id --name ${container_name} ${envs} ${vols} opnfv/qtip:${DOCKER_TAG} /bin/bash"
    echo "Qtip: Running docker command: ${cmd}"
    ${cmd}

elif [[ "$TEST_SUITE" == 'storage' ]];then
    script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

    curl https://git.opnfv.org/releng/plain/utils/fetch_os_creds.sh | bash -s -- \
        -i $INSTALLER_TYPE -a $INSTALLER_IP -d $WORKSPACE/openrc

    grep "export" $WORKSPACE/openrc | sed "s/export //" >> $ENV_FILE
    echo "DOCKER_TAG=$DOCKER_TAG" >> $ENV_FILE

    echo "--------------------ENV_FILE----------------------------"
    cat $ENV_FILE
    echo "--------------------------------------------------------"

    source $script_dir/storperf/containers.sh
    cd $script_dir/storperf
    clean_containers
    launch_containers
else
    echo "QTIP: Sorry, not support test suite $TEST_SUITE!"
    exit 1
fi