run_container.sh 3.2 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
    REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
haoranc's avatar
haoranc 已提交
71 72
    REP_MOUNT_LIB="$INTERNAL_REPDIR/debug/build/lib:/home/TDinternal/debug/build/lib:ro"

T
tangfangzhi 已提交
73 74 75 76
else
    # community edition
    REPDIR=$WORKDIR/TDengine
    CONTAINER_TESTDIR=/home/TDengine
77
    SIM_DIR=/home/TDengine/sim
T
tangfangzhi 已提交
78
    REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
haoranc's avatar
haoranc 已提交
79 80
    REP_MOUNT_LIB="$REPDIR/debug/build/lib:/home/TDengine/debug/build/lib:ro"

T
tangfangzhi 已提交
81 82 83 84 85
fi

ulimit -c unlimited

TMP_DIR=$WORKDIR/tmp
86
SOURCEDIR=$WORKDIR/src
T
tangfangzhi 已提交
87
MOUNT_DIR=""
88
packageName="TDengine-server-3.0.1.0-Linux-x64.tar.gz"
T
tangfangzhi 已提交
89
rm -rf ${TMP_DIR}/thread_volume/$thread_no/sim
90
mkdir -p $SOURCEDIR
T
tangfangzhi 已提交
91 92 93 94 95 96 97 98
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
99

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

T
tangfangzhi 已提交
104 105 106 107 108 109
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 \
haoranc's avatar
haoranc 已提交
110
    -v $REP_MOUNT_LIB \
T
tangfangzhi 已提交
111
    -v $MOUNT_DIR \
112
    -v ${SOURCEDIR}:/usr/local/src/ \
113
    -v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
T
tangfangzhi 已提交
114 115
    -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 \
116
    -v $WORKDIR/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro \
T
tangfangzhi 已提交
117 118 119 120
    --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