run_container.sh 3.5 KB
Newer Older
T
tangfangzhi 已提交
1 2 3 4 5 6 7 8 9 10
#!/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"
11
    echo -e "\t -s build with sanitizer"
T
tangfangzhi 已提交
12 13 14 15
    echo -e "\t -h help"
}

ent=0
16
while getopts "w:d:c:t:o:s:eh" opt; do
T
tangfangzhi 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    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"
            ;;
36
        s)
37
            buildSan=$OPTARG
38
            ;;
T
tangfangzhi 已提交
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
        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
67 68 69

#select whether the compilation environment  includes sanitizer
if [ "${buildSan}" == "y" ]; then
70
    DEBUGPATH="debugSan"
71 72 73 74 75 76 77
elif [[ "${buildSan}" == "n" ]] || [[ "${case_build_san}" == "" ]]; then
    DEBUGPATH="debugNoSan"
else
    usage
    exit 1
fi

T
tangfangzhi 已提交
78 79 80 81 82
if [ $ent -ne 0 ]; then
    # enterprise edition
    extra_param="$extra_param -e"
    INTERNAL_REPDIR=$WORKDIR/TDinternal
    REPDIR=$INTERNAL_REPDIR/community
83
    REPDIR_DEBUG=$WORKDIR/$DEBUGPATH/
T
tangfangzhi 已提交
84
    CONTAINER_TESTDIR=/home/TDinternal/community
85
    SIM_DIR=/home/TDinternal/sim
T
tangfangzhi 已提交
86
    REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
87
    REP_MOUNT_DEBUG="${REPDIR_DEBUG}:/home/TDinternal/debug/:ro"
haoranc's avatar
haoranc 已提交
88

T
tangfangzhi 已提交
89 90 91
else
    # community edition
    REPDIR=$WORKDIR/TDengine
92
    REPDIR_DEBUG=$WORKDIR/$DEBUGPATH/
T
tangfangzhi 已提交
93
    CONTAINER_TESTDIR=/home/TDengine
94
    SIM_DIR=/home/TDengine/sim
T
tangfangzhi 已提交
95
    REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
96
    REP_MOUNT_DEBUG="${REPDIR_DEBUG}:/home/TDengine/debug/:ro"
haoranc's avatar
haoranc 已提交
97

T
tangfangzhi 已提交
98 99 100 101 102
fi

ulimit -c unlimited

TMP_DIR=$WORKDIR/tmp
103
SOURCEDIR=$WORKDIR/src
T
tangfangzhi 已提交
104
MOUNT_DIR=""
105
packageName="TDengine-server-3.0.1.0-Linux-x64.tar.gz"
T
tangfangzhi 已提交
106
rm -rf ${TMP_DIR}/thread_volume/$thread_no/sim
107
mkdir -p $SOURCEDIR
T
tangfangzhi 已提交
108 109 110 111 112 113 114 115
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
116

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

T
tangfangzhi 已提交
121 122 123 124 125 126
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 \
127
    -v $REP_MOUNT_DEBUG \
T
tangfangzhi 已提交
128
    -v $MOUNT_DIR \
129
    -v ${SOURCEDIR}:/usr/local/src/ \
130
    -v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
T
tangfangzhi 已提交
131 132
    -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 \
133
    -v $WORKDIR/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro \
T
tangfangzhi 已提交
134 135 136 137
    --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