Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make investigation comment more prominent #272

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions openqa-investigate
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ curl_args=(-L --user-agent "openqa-investigate")
echoerr() { echo "$@" >&2; }

clone() {
local origin id name_suffix refspec unsupported_cluster_jobs pending_cluster_jobs name base_prio clone_settings casedir repo out url clone_id
local origin id name_suffix refspec unsupported_cluster_jobs pending_cluster_jobs name base_prio clone_settings casedir repo out clone_id
origin=${1:?"Need 'origin'"}
id=${2:?"Need 'id'"}
name_suffix=${3+":$3"}
Expand Down Expand Up @@ -66,9 +66,8 @@ clone() {

# output: { "$id": $clone_id }
clone_id=$(echo "$out" | runjq -r ".\"$id\"")
url="$scheme://$host/t$clone_id"
# Create markdown list entry
echo "* **$name**: $url"
echo "* *$name*: t#$clone_id"
asdil12 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job status bubbles created via javascript when loading comments don't recognize this syntax, e.g. compare
https://openqa.opensuse.org/tests/3734688#comments (good) vs.
https://openqa.opensuse.org/tests/3751441#comments (bad)

"${client_call[@]}" --json --data "{\"priority\": $((base_prio + prio_add))}" -X PUT jobs/"$clone_id" >/dev/null
}

Expand Down Expand Up @@ -190,13 +189,13 @@ fetch-investigation-results() {
local origin_job_id=$1
local state job investigate_type other_id result investigate_comment output comment_lines

investigate_comment=$("${client_call[@]}" -X GET jobs/"$origin_job_id"/comments | runjq -r '[.[] | select(.text | contains("Automatic investigation jobs for job") and contains(":investigate:retry**:"))] | min_by(.id)') || return $?
investigate_comment=$("${client_call[@]}" -X GET jobs/"$origin_job_id"/comments | runjq -r '[.[] | select(.text | contains("Automatic investigation jobs for job") and contains(":investigate:retry*:"))] | min_by(.id)') || return $?
[[ $investigate_comment == 'null' ]] && return
output=$(echo "$investigate_comment" | runjq -r '.text') || return $?
mapfile -t comment_lines <<<"$output"

for line in "${comment_lines[@]}"; do
if [[ $line =~ :investigate:([^:*]+).*\/t([0-9]+) ]]; then
if [[ $line =~ :investigate:([^:*]+).*t\#([0-9]+) ]]; then
investigate_type=${BASH_REMATCH[1]}
other_id=${BASH_REMATCH[2]}
job=$(openqa-cli "${client_args[@]}" --json experimental/jobs/"$other_id"/status)
Expand Down Expand Up @@ -259,21 +258,22 @@ post-investigate() {
# cluster jobs might have the same OPENQA_INVESTIGATE_ORIGIN as the root retry job
[[ $retry_name != "$origin_name:investigate:retry" ]] && echo "Job $retry_name ($id) is not a retry of $origin_name ($origin_job_id)" && return 0

comment="Investigate retry job **$retry_name**: $host_url/t$id"
comment="Investigate retry job *$retry_name*: t#$id"
if is-ok "$retry_result"; then
comment+=" $retry_result, likely a sporadic failure"
comment+=" $retry_result."$'\n\n'
comment+="📋 **Likely a sporadic failure**."
else
comment+=" failed"
comment+=" failed."$'\n\n'
local product_issue=false
local test_issue=false
identify-issue-type "$origin_job_id" || return $?

if "$product_issue"; then
comment+="."$'\n'"Jobs including the last good build are ok, likely a product issue"
comment+="📋 **Jobs including the last good build are ok, likely a product issue**."
elif "$test_issue"; then
comment+="."$'\n'"Jobs including the last good test are ok, likely a test issue"
comment+="📋 **Jobs including the last good test are ok, likely a test issue**."
else
comment+=", likely not a sporadic failure"
comment+="📋 **Likely not a sporadic failure**."
fi
fi

Expand Down
16 changes: 8 additions & 8 deletions test/02-investigate.t
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ openqa-cli() {
elif [[ $@ == "-X GET jobs/10032/comments" ]]; then
echo '[{"id": 1236, "text":"Starting investigation for job 10032"},{"id": 1237, "text":"Starting investigation for job 10032"}]'
elif [[ $@ == "-X GET jobs/3000/comments" ]]; then
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n**a:investigate:retry**:url/t30001\n**a:investigate:last_good_tests:coffee**:url/t30002\n**a:investigate:last_good_build:2001**:url/t30003\n**a:investigate:last_good_tests_and_build:coffee+2001**:url/t30004"}]'
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n*a:investigate:retry*: t#30001\n*a:investigate:last_good_tests:coffee*: t#30002\n*a:investigate:last_good_build:2001*: t#30003\n*a:investigate:last_good_tests_and_build:coffee+2001*: t#30004"}]'
elif [[ $@ == "-X GET jobs/3002/comments" ]]; then
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n**a:investigate:retry**:url/t30021\n**a:investigate:last_good_tests:coffee**:url/t30022\n**a:investigate:last_good_build:2001**:url/t30023\n**a:investigate:last_good_tests_and_build:coffee+2001**:url/t34024"}]'
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n*a:investigate:retry*: t#30021\n*a:investigate:last_good_tests:coffee*: t#30022\n*a:investigate:last_good_build:2001*: t#30023\n*a:investigate:last_good_tests_and_build:coffee+2001*: t#34024"}]'
elif [[ $@ == "-X GET jobs/3003/comments" ]]; then
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n**a:investigate:retry**:url/t30031\n**a:investigate:last_good_tests:coffee**:url/t30032\n**a:investigate:last_good_build:2001**:url/t30033\n**a:investigate:last_good_tests_and_build:coffee+2001**:url/t30034"}]'
echo '[{"id": 1236, "text":"Automatic investigation jobs for job\n*a:investigate:retry*: t#30031\n*a:investigate:last_good_tests:coffee*: t#30032\n*a:investigate:last_good_build:2001*: t#30033\n*a:investigate:last_good_tests_and_build:coffee+2001*: t#30034"}]'

# PUT jobs/id/comments/id
elif [[ $@ =~ $'-X PUT jobs/10030/comments/1234 text=Automatic investigation jobs for job 10031:\n\nfoo' ]]; then
Expand Down Expand Up @@ -136,7 +136,7 @@ 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" "* *$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"

clone_call=echo
Expand Down Expand Up @@ -174,20 +174,20 @@ test-post-investigate() {
try investigate 30001
is "$rc" 2 'mocked function returned failure (30001)'
has "$got" "Commenting 3000" "Posting comment on OPENQA_INVESTIGATE_ORIGIN (30001)"
has "$got" "Investigate retry job **vim:investigate:retry**" "retry test name appears in comment(30001)"
has "$got" "Investigate retry job *vim:investigate:retry*" "retry test name appears in comment(30001)"
has "$got" "likely a product issue" "product issue (30001)"

# retry passed
try investigate 30003
is "$rc" 2 'mocked function returned failure (30003)'
has "$got" "Commenting 3000" "Posting comment on OPENQA_INVESTIGATE_ORIGIN (30003)"
has "$got" "likely a sporadic" "sporadic (passed) (30003)"
has "$got" "Likely a sporadic" "sporadic (passed) (30003)"

# retry softfailed
try investigate 30003
is "$rc" 2 'mocked function returned failure (30003)'
has "$got" "Commenting 3000" "Posting comment on OPENQA_INVESTIGATE_ORIGIN (30003)"
has "$got" "likely a sporadic" "sporadic (softfailed) (30003)"
has "$got" "Likely a sporadic" "sporadic (softfailed) (30003)"

# retry softfailed
try investigate 30005
Expand All @@ -198,7 +198,7 @@ test-post-investigate() {
try investigate 30031
is "$rc" 2 'mocked function returned failure (30031)'
has "$got" "Commenting 3003" "Posting comment on OPENQA_INVESTIGATE_ORIGIN (30031)"
has "$got" "Investigate retry job **vim:investigate:retry**" "retry test name appears in comment(30031)"
has "$got" "Investigate retry job *vim:investigate:retry*" "retry test name appears in comment(30031)"
has "$got" "likely a test issue" "test issue (30031)"

# 142 not finished yet
Expand Down
Loading