From 3929fb6ca86f023b30bfb4946bd5ee65ed337e01 Mon Sep 17 00:00:00 2001 From: Huanian Li Date: Thu, 10 Apr 2025 15:48:54 +0800 Subject: [PATCH] Support to reset TONE_PATH The default location to run tests is "/tmp/tone", but it may not have enough space. To avoid such a problem, we support to reset TONE_PATH by reading it from environment variable. For example, if env TONE_PATH is set to be "/opt/tone", tests will be run under "/opt/tone" instead of "/tmp/tone". Signed-off-by: Huanian Li --- initial/base_config/script/prepare.py | 5 ++++- initial/base_config/script/prepare_debian.py | 5 ++++- initial/base_config/script/run_test.py | 11 +++++++---- initial/base_config/script/run_test_debian.py | 17 ++++++++++------- initial/base_config/script/upload.py | 5 ++++- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/initial/base_config/script/prepare.py b/initial/base_config/script/prepare.py index d555c63..2276362 100644 --- a/initial/base_config/script/prepare.py +++ b/initial/base_config/script/prepare.py @@ -16,7 +16,10 @@ if [ $# -lt 1 ];then exit 1 fi -tone_install=$1 +# Note that the default location to run tests is "/tmp/tone". The loaction will +# be changed if variable TONE_PATH is set by user (e.g. TONE_PATH="/opt/tone"), +# which is pretty helpful if dir "/tmp" doesn't have enough space. +tone_install=${TONE_PATH:-"$1"} provider=$2 logfile=/tmp/prepare_tone.log tone_branch=${TONE_DEBUG_BRANCH:-master} diff --git a/initial/base_config/script/prepare_debian.py b/initial/base_config/script/prepare_debian.py index 7929257..1f5a22b 100644 --- a/initial/base_config/script/prepare_debian.py +++ b/initial/base_config/script/prepare_debian.py @@ -16,7 +16,10 @@ if [ $# -lt 1 ];then exit 1 fi -tone_install=$1 +# Note that the default location to run tests is "/tmp/tone". The loaction will +# be changed if variable TONE_PATH is set by user (e.g. TONE_PATH="/opt/tone"), +# which is pretty helpful if dir "/tmp" doesn't have enough space. +tone_install=${TONE_PATH:-"$1"} provider=$2 logfile=/tmp/prepare_tone.log tone_branch=${TONE_DEBUG_BRANCH:-master} diff --git a/initial/base_config/script/run_test.py b/initial/base_config/script/run_test.py index 65a5571..324d4a4 100644 --- a/initial/base_config/script/run_test.py +++ b/initial/base_config/script/run_test.py @@ -11,7 +11,10 @@ RUN_TEST = """#!/bin/bash # 4.上传测试结果及日志 #-------------------------------------------- -TONE_PATH=$1 +# Note that the default location to run tests is "/tmp/tone". The loaction will +# be changed if variable TONE_PATH is set by user (e.g. TONE_PATH="/opt/tone"), +# which is pretty helpful if dir "/tmp" doesn't have enough space. +TONE_PATH=${TONE_PATH:-"$1"} TONE_BIN=/usr/local/bin/tone TEST_SUITE=$2 TEST_CONF=$3 @@ -117,7 +120,7 @@ function upload_dir(){{ lftp -u ${{TONE_STORAGE_USER}},${{TONE_STORAGE_PASSWORD}} -e "${{SFTP_PARAMS}}" sftp://${{TONE_STORAGE_HOST}}:${{TONE_STORAGE_SFTP_PORT}} >> $ALL_LOG 2>&1 <> "$LOG" echo "${{file:$TONE_RESULT_PATH_LEN}}" diff --git a/initial/base_config/script/run_test_debian.py b/initial/base_config/script/run_test_debian.py index d4656db..f5b3fc9 100644 --- a/initial/base_config/script/run_test_debian.py +++ b/initial/base_config/script/run_test_debian.py @@ -20,7 +20,10 @@ TONE_STORAGE_USER={tone_storage_user} TONE_STORAGE_PASSWORD={tone_storage_password} TONE_STORAGE_BUCKET=${{7:-results}} -TONE_PATH=$1 +# Note that the default location to run tests is "/tmp/tone". The loaction will +# be changed if variable TONE_PATH is set by user (e.g. TONE_PATH="/opt/tone"), +# which is pretty helpful if dir "/tmp" doesn't have enough space. +TONE_PATH=${TONE_PATH:-"$1"} TONE_BIN=/usr/local/bin/tone TEST_SUITE=$2 TEST_CONF=$3 @@ -113,13 +116,13 @@ upload_file(){{ fi mkdir -p $file_path - + expect << EOF set timeout 30 spawn sftp -P $TONE_STORAGE_SFTP_PORT $TONE_STORAGE_USER@$TONE_STORAGE_HOST expect "password" {{ send "$TONE_STORAGE_PASSWORD\\n" }} - + expect "tp>" {{ send "cd $TONE_STORAGE_BUCKET\\n" }} expect "tp>" {{ send "cd $file_path\\n" }} expect "tp>" {{ send "put $file\\n" }} @@ -138,14 +141,14 @@ upload_dir(){{ exit 2 fi - mkdir -p $TONE_JOB_ID/$OSS_RESULT_FOLDER - + mkdir -p $TONE_JOB_ID/$OSS_RESULT_FOLDER + expect << EOF set timeout 30 spawn sftp -P $TONE_STORAGE_SFTP_PORT $TONE_STORAGE_USER@$TONE_STORAGE_HOST expect "password" {{ send "$TONE_STORAGE_PASSWORD\\n" }} - + expect "tp>" {{ send "cd $TONE_STORAGE_BUCKET\\n" }} expect "tp>" {{ send "put -R $TONE_JOB_ID\\n" }} expect "tp>" {{ send "cd $TONE_JOB_ID/$OSS_RESULT_FOLDER\\n" }} @@ -250,4 +253,4 @@ echo $file_result_path >> $LOG echo $file_result_path list_file $TONE_RESULT_PATH -""" \ No newline at end of file +""" diff --git a/initial/base_config/script/upload.py b/initial/base_config/script/upload.py index aed7637..15c62ac 100644 --- a/initial/base_config/script/upload.py +++ b/initial/base_config/script/upload.py @@ -6,7 +6,10 @@ UPLOAD = """#!/bin/bash # 该脚本用来当RUN_TEST步骤失败或者中止后上传执行日志 #-------------------------------------------- -TONE_PATH=$1 +# Note that the default location to run tests is "/tmp/tone". The loaction will +# be changed if variable TONE_PATH is set by user (e.g. TONE_PATH="/opt/tone"), +# which is pretty helpful if dir "/tmp" doesn't have enough space. +TONE_PATH=${TONE_PATH:-"$1"} TEST_SUITE=$2 TEST_CONF=$3 OSS_RESULT_FOLDER=$4 -- Gitee