From ba85dd46a0eb22d49436dee2bf88e3db997ef381 Mon Sep 17 00:00:00 2001 From: "zhangtaibo.ztb" Date: Mon, 22 Apr 2024 16:44:08 +0800 Subject: [PATCH 1/4] tone-cli add check_pkg_version --- tests/anolis-ci-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/anolis-ci-test/run.sh b/tests/anolis-ci-test/run.sh index abf0850..2b9a543 100755 --- a/tests/anolis-ci-test/run.sh +++ b/tests/anolis-ci-test/run.sh @@ -3,7 +3,7 @@ run() { # pre_define test_groups - basic_test_list="check_license check_specfile check_codestyle check_source" + basic_test_list="check_license check_specfile check_codestyle check_source check_pkg_version" rpm_test_list="pkg_smoke_test check_abi_diff check_pkg_dependency" custom_test_list="custom_script" -- Gitee From e784a84ed9a9e671a4f0cc7a6236311865e2f168 Mon Sep 17 00:00:00 2001 From: "zhangtaibo.ztb" Date: Fri, 26 Apr 2024 10:33:57 +0800 Subject: [PATCH 2/4] install avocado in run.sh, that use avocado's plugin correctly. --- tests/image-ci-test/install.sh | 3 --- tests/image-ci-test/run.sh | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index 719237a..81686a9 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -21,9 +21,6 @@ build() install() { - python3 -m pip install --upgrade pip - pip3 install --ignore-installed PyYAML - python3 -m pip install -r $TONE_BM_CACHE_DIR/requirements.txt cp -Trf $TONE_BM_CACHE_DIR $TONE_BM_RUN_DIR } diff --git a/tests/image-ci-test/run.sh b/tests/image-ci-test/run.sh index 1c67b79..f161ccf 100644 --- a/tests/image-ci-test/run.sh +++ b/tests/image-ci-test/run.sh @@ -5,6 +5,19 @@ group_array=$(cat $TONE_CONF_DIR/functional/image-ci-test.conf | grep -v ^group$) +setup() +{ + if python3 -m pip list | grep avocado-framework; then + python3 -m pip uninstall avocado-framework avocado-framework-plugin-varianter-yaml-to-mux -y + fi + python3 -m pip install --upgrade pip + pip3 install --ignore-installed PyYAML + python3 -m pip install -r $TONE_BM_CACHE_DIR/requirements.txt || { + pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/ + python3 -m pip install -r $TONE_BM_BUILD_DIR/requirements.txt --ignore-installed --trusted-host mirrors.aliyun.com + } +} + run(){ [ -n "$group" ] || { echo "No group in specfile" -- Gitee From 238af453e45972066cae4e890c63669fcceaa506 Mon Sep 17 00:00:00 2001 From: "zhangtaibo.ztb" Date: Fri, 26 Apr 2024 11:02:10 +0800 Subject: [PATCH 3/4] sync run.sh's code --- tests/image-ci-test/run.sh | 88 ++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 14 deletions(-) diff --git a/tests/image-ci-test/run.sh b/tests/image-ci-test/run.sh index f161ccf..0a6e012 100644 --- a/tests/image-ci-test/run.sh +++ b/tests/image-ci-test/run.sh @@ -1,8 +1,9 @@ #!/bin/bash # Avaliable environment variables: -# $C_VERSION: image version seperated by '#' -# $CONTAINER_ENGINE: container engine for func test seperated by '/' - +# $USERNAME: host username, only one or username list seperated by ',' +# $PASSWROD: host password, only one or password list seperated by ',' +# $HOST_IP: host ip list seperated by ',' +# $HOST_NAME: host name list seperated by ',' group_array=$(cat $TONE_CONF_DIR/functional/image-ci-test.conf | grep -v ^group$) setup() @@ -18,7 +19,8 @@ setup() } } -run(){ +run() +{ [ -n "$group" ] || { echo "No group in specfile" return 1 @@ -29,7 +31,6 @@ run(){ } export PYTHONPATH=$TONE_BM_RUN_DIR/tests - option="" IFS=', ' read -ra run_tags <<< "$TONE_TESTCASES" for tag in "${run_tags[@]}"; do if [ -n "$tag" ] && [ "$tag" != "null" ] && [ "$tag" != "container_default" ]; then @@ -37,7 +38,13 @@ run(){ fi done generate_yaml - if [ "$group" == "keentune_application_container_func_test" ]; then + if [ "$group" == "vhd_smoke_test" ]; then + for vhd_case in $(find $TONE_BM_RUN_DIR/tests -type f -name "*.py" -exec grep -l "tags=.*vhd_img" {} +); do + avocado -V run --nrunner-max-parallel-tasks 1 $vhd_case -m $TONE_BM_RUN_DIR/hosts.yaml -t vhd_img + casename=$(echo $vhd_case | xargs basename | cut -d. -f1) + cp -rH $HOME/avocado/job-results/latest/test-results/ $TONE_CURRENT_RESULT_DIR/$casename + done + elif [ "$group" == "keentune_application_container_func_test" ]; then if echo "$CONTAINER_SERVICE" |grep -q "optimized"; then service_name=${CONTAINER_SERVICE/optimized/keentune} else @@ -46,6 +53,14 @@ run(){ avocado -V run --nrunner-max-parallel-tasks 1 $TONE_BM_RUN_DIR/tests/keentune/tc_container_${service_name}_001.py --mux-yaml $TONE_BM_RUN_DIR/hosts.yaml cp -rH $HOME/avocado/job-results/latest/test-results/ $TONE_CURRENT_RESULT_DIR/$casename else + yaml_add_registry + # yaml_add_engine + c_engine=(`echo $CONTAINER_ENGINE | tr '/' ' '`) +cat >> hosts.yaml << EOF +engines: !mux +EOF + + #container_default 默认 for vhd_case in $(find $TONE_BM_RUN_DIR/tests -type f -name "*.py" -exec grep -l "tags=.*container_default" {} +| xargs grep -LE "tags=.*_container_default" ); do echo $vhd_case >> /tmp/case_file.txt done @@ -57,11 +72,28 @@ run(){ echo $vhd_case >> /tmp/case_file.txt done done + + test_cases="" for vhd_case in $(sort /tmp/case_file.txt | uniq); do - avocado -V run --nrunner-max-parallel-tasks 1 $vhd_case -m $TONE_BM_RUN_DIR/hosts.yaml - casename=$(echo $vhd_case | xargs basename | cut -d. -f1) - cp -rH $HOME/avocado/job-results/latest/test-results/ $TONE_CURRENT_RESULT_DIR/$casename + test_cases="$test_cases $vhd_case" done + + for ((i = 0; i < ${#c_engine[@]}; i++)); do + if grep -E "engine[0-9]+:" hosts.yaml > /dev/null; then + sed -i "s/engine[0-9]:/engine$i:/g" hosts.yaml + sed -i "s/engine: .*/engine: ${c_engine[$i]}/g" hosts.yaml + else +cat >> hosts.yaml << EOF + engine$i: + engine: ${c_engine[$i]} +EOF + fi + # 传当前的测试engine给avocado JobPre plugin + export TEST_ENGINE=${c_engine[$i]} + avocado -V run --nrunner-max-parallel-tasks 1 $test_cases -m $TONE_BM_RUN_DIR/hosts.yaml + cp -rH $HOME/avocado/job-results/latest/test-results/ $TONE_CURRENT_RESULT_DIR/ + done + rm -rf /tmp/case_file.txt fi @@ -74,13 +106,37 @@ parse() generate_yaml() { - registry_addr=(`echo $REGISTRY_ADDR | tr '#' ' '`) - c_engine=(`echo $CONTAINER_ENGINE | tr '/' ' '`) + username=(`echo $USERNAME | tr '/' ' '`) + password=(`echo $PASSWORD | tr '/' ' '`) + host_ip=(`echo $HOST_IP | tr '/' ' '`) + host_name=(`echo $HOST_NAME | tr '/' ' '`) cat > hosts.yaml << EOF hosts: !mux - localhost: - host: localhost -registry: !mux +EOF + for ((i = 0; i < ${#host_ip[@]}; i++)); do +cat >> hosts.yaml << EOF + ${host_name[$i]}$i: + remote: ${host_ip[$i]} +EOF + if [[ ${#username[@]} -eq 1 ]]; then +cat >> hosts.yaml << EOF + username: $username + password: $password +EOF + else +cat >> hosts.yaml << EOF + username: ${username[$i]} + password: ${password[$i]} +EOF + fi + done +} + +yaml_add_registry() +{ + registry_addr=(`echo $REGISTRY_ADDR | tr '#' ' '`) +cat >> hosts.yaml << EOF +registries: !mux EOF for ((i = 0; i < ${#registry_addr[@]}; i++)); do cat >> hosts.yaml << EOF @@ -88,7 +144,11 @@ cat >> hosts.yaml << EOF registry: ${registry_addr[$i]} EOF done +} +yaml_add_engine() +{ + c_engine=(`echo $CONTAINER_ENGINE | tr '/' ' '`) cat >> hosts.yaml << EOF engines: !mux EOF -- Gitee From c2239de40745ac80faee315fe38f2eeeda0981fb Mon Sep 17 00:00:00 2001 From: "zhangtaibo.ztb" Date: Tue, 7 May 2024 11:41:07 +0800 Subject: [PATCH 4/4] fix anolis-sys-tests's install --- tests/anolis-sys-tests/install.sh | 4 ---- tests/anolis-sys-tests/run.sh | 9 +++++++++ tests/image-ci-test/install.sh | 6 ++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/anolis-sys-tests/install.sh b/tests/anolis-sys-tests/install.sh index 1733193..48b052a 100755 --- a/tests/anolis-sys-tests/install.sh +++ b/tests/anolis-sys-tests/install.sh @@ -11,10 +11,6 @@ build() { } install() { - python3 -m pip install -r $TONE_BM_BUILD_DIR/requirements.txt || { - pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/ - python3 -m pip install -r $TONE_BM_BUILD_DIR/requirements.txt --ignore-installed --trusted-host mirrors.aliyun.com - } cp -a $TONE_BM_BUILD_DIR/* $TONE_BM_RUN_DIR } diff --git a/tests/anolis-sys-tests/run.sh b/tests/anolis-sys-tests/run.sh index d83bda2..cb54e56 100755 --- a/tests/anolis-sys-tests/run.sh +++ b/tests/anolis-sys-tests/run.sh @@ -9,6 +9,15 @@ . $TONE_ROOT/lib/testinfo.sh setup() { + if python3 -m pip list | grep avocado-framework; then + python3 -m pip uninstall avocado-framework avocado-framework-plugin-varianter-yaml-to-mux -y + fi + python3 -m pip install --upgrade pip + pip3 install --ignore-installed PyYAML + python3 -m pip install -r $TONE_BM_RUN_DIR/requirements.txt || { + pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/ + python3 -m pip install -r $TONE_BM_RUN_DIR/requirements.txt --ignore-installed --trusted-host mirrors.aliyun.com + } export PYTHONPATH=$PYTHONPATH:$TONE_BM_RUN_DIR/tests IFS="," } diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index 81686a9..b32335a 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -9,11 +9,9 @@ DEP_PKG_LIST="python3" fetch() { - git_clone $GIT_URL $TONE_BM_CACHE_DIR + : } - - build() { : @@ -21,7 +19,7 @@ build() install() { - cp -Trf $TONE_BM_CACHE_DIR $TONE_BM_RUN_DIR + cp -Trf $TONE_BM_BUILD_DIR $TONE_BM_RUN_DIR } -- Gitee