Skip to content

Commit

Permalink
Merge pull request #278 from b10n1k/fix_openqa_investigate
Browse files Browse the repository at this point in the history
Assign correct CASEDIR based on TEST_GIT_URL on clone function
  • Loading branch information
mergify[bot] authored Jan 18, 2024
2 parents 6694388 + 72df157 commit b0326a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions _common
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enable_force_result=${enable_force_result:-false}

client_call=()
client_args=()
curl_args=()
markdown_cmd=$(command -v Markdown.pl) || markdown_cmd=$(command -v markdown) \
|| warn "+++ (Markdown.pl|markdown) not found, please install Text::Markdown +++"
openqa_cli="${openqa_cli:-""}"
Expand Down Expand Up @@ -255,3 +256,7 @@ find_latest_published_tumbleweed_image() {
echo "$image"
}

fetch-vars-json() {
local tid=$1
runcurl "${curl_args[@]}" -sS "$host_url/tests/$tid"/file/vars.json || return $?
}
3 changes: 3 additions & 0 deletions openqa-investigate
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ clone() {
base_prio=$(echo "$clone_job_data" | runjq -r '.job.priority') || return $?
clone_settings=("TEST+=:investigate$name_suffix" '_TRIGGER_JOB_DONE_HOOK=1' '_GROUP_ID=0' 'BUILD=')
if [[ $refspec ]]; then
vars_json=$(fetch-vars-json "$origin")
testgiturl=$(echo "$vars_json" | runjq -r '.TEST_GIT_URL')
casedir=$(echo "$clone_job_data" | runjq -r '.job.settings.CASEDIR') || return $?
[[ $testgiturl != null ]] && casedir=$testgiturl
[[ $casedir == null ]] && casedir=''
repo=${casedir:-'https://github.com/os-autoinst/os-autoinst-distri-opensuse.git'}
clone_settings+=("CASEDIR=${repo%#*}#${refspec}")
Expand Down
26 changes: 25 additions & 1 deletion test/02-investigate.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source test/init
bpan:source bashplus +err +fs +sym

plan tests 73
plan tests 79

host=localhost
url=https://localhost
Expand Down Expand Up @@ -32,6 +32,8 @@ openqa-cli() {
# GET jobs/id
if [[ "$1 $2" == "--json jobs/10024" ]]; then
echo '{"job": { "test": "vim", "priority": 50, "settings" : {} } }'
elif [[ "$1 $2" == "--json jobs/10030" ]]; then
echo '{"job": { "test": "vim", "priority": "50", "settings":{"CASEDIR": "https://github.com/os-autoinst/os-autoinst-testrepo.git"} } }'
elif [[ "$1 $2" == "--json jobs/10027" ]]; then
echo '{"job": { "test": "vim", "clone_id" : 10028 } }'
elif [[ "$1 $2" == "--json jobs/3000" ]]; then
Expand Down Expand Up @@ -132,13 +134,35 @@ clone_call=echo
_clone_call() {
echo "$@" >&2
}

fetch-vars-json() {
local tid=$1
if [[ $tid -eq 10020 ]]; then
echo '{"TEST_GIT_URL": "https://github.com/os-autoinst/os-autoinst-distri-openQA.git"}'
else
echo '{}'
fi
}

clone_call=_clone_call
try clone 10023 10024
is "$rc" 0 "Successful clone"
testlabel="vim:investigate"
has "$got" "* *$testlabel*: " "Expected markdown output of job urls for unsupported clusters"
has "$got" '_TRIGGER_JOB_DONE_HOOK=1' "job is cloned with _TRIGGER_JOB_DONE_HOOK"

try clone 10023 10024 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'CASEDIR=.*/os-autoinst-distri-opensuse.git#refspec' "job is cloned and it uses default CASEDIR"

try clone 10020 10024 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'CASEDIR=.*/os-autoinst-distri-openQA.git#refspec' "job is cloned with sets CASEDIR from TEST_GIT_URL"

try clone 10023 10030 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'CASEDIR=.*/os-autoinst-testrepo.git#refspec' "job is cloned and CASEDIR is set correctly"

clone_call=echo
try investigate 10027
is "$rc" 0 'success regardless of actually triggered jobs'
Expand Down

0 comments on commit b0326a4

Please sign in to comment.