run_container.sh 3.0 KB
Newer Older
T
tangfangzhi 已提交
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
#!/bin/bash

function usage() {
    echo "$0"
    echo -e "\t -w work dir"
    echo -e "\t -d execution dir"
    echo -e "\t -c command"
    echo -e "\t -t thread number"
    echo -e "\t -e enterprise edition"
    echo -e "\t -o default timeout value"
    echo -e "\t -h help"
}

ent=0
while getopts "w:d:c:t:o:eh" opt; do
    case $opt in
        w)
            WORKDIR=$OPTARG
            ;;
        d)
            exec_dir=$OPTARG
            ;;
        c)
            cmd=$OPTARG
            ;;
        t)
            thread_no=$OPTARG
            ;;
        e)
            ent=1
            ;;
        o)
            extra_param="-o $OPTARG"
            ;;
        h)
            usage
            exit 0
            ;;
        \?)
            echo "Invalid option: -$OPTARG"
            usage
            exit 0
            ;;
    esac
done

if [ -z "$WORKDIR" ]; then
    usage
    exit 1
fi
if [ -z "$exec_dir" ]; then
    usage
    exit 1
fi
if [ -z "$cmd" ]; then
    usage
    exit 1
fi
if [ -z "$thread_no" ]; then
    usage
    exit 1
fi
if [ $ent -ne 0 ]; then
    # enterprise edition
    extra_param="$extra_param -e"
    INTERNAL_REPDIR=$WORKDIR/TDinternal
    REPDIR=$INTERNAL_REPDIR/community
    CONTAINER_TESTDIR=/home/TDinternal/community
69
    SIM_DIR=/home/TDinternal/sim
T
tangfangzhi 已提交
70 71 72 73 74
    REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
else
    # community edition
    REPDIR=$WORKDIR/TDengine
    CONTAINER_TESTDIR=/home/TDengine
75
    SIM_DIR=/home/TDengine/sim
T
tangfangzhi 已提交
76 77 78 79 80 81
    REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
fi

ulimit -c unlimited

TMP_DIR=$WORKDIR/tmp
82
SOURCEDIR=$WORKDIR/src
T
tangfangzhi 已提交
83
MOUNT_DIR=""
84
packageName="TDengine-server-3.0.1.0-Linux-x64.tar.gz"
T
tangfangzhi 已提交
85
rm -rf ${TMP_DIR}/thread_volume/$thread_no/sim
86
mkdir -p $SOURCEDIR
T
tangfangzhi 已提交
87 88 89 90 91 92 93 94
mkdir -p ${TMP_DIR}/thread_volume/$thread_no/sim/tsim
mkdir -p ${TMP_DIR}/thread_volume/$thread_no/coredump
rm -rf ${TMP_DIR}/thread_volume/$thread_no/coredump/*
if [ ! -d "${TMP_DIR}/thread_volume/$thread_no/$exec_dir" ]; then
    subdir=`echo "$exec_dir"|cut -d/ -f1`
    echo "cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/"
    cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/
fi
95 96 97 98 99

if [ ! -d "${SOURCEDIR}/${packageName}" ]; then
     wget -P  ${SOURCEDIR} https://taosdata.com/assets-download/3.0/${packageName}
fi

T
tangfangzhi 已提交
100 101 102 103 104 105 106
MOUNT_DIR="$TMP_DIR/thread_volume/$thread_no/$exec_dir:$CONTAINER_TESTDIR/tests/$exec_dir"
echo "$thread_no -> ${exec_dir}:$cmd"
coredump_dir=`cat /proc/sys/kernel/core_pattern | xargs dirname`

docker run \
    -v $REP_MOUNT_PARAM \
    -v $MOUNT_DIR \
107
    -v ${SOURCEDIR}:/usr/local/src/ \
108
    -v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
T
tangfangzhi 已提交
109 110
    -v ${TMP_DIR}/thread_volume/$thread_no/coredump:$coredump_dir \
    -v $WORKDIR/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \
111
    -v $WORKDIR/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro \
T
tangfangzhi 已提交
112 113 114 115
    --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $extra_param
ret=$?
exit $ret