From 02626cd1975c65814f61c03e907564a95c7e1cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Wed, 27 Nov 2024 12:12:25 +0100 Subject: [PATCH] Properly localize testurl variable and pass the correct variable. investigate_issue gets a url as a parameter and then strips everything until the last slash to get the id. --- openqa-label-known-issues | 5 +++-- test/07-openqa-label-known-issues.t | 19 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openqa-label-known-issues b/openqa-label-known-issues index ea52cc0..306fa88 100755 --- a/openqa-label-known-issues +++ b/openqa-label-known-issues @@ -130,7 +130,8 @@ label_on_issues_without_tickets() { } investigate_issue() { - local id="${1##*/}" + local testurl=$1 + local id="${testurl##*/}" local reason local curl_output echo "Requesting jobs/${id} via openqa-cli" @@ -174,7 +175,7 @@ investigate_issue() { } label_issue() { - testurl="${1:?"Need 'testurl'"}" + local testurl="${1:?"Need 'testurl'"}" [[ "$dry_run" = "1" ]] && client_prefix="echo" if [[ -z "$client_call" ]]; then client_call=(openqa-cli "${client_args[@]}") diff --git a/test/07-openqa-label-known-issues.t b/test/07-openqa-label-known-issues.t index 69a9396..5b4d5d4 100644 --- a/test/07-openqa-label-known-issues.t +++ b/test/07-openqa-label-known-issues.t @@ -60,9 +60,8 @@ out=$tmplog tmpjobpage=$(mktemp) setup() { - local id=$1 - declare -g id=$id - declare -g testurl="https://openqa.opensuse.org/tests/${id}" + id=$1 + testurl="https://openqa.opensuse.org/tests/${id}" } # test data with reason but 404 in curl respond @@ -70,7 +69,7 @@ setup 404 older40d_date=$(date -uIs -d '-40days') echo -n "Result:incompletefinished>" > $tmpjobpage export JOB_HTML_FILE=$tmpjobpage -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'investigate_issue with missing autoinst-log and with reason in job_data' #ok 3 has "$got" "without autoinst-log.txt older than 14 days. Do not label" "exits succefully when is old job without autoinst-log.txt" @@ -83,7 +82,7 @@ echo -n "Result:incompletefinished $tmplog -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'investigate_issue with missing autoinst-log but with reason in job_data' # ok 4 has "$got" "does not have autoinst-log.txt or reason, cannot label" "investigation exits when no reason and autoinst-log" # Cleanup 404.json @@ -92,28 +91,28 @@ sed -i "s/${older1d_date}/yyyy-mm-dd/" "$dir/data/${id}.json" # Unknown reason - not included in issues setup 102 echo -n "\nthe reason is whatever" >> $tmplog -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'investigate no old issue with missing autoinst-log and unknown reason in job_data' has "$got" "Unknown test issue, to be reviewed" "investigation still label Unknown reason" setup 414 -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'investigate_issue with missing old autoinst-log and without reason in job_data' has "$got" "does not have autoinst-log.txt or reason, cannot label" "investigation exits successfully when no reason and no autoinst-log" setup 200 cp $autoinst_log $tmplog -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'investigate_issue with autoinst-log and without reason' has "$got" "test fails in network_peering" "investigation label job with matched autoinst-log context" # handle_unreview branch echo > "$tmplog" -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'job with empty autoinst-log checks unknown issue' has "$got" "Unknown test issue, to be reviewed" "investigation still label Unknown issue" echo -n "[error] Failed to download" > $out -try-client-output investigate_issue $id +try-client-output investigate_issue $testurl is "$rc" 0 'job label without tickets' has "$got" "label:download_error potentially out-of-space worker?" "investistigation label correctly job without ticket"