From a79bb8bc2d7cb823cb7e2362782c6255c2f25346 Mon Sep 17 00:00:00 2001 From: wannianbuxiang Date: Mon, 20 Nov 2023 07:08:07 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=88=86=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wannianbuxiang --- tests/image-ci-test/run.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/image-ci-test/run.sh b/tests/image-ci-test/run.sh index c63c875..76f2e7f 100644 --- a/tests/image-ci-test/run.sh +++ b/tests/image-ci-test/run.sh @@ -23,10 +23,12 @@ run() fi option="" - run_tags=(`echo $TONE_TESTCASES`) - if [ -n "$run_tags" ] && [ "$run_tags" != "null" ] && [ "$run_tags" != "container_default" ]; then - option="-t $run_tags" - fi + IFS=', ' read -ra run_tags <<< "$TONE_TESTCASES" + for tag in "${run_tags[@]}"; do + if [ -n "$tag" ] && [ "$tag" != "null" ] && [ "$tag" != "container_default" ]; then + option+="-t $tag " + fi + done generate_yaml if [ "$group" == "container_startup_test" ]; then -- Gitee From 820bd9d289d2749e2e611b0c3943b12a111e1ec1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 14 Dec 2023 15:27:00 +0800 Subject: [PATCH 2/5] fix --- tests/image-ci-test/install.sh | 7 +++-- tests/image-ci-test/parse.py | 17 +++++------- tests/image-ci-test/run.sh | 47 ++++++++++++++++------------------ 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index d6a40f4..f1349b1 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -3,13 +3,13 @@ # # Download variable: # WEB_URL= -GIT_URL="https://gitee.com/anolis/anolis-ci-test.git" +GIT_URL="https://gitee.com/wannianbuxiang/anolis-pkg-tests.git" DEP_PKG_LIST="python3" fetch() { - git_clone $GIT_URL $TONE_BM_CACHE_DIR + git_clone $GIT_URL $TONE_BM_RUN_DIR } @@ -21,7 +21,6 @@ build() install() { - python3 -m pip install -r $TONE_BM_CACHE_DIR/image_ci/requirements.txt - cp -Trf $TONE_BM_CACHE_DIR $TONE_BM_RUN_DIR + python3 -m pip install -r $TONE_BM_RUN_DIR/image_ci/requirements.txt } diff --git a/tests/image-ci-test/parse.py b/tests/image-ci-test/parse.py index 586fc6b..b5e5d03 100755 --- a/tests/image-ci-test/parse.py +++ b/tests/image-ci-test/parse.py @@ -4,17 +4,14 @@ import re with sys.stdin as stdin: for line in stdin: - if '====SKIP' in line: - print("SKIP") - match = re.search(r'tests/(.+);run-(.+)-.+: (PASS|FAIL|SKIP|ERROR|WARN|INTERRUPT|CANCEL)', line) + match = re.search(r'(tests/\S+)\.py\S+:\s+(\w+)', line) if match: group = match.groups() - name, host, result = (group[0], group[1], group[2]) - if result in ['ERROR', 'INTERRUPT', 'CANCEL']: + path, result = (match.group(1,2)) + if result in ['ERROR', 'WARN', 'INTERRUPT', 'CANCEL']: result = 'FAIL' - if result is 'WARN': - result = 'Warning' - if 'py' in name: - name = name.split(':')[1] - print('localhost-{}: {}'.format(name, result.title())) + if result in ['STARTED']: + continue + name = path.split('/')[-1] + print('{}: {}'.format(name, result)) diff --git a/tests/image-ci-test/run.sh b/tests/image-ci-test/run.sh index 76f2e7f..1c67b79 100644 --- a/tests/image-ci-test/run.sh +++ b/tests/image-ci-test/run.sh @@ -5,23 +5,17 @@ group_array=$(cat $TONE_CONF_DIR/functional/image-ci-test.conf | grep -v ^group$) -run() -{ +run(){ [ -n "$group" ] || { echo "No group in specfile" return 1 } - [[ "$group_array" =~ "$group" ]] || { echo "$group is not supported" return 1 } - export PYTHONPATH=$TONE_BM_RUN_DIR/image_ci/tests - registry_type=(`echo $REGISTRY_TYPE | tr '/' ' '`) - if [ "$registry_type" == "app" ]; then - export CONTAINER_ENGINE=docker - fi + export PYTHONPATH=$TONE_BM_RUN_DIR/tests option="" IFS=', ' read -ra run_tags <<< "$TONE_TESTCASES" for tag in "${run_tags[@]}"; do @@ -29,32 +23,35 @@ run() option+="-t $tag " fi done - generate_yaml - if [ "$group" == "container_startup_test" ]; then - avocado -V run --nrunner-max-parallel-tasks 1 $TONE_BM_RUN_DIR/image_ci/tests/smoke --mux-yaml $TONE_BM_RUN_DIR/hosts.yaml -t container $option - elif [ "$group" == "application_container_func_test" ]; then - if [ "$registry_type" == "app" ]; then - avocado -V run --nrunner-max-parallel-tasks 1 $TONE_BM_RUN_DIR/image_ci/tests/smoke --mux-yaml $TONE_BM_RUN_DIR/hosts.yaml -t app_container - else - echo "====SKIP:$group" - fi - elif [ "$group" == "keentune_application_container_func_test" ]; then + if [ "$group" == "keentune_application_container_func_test" ]; then if echo "$CONTAINER_SERVICE" |grep -q "optimized"; then service_name=${CONTAINER_SERVICE/optimized/keentune} else service_name=$CONTAINER_SERVICE fi - avocado -V run --nrunner-max-parallel-tasks 1 $TONE_BM_RUN_DIR/image_ci/tests/keentune/tc_container_${service_name}_001.py --mux-yaml $TONE_BM_RUN_DIR/hosts.yaml + 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 - option="$option -t 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 if [ "$group" != "container_default_group" ]; then - option="$option -t ${group}_default" + run_tags+=("${group}_default") fi - cd $TONE_BM_RUN_DIR/image_ci - avocado -V run --nrunner-max-parallel-tasks 1 $TONE_BM_RUN_DIR/image_ci/tests/smoke --mux-yaml $TONE_BM_RUN_DIR/hosts.yaml $option + for element in "${run_tags[@]}"; do + for vhd_case in $(find $TONE_BM_RUN_DIR/tests -type f -name "*.py" -exec grep -l "tags=.*$element" {} +); do + echo $vhd_case >> /tmp/case_file.txt + done + done + 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 + done + rm -rf /tmp/case_file.txt fi - cp -rH $HOME/avocado/job-results/latest $TONE_CURRENT_RESULT_DIR + } parse() @@ -75,7 +72,7 @@ EOF for ((i = 0; i < ${#registry_addr[@]}; i++)); do cat >> hosts.yaml << EOF registry$i: - version: ${registry_addr[$i]} + registry: ${registry_addr[$i]} EOF done -- Gitee From dfd9fabad95b206728556bee27814247db6897ac Mon Sep 17 00:00:00 2001 From: wannianbuxiang Date: Thu, 14 Dec 2023 07:55:52 +0000 Subject: [PATCH 3/5] giturl Signed-off-by: wannianbuxiang --- tests/image-ci-test/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index f1349b1..6328865 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -3,7 +3,7 @@ # # Download variable: # WEB_URL= -GIT_URL="https://gitee.com/wannianbuxiang/anolis-pkg-tests.git" +GIT_URL="https://gitee.com/anolis/anolis-sys-tests.git" DEP_PKG_LIST="python3" -- Gitee From b530c3b8118acb87981b8535af9a6c65b7f8960c Mon Sep 17 00:00:00 2001 From: wannianbuxiang Date: Thu, 14 Dec 2023 08:59:11 +0000 Subject: [PATCH 4/5] fix Signed-off-by: wannianbuxiang --- tests/image-ci-test/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index 6328865..8c6c9ba 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -9,7 +9,7 @@ DEP_PKG_LIST="python3" fetch() { - git_clone $GIT_URL $TONE_BM_RUN_DIR + git_clone $GIT_URL $TONE_BM_CACHE_DIR } @@ -21,6 +21,8 @@ build() install() { - python3 -m pip install -r $TONE_BM_RUN_DIR/image_ci/requirements.txt + python3 -m pip install -r $TONE_BM_CACHE_DIR/requirements.txt + cp -Trf $TONE_BM_CACHE_DIR $TONE_BM_RUN_DIR + } -- Gitee From dd2d6096e22c8175ba4f22a871a0313561b546c6 Mon Sep 17 00:00:00 2001 From: wannianbuxiang Date: Thu, 14 Dec 2023 09:02:24 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wannianbuxiang --- tests/image-ci-test/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/image-ci-test/install.sh b/tests/image-ci-test/install.sh index 2bf2472..8c6c9ba 100644 --- a/tests/image-ci-test/install.sh +++ b/tests/image-ci-test/install.sh @@ -9,7 +9,7 @@ DEP_PKG_LIST="python3" fetch() { - git_clone $GIT_URL $TONE_BM_RUN_DIR + git_clone $GIT_URL $TONE_BM_CACHE_DIR } -- Gitee