From 309bbd655ee44924644ee20a5d8009236ccbda0b Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 4 Feb 2021 18:10:44 +0800 Subject: [PATCH] [TD-2846]: imporve docker cluster scripts --- .../pytest/cluster/clusterEnvSetup/Dockerfile | 15 +++++++-- .../clusterEnvSetup/buildClusterEnv.sh | 26 +++++++++++----- .../clusterEnvSetup/docker-compose.yml | 31 +++++++++++++------ .../pytest/cluster/clusterEnvSetup/node4.yml | 11 +++++-- .../pytest/cluster/clusterEnvSetup/node5.yml | 13 ++++++-- 5 files changed, 72 insertions(+), 24 deletions(-) diff --git a/tests/pytest/cluster/clusterEnvSetup/Dockerfile b/tests/pytest/cluster/clusterEnvSetup/Dockerfile index b699e8a23f..4502142061 100644 --- a/tests/pytest/cluster/clusterEnvSetup/Dockerfile +++ b/tests/pytest/cluster/clusterEnvSetup/Dockerfile @@ -9,6 +9,7 @@ WORKDIR /root COPY ${PACKAGE} . RUN tar -zxf ${PACKAGE} +RUN tar -zxf ${TARBITRATORPKG} RUN mv ${EXTRACTDIR}/driver ./lib RUN tar -zxf ${EXTRACTDIR}/${CONTENT} @@ -19,8 +20,18 @@ WORKDIR /root RUN apt-get update RUN apt-get install -y vim tmux net-tools RUN echo 'alias ll="ls -l --color=auto"' >> /root/.bashrc - +RUN echo 'node1 172.27.0.7' >> /etc/hosts +RUN echo 'node2 172.27.0.8' >> /etc/hosts +RUN echo 'node3 172.27.0.9' >> /etc/hosts +RUN echo 'node4 172.27.0.10' >> /etc/hosts +RUN echo 'node5 172.27.0.11' >> /etc/hosts +RUN ulimit -c unlimited +RUN mkdir /coredump +RUN echo 'kernel.core_pattern=/coredump/core_%e_%p' >> /etc/sysctl.conf +RUN sysctl -p + COPY --from=builder /root/bin/taosd /usr/bin +COPY --from=builder /root/bin/tarbitrator /usr/bin COPY --from=builder /root/bin/taos /usr/bin COPY --from=builder /root/cfg/taos.cfg /etc/taos/ COPY --from=builder /root/lib/libtaos.so.* /usr/lib/libtaos.so.1 @@ -29,7 +40,7 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" ENV LC_CTYPE=en_US.UTF-8 ENV LANG=en_US.UTF-8 -EXPOSE 6030-6041/tcp 6060/tcp 6030-6039/udp +EXPOSE 6030-6042/tcp 6060/tcp 6030-6039/udp # VOLUME [ "/var/lib/taos", "/var/log/taos", "/etc/taos" ] diff --git a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh index 973d000a0a..896f5e4105 100755 --- a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh +++ b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh @@ -34,6 +34,7 @@ function createDIR { mkdir -p /data/node$i/data mkdir -p /data/node$i/log mkdir -p /data/node$i/cfg + mkdir -p /data/node$i/core done } @@ -54,16 +55,25 @@ function prepareBuild { rm -rf $CURR_DIR/../../../../release/* fi - cd $CURR_DIR/../../../../packaging - ./release.sh -v edge -n $VERSION >> /dev/null - if [ ! -f $CURR_DIR/../../../../release/TDengine-server-$VERSION-Linux-x64.tar.gz ]; then - echo "no TDengine install package found" - exit 1 - fi + if [ ! -e $DOCKER_DIR/TDengine-server-$VERSION-Linux-x64.tar.gz && ! -e TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + cd $CURR_DIR/../../../../packaging + ./release.sh -v edge -n $VERSION >> /dev/null + + if [ ! -e $CURR_DIR/../../../../release/TDengine-server-$VERSION-Linux-x64.tar.gz ]; then + echo "no TDengine install package found" + exit 1 + fi - cd $CURR_DIR/../../../../release - mv TDengine-server-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + if [ ! -e $CURR_DIR/../../../../release/TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + echo "no arbitrator install package found" + exit 1 + fi + + cd $CURR_DIR/../../../../release + mv TDengine-server-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + mv TDengine-arbitrator-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + fi rm -rf $DOCKER_DIR/*.yml cd $CURR_DIR diff --git a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml index c45a09582b..21240e52d6 100644 --- a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml +++ b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml @@ -1,14 +1,15 @@ version: '3.7' services: - td2.0-node1: - build: + td2.0-node1: + build: context: . args: - PACKAGE=${PACKAGE} + - TARBITRATORPKG=${TARBITRATORPKG} - EXTRACTDIR=${DIR} image: 'tdengine:${VERSION}' - container_name: 'td2.0-node1' + container_name: 'tdnode1' cap_add: - ALL stdin_open: true @@ -32,14 +33,18 @@ services: - type: bind source: /data/node1/cfg target: /etc/taos + # bind core dump path + - type: bind + source: /data/node2/core + target: /coredump - type: bind source: /data target: /root - hostname: node1 + hostname: tdnode1 networks: taos_update_net: ipv4_address: 172.27.0.7 - command: taosd + command: taosd && tarbitrator td2.0-node2: build: @@ -48,7 +53,7 @@ services: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} image: 'tdengine:${VERSION}' - container_name: 'td2.0-node2' + container_name: 'tdnode2' cap_add: - ALL stdin_open: true @@ -72,9 +77,15 @@ services: - type: bind source: /data/node2/cfg target: /etc/taos + # bind configuration + - type: bind + source: /data/node2/core + target: /coredump + # bind core dump path - type: bind source: /data target: /root + hostname: tdnode2 networks: taos_update_net: ipv4_address: 172.27.0.8 @@ -87,7 +98,7 @@ services: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} image: 'tdengine:${VERSION}' - container_name: 'td2.0-node3' + container_name: 'tdnode3' cap_add: - ALL stdin_open: true @@ -96,7 +107,7 @@ services: TZ: "Asia/Shanghai" command: > sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && - echo $TZ > /etc/timezone && + echo $TZ > /etc/timezone && exec my-main-application" volumes: # bind data directory @@ -111,9 +122,11 @@ services: - type: bind source: /data/node3/cfg target: /etc/taos + # bind core dump path - type: bind source: /data - target: /root + target: /root + hostname: tdnode3 networks: taos_update_net: ipv4_address: 172.27.0.9 diff --git a/tests/pytest/cluster/clusterEnvSetup/node4.yml b/tests/pytest/cluster/clusterEnvSetup/node4.yml index 542dc4cac1..6c8fc94ae8 100644 --- a/tests/pytest/cluster/clusterEnvSetup/node4.yml +++ b/tests/pytest/cluster/clusterEnvSetup/node4.yml @@ -8,7 +8,7 @@ services: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} image: 'tdengine:2.0.13.1' - container_name: 'td2.0-node4' + container_name: 'tdnode4' cap_add: - ALL stdin_open: true @@ -17,7 +17,7 @@ services: TZ: "Asia/Shanghai" command: > sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && - echo $TZ > /etc/timezone && + echo $TZ > /etc/timezone && exec my-main-application" volumes: # bind data directory @@ -32,9 +32,14 @@ services: - type: bind source: /data/node4/cfg target: /etc/taos + # bind core dump path + - type: bind + source: /data/node2/core + target: /coredump - type: bind source: /data - target: /root + target: /root + hostname: tdnode4 networks: taos_update_net: ipv4_address: 172.27.0.10 diff --git a/tests/pytest/cluster/clusterEnvSetup/node5.yml b/tests/pytest/cluster/clusterEnvSetup/node5.yml index 832cc65e08..92cd4a8fad 100644 --- a/tests/pytest/cluster/clusterEnvSetup/node5.yml +++ b/tests/pytest/cluster/clusterEnvSetup/node5.yml @@ -8,7 +8,7 @@ services: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} image: 'tdengine:2.0.13.1' - container_name: 'td2.0-node5' + container_name: 'tdnode5' cap_add: - ALL stdin_open: true @@ -32,9 +32,18 @@ services: - type: bind source: /data/node5/cfg target: /etc/taos + # bind core dump path + - type: bind + source: /data/node2/core + target: /coredump + # bind core dump path + - type: bind + source: /data/node2/core + target: /coredump - type: bind source: /data - target: /root + target: /root + hostname: tdnode5 networks: taos_update_net: ipv4_address: 172.27.0.11 -- GitLab