Skip to content

Commit

Permalink
Properly localize testurl variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
perlpunk committed Nov 27, 2024
1 parent 7ce0198 commit 02626cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions openqa-label-known-issues
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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[@]}")
Expand Down
19 changes: 9 additions & 10 deletions test/07-openqa-label-known-issues.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ 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
setup 404
older40d_date=$(date -uIs -d '-40days')
echo -n "Result:<b>incomplete</b>finished<abbr class=\"timeago\" title=\"${older40d_date}\"</abbr>>" > $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"

Expand All @@ -83,7 +82,7 @@ echo -n "Result:<b>incomplete</b>finished<abbr class=\"timeago\" title=\"${older
html_out=$tmpjobpage
export JOB_HTML_FILE=$tmpjobpage
echo > $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
Expand All @@ -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"

0 comments on commit 02626cd

Please sign in to comment.