From de1f4b75a6f81d043583b0445af57da8204ee5cb Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Wed, 13 Nov 2024 10:30:28 +0800 Subject: [PATCH] test:update install py connector in ci --- Jenkinsfile2 | 20 ++------------- tests/ci/Dockerfile | 2 +- tests/ci/install_taos_py_con.py | 34 ++++++++++++++++++++++++++ tests/parallel_test/container_build.sh | 4 +-- tests/parallel_test/run_case.sh | 12 +++------ 5 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 tests/ci/install_taos_py_con.py diff --git a/Jenkinsfile2 b/Jenkinsfile2 index a9c829660a..917c75f5bc 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -273,16 +273,6 @@ def pre_test_win(){ cd %WIN_COMMUNITY_ROOT% git submodule update --init --recursive ''' - bat ''' - cd %WIN_CONNECTOR_ROOT% - git branch - git reset --hard - git pull - ''' - bat ''' - cd %WIN_CONNECTOR_ROOT% - git log -5 - ''' } def pre_test_build_win() { bat ''' @@ -303,12 +293,8 @@ def pre_test_build_win() { time /t ''' bat ''' - cd %WIN_CONNECTOR_ROOT% - python.exe -m pip install --upgrade pip - python -m pip uninstall taospy -y - python -m pip install taospy==2.7.16 - python -m pip uninstall taos-ws-py -y - python -m pip install taos-ws-py==0.3.3 + cd %WIN_COMMUNITY_ROOT%/tests/ci + python install_taos_py_con.py taospy==2.7.16 taos-ws-py==0.3.3 xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ''' return 1 @@ -325,7 +311,6 @@ def run_win_ctest() { def run_win_test() { bat ''' echo "windows test ..." - cd %WIN_CONNECTOR_ROOT% xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ls -l C:\\Windows\\System32\\taos.dll time /t @@ -343,7 +328,6 @@ pipeline { WKDIR = '/var/lib/jenkins/workspace' WK = '/var/lib/jenkins/workspace/TDinternal' WKC = '/var/lib/jenkins/workspace/TDinternal/community' - WKPY = '/var/lib/jenkins/workspace/taos-connector-python' } stages { stage('check') { diff --git a/tests/ci/Dockerfile b/tests/ci/Dockerfile index 8381f1bb57..d3d574b484 100644 --- a/tests/ci/Dockerfile +++ b/tests/ci/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get install -y locales psmisc sudo tree libgeos-dev libgflags2.2 libgfl RUN sed -i 's/# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen && locale-gen RUN pip3 config set global.index-url http://admin:123456@192.168.0.212:3141/admin/dev/+simple/ RUN pip3 config set global.trusted-host 192.168.0.212 -RUN pip3 install taospy==2.7.15 taos-ws-py==0.3.1 pandas psutil fabric2 requests faker simplejson toml pexpect tzlocal distro decorator loguru hyperloglog +RUN pip3 install taospy==2.7.16 taos-ws-py==0.3.3 pandas psutil fabric2 requests faker simplejson toml pexpect tzlocal distro decorator loguru hyperloglog ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 RUN add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' diff --git a/tests/ci/install_taos_py_con.py b/tests/ci/install_taos_py_con.py new file mode 100644 index 0000000000..08f95b943b --- /dev/null +++ b/tests/ci/install_taos_py_con.py @@ -0,0 +1,34 @@ +import subprocess +import pkg_resources +import sys +import argparse + +def get_installed_version(package_name): + try: + return pkg_resources.get_distribution(package_name).version + except pkg_resources.DistributionNotFound: + return None + +def install_package(package_name, version): + subprocess.check_call([sys.executable, "-m", "pip", "install", f"{package_name}=={version}"]) + +def main(packages): + for package, latest_version in packages.items(): + installed_version = get_installed_version(package) + if installed_version != latest_version: + print(f"Installing {package} version {latest_version} (current version: {installed_version})") + install_package(package, latest_version) + else: + print(f"{package} is already up-to-date (version {installed_version})") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Install specified versions of packages.') + parser.add_argument('packages', nargs='+', help='List of packages with versions (e.g., taospy==2.7.16 taos-ws-py==0.3.3)') + args = parser.parse_args() + + packages = {} + for package in args.packages: + name, version = package.split('==') + packages[name] = version + + main(packages) \ No newline at end of file diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index a386269f85..363f62284a 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -83,7 +83,7 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/xml2/:${REP_DIR}/community/contrib/xml2 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ -v ${REP_REAL_PATH}/community/contrib/zstd/:${REP_DIR}/community/contrib/zstd \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ;make -j|| exit 1" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ;make -j|| exit 1" # -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ if [[ -d ${WORKDIR}/debugNoSan ]] ;then @@ -137,7 +137,7 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/xml2/:${REP_DIR}/community/contrib/xml2 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ -v ${REP_REAL_PATH}/community/contrib/zstd/:${REP_DIR}/community/contrib/zstd \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=false -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DCMAKE_BUILD_TYPE=Debug -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j|| exit 1 " + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=false -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DCMAKE_BUILD_TYPE=Debug -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j|| exit 1 " mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh index fa8fedbdbe..9c7daa147c 100755 --- a/tests/parallel_test/run_case.sh +++ b/tests/parallel_test/run_case.sh @@ -76,15 +76,9 @@ ulimit -c unlimited md5sum /usr/lib/libtaos.so.1 md5sum /home/TDinternal/debug/build/lib/libtaos.so -#define taospy 2.7.16 -pip3 list|grep taospy -pip3 uninstall taospy -y -pip3 install --default-timeout=120 taospy==2.7.16 - -#define taos-ws-py 0.3.1 -pip3 list|grep taos-ws-py -pip3 uninstall taos-ws-py -y -pip3 install --default-timeout=600 taos-ws-py==0.3.3 +#get python connector and update: taospy 2.7.16 taos-ws-py 0.3.3 +cd /home/TDinternal/community/tests/ci/ +python install_taos_py_con.py taospy==2.7.16 taos-ws-py==0.3.3 $TIMEOUT_CMD $cmd RET=$?