Skip to content

Commit

Permalink
Merge pull request #290 from os-autoinst/mm-ping-test
Browse files Browse the repository at this point in the history
Add script for scheduling MM ping test
  • Loading branch information
mergify[bot] committed Feb 13, 2024
2 parents 49990c3 + 0ffcc00 commit f7dc1a0
Show file tree
Hide file tree
Showing 27 changed files with 223 additions and 80 deletions.
8 changes: 4 additions & 4 deletions _common
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ runcli() {
set +e
errorlog=$(mktemp -t runcli-errorlog-XXXX)
# shellcheck disable=SC2064
output=$("${args[@]}" 2>"$errorlog")
output=$("${args[@]}" 2> "$errorlog")
rc=$?
set -e
if [[ -s "$errorlog" ]]; then
read -r errstr <"$errorlog"
read -r errstr < "$errorlog"
warn "$1 ($(caller)): (${args[*]}) stderr: >>>$errstr<<<"
fi
rm "$errorlog"
Expand All @@ -57,7 +57,7 @@ runcli() {
runjq() {
local rc output
local jq_output_limit="${jq_output_limit:-15}"
input=$(</dev/stdin)
input=$(< /dev/stdin)
set +e
output=$(echo "$input" | jq "$@" 2>&1)
rc=$?
Expand Down Expand Up @@ -231,7 +231,7 @@ get_image() {
find_latest_published_tumbleweed_image() {
local latest_builds build image=null assetname
local tw_group_id=$1 arch=$2 machine=$3 type=$4
read -r -a latest_builds <<<"$(latest_published_tw_builds "$tw_group_id")"
read -r -a latest_builds <<< "$(latest_published_tw_builds "$tw_group_id")"
if [[ "${#latest_builds[@]}" -eq 0 ]]; then
warn "Unable to find latest published Tumbleweed builds."
exit 1
Expand Down
4 changes: 2 additions & 2 deletions backlog-set-due-date
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ issues=$(mktemp -t backlog-set-due-date-XXXX)
jquery=".issues | .[] | select(.priority.name!=\"$priority\" and .due_date==null and .assigned_to!=null and .status.name==\"$status\")"

if [ $# -eq 1 ] && [ -f "$1" ] && [ "$dry_run" = "1" ]; then
jq -r "$jquery" "$1" >"$issues"
jq -r "$jquery" "$1" > "$issues"
else
redmine_api_key="${redmine_api_key:?"Need redmine API key"}"
curl -sS -H "X-Redmine-API-Key: $redmine_api_key" "$host/issues.json?query_id=$query_id&limit=$ticket_limit" | jq -r "$jquery" >"$issues"
curl -sS -H "X-Redmine-API-Key: $redmine_api_key" "$host/issues.json?query_id=$query_id&limit=$ticket_limit" | jq -r "$jquery" > "$issues"
fi

[ "$dry_run" = "1" ] && prefix="echo"
Expand Down
2 changes: 2 additions & 0 deletions external/os-autoinst-common/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
indent_style = space
indent_size = 4
binary_next_line = true
switch_case_indent = true
space_redirects = true

[.bpan/**]
ignore = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Check subject beginning
uses: gsactions/commit-message-checker@v2
with:
pattern: '^([A-Z]|\S+:|git subrepo pull)'
pattern: '^([A-Z]|\S+:|git subrepo (clone|pull))'
flags: 'g'
error: 'The subject does not start with a capital or tag.'
excludeDescription: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: 'Perl author tests'

on: [push, pull_request]

jobs:
perl-author-tests:
runs-on: ubuntu-latest
name: Perl author tests
container:
image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev
steps:
- uses: actions/checkout@v4
- run: make test-author
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
name: 'Perl critic'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
perl-critic-checks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
---
name: 'Perl static checks'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
perl-lint-checks:
runs-on: ubuntu-latest
name: "Perltidy"
container:
image: perldocker/perl-tester
image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev
steps:
- uses: actions/checkout@v4
- run: GITHUB_ACTIONS=1 ./tools/tidyall --check-only --all --quiet
6 changes: 1 addition & 5 deletions external/os-autoinst-common/.github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
name: 'YAML-lint'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
yaml-lint:
Expand Down
4 changes: 2 additions & 2 deletions external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = git@github.com:os-autoinst/os-autoinst-common.git
branch = master
commit = ef465670789c9b49ce0e4e1f3da61c2cc313a0e0
parent = 73b88030ec6629098e96627cc393ec735ec6727e
commit = db78c615c257969eed5d71f3fcf5efe1a09d3b5c
parent = fb72ceee31d5391760bba113cefc4adff97dde90
method = merge
cmdver = 0.4.6
3 changes: 3 additions & 0 deletions external/os-autoinst-common/.mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pull_request_rules:
- "#review-requested=0"
- -label~=^acceptance-tests-needed|not-ready
- base=master
- "#check-failure=0"
- "#check-pending=0"
- linear-history
actions:
merge:
method: merge
Expand Down
19 changes: 19 additions & 0 deletions external/os-autoinst-common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: help
help:
@echo Call one of the available targets:
@sed -n 's/\(^[^.#[:space:]A-Z]*\):.*$$/\1/p' Makefile | uniq

.PHONY: update-deps
update-deps:
tools/update-deps --cpanfile cpanfile

.PHONY: test
test: test-tidy test-author

.PHONY: test-tidy
test-tidy:
tools/tidyall --all --check-only

.PHONY: test-author
test-author:
prove -l -r xt/
1 change: 0 additions & 1 deletion external/os-autoinst-common/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ main_requires:
# Needed until preaction/Log-Any#105 is solved.
perl(Storable): '>= 3.06'
perl(Module::CPANfile):
perl(version):

develop_requires:
perl(Perl::Tidy): '== 20230912'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ our $VERSION = '0.0.1';

sub default_severity { return $SEVERITY_HIGH }
sub default_themes { return qw(openqa) }
# we only want the check quoted expressions
sub applies_to { return qw(PPI::Token::Quote::Single PPI::Token::Quote::Double) }

# check that hashes are not overly using quotes
# (os-autoinst coding style)
sub violates ($self, $elem, $document) {
#we only want the check hash keys
return if !is_hash_key($elem);
# skip anything that's not a hash key
return () unless is_hash_key($elem);

my $c = $elem->content;
# special characters
return if $c =~ m/[- \/<>.=_:\\\$\|]/;
my $k = $elem->literal;
# skip anything that has a special symbol in the content
return () unless $k =~ m/^\w+$/;

# report violation
my $desc = q{Hash key with quotes};
my $expl = q{Avoid useless quotes};
my $expl = qq{Avoid useless quotes for key "$k"};
return $self->violation($desc, $expl, $elem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,56 @@ sub applies_to { 'PPI::Statement::Sub' }

# check that use strict/warnings is not present when equivalent modules are.
sub violates ($self, $elem, $doc) {
# Grep the first 7 tokens:
# Case 1: bare sub
# 0. literal "sub"
# 1. :space: # must be 1
# 2. sub_name
# 3. :space: # must be 1
# 4. block/structure
# Case 2: sub with prototype/signature
# 0. literal "sub"
# 1. :space: # must be 1
# 2. sub_name
# 3. :space: # must be 1
# 4. prototype
# 5. :space: # must be 1
# 6. block/structure

# Grep the first 7 tokens: each function will validate the cases.
my @tokens = ($elem->tokens())[0 .. 6];
return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[2]);

return () if $tokens[4]->isa('PPI::Token::Structure');
return () if $elem->forward();
return $self->check_reserved_sub($elem, @tokens) if _is_reserved_sub($elem);
return $self->check_classic_sub($elem, @tokens) unless defined($elem->prototype);
return $self->check_complete_sub($elem, @tokens);
}

return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[4]);
sub report_violation ($self, $elem) {
return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem);
}

return ();
sub check_reserved_sub ($self, $elem, @tokens) {
# "Reserved Sub" token desired layout
# 0. Word - END/BEGIN/etc.
# 1. Whitespace
# 2. Structure - the actual code block.
return () if _is_only_one_space($tokens[1]) && _is_block($tokens[2]);
return $self->report_violation($elem);
}

sub check_classic_sub ($self, $elem, @tokens) {
# "Classic Sub" token desired layout
# 0. Word "sub"
# 1. Whitespace - must be 1
# 2. Word - the sub name
# 3. Whitespace - must be 1
# 4. Structure - the actual code block

return () if _is_surrounded_by_one_space($tokens[2]);
return $self->report_violation($elem);
}

sub check_complete_sub ($self, $elem, @tokens) {
# "Complete Sub" token desired layout
# 0. Word "sub"
# 1. Whitespace - must be 1
# 2. Word - the sub name
# 3. Whitespace - must be 1
# 4. Prototype - sub's prototype/signature
# 5. Whitespace - must be 1
# 6. Structure - the actual code block

return () if _is_surrounded_by_one_space($tokens[2]) && _is_surrounded_by_one_space($tokens[4]);
return $self->report_violation($elem);
}

sub _is_block ($token) {
return $token->isa('PPI::Token::Structure');
}

sub _is_only_one_space ($token) {
Expand All @@ -58,4 +84,8 @@ sub _is_surrounded_by_one_space ($token) {
return _is_only_one_space($token->previous_sibling) && _is_only_one_space($token->next_sibling);
}

sub _is_reserved_sub ($elem) {
return $elem->isa('PPI::Statement::Scheduled');
}

1;
7 changes: 7 additions & 0 deletions external/os-autoinst-common/xt/00-tidy.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/perl
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

use Test::Most;
use Test::Code::TidyAll;
tidyall_ok();
20 changes: 20 additions & 0 deletions external/os-autoinst-common/xt/01-compile-check-all.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

use Test::Most;
# We need :no_end_test here because otherwise it would output a no warnings
# test for each of the modules, but with the same test number
use Test::Warnings qw(:no_end_test :report_warnings);
use FindBin;
use lib "$FindBin::Bin/lib";
use OpenQA::Test::TimeLimit '400';

use Test::Strict;

push @Test::Strict::MODULES_ENABLING_STRICT, 'Test::Most';
push @Test::Strict::MODULES_ENABLING_WARNINGS, 'Test::Most';

$Test::Strict::TEST_SYNTAX = 1;
$Test::Strict::TEST_STRICT = 1;
$Test::Strict::TEST_WARNINGS = 1;
all_perl_files_ok(qw(lib tools xt));
10 changes: 5 additions & 5 deletions openqa-investigate
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ clone() {
# shellcheck disable=SC2207
clone_ids=($(echo "$out" | runjq -r 'values[]'))
for id in "${clone_ids[@]}"; do
"${client_call[@]}" --json --data "{\"priority\": $((base_prio + prio_add))}" -X PUT jobs/"$id" >/dev/null
"${client_call[@]}" --json --data "{\"priority\": $((base_prio + prio_add))}" -X PUT jobs/"$id" > /dev/null
done
}

Expand Down Expand Up @@ -214,7 +214,7 @@ fetch-investigation-results() {
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"
mapfile -t comment_lines <<< "$output"

for line in "${comment_lines[@]}"; do
if [[ $line =~ :investigate:([^:*]+).*t\#([0-9]+) ]]; then
Expand Down Expand Up @@ -244,7 +244,7 @@ identify-issue-type() {
product_issue=false test_issue=false

output=$(fetch-investigation-results "$origin_job_id") || return $?
mapfile -t result_lines <<<"$output"
mapfile -t result_lines <<< "$output"

for line in "${result_lines[@]}"; do
if [[ $line =~ ^([^|]+)\|([^|]+)\|([^|]+) ]]; then
Expand Down Expand Up @@ -303,7 +303,7 @@ post-investigate() {
# gracefully
out=$("${client_call[@]}" -X POST jobs/"$origin_job_id"/comments text="$comment" 2>&1) || rc=$?
if [[ "$rc" -ne 0 ]]; then
status=$(echo "$out" | runjq .error_status 2>/dev/null || echo "unknown")
status=$(echo "$out" | runjq .error_status 2> /dev/null || echo "unknown")
if [[ "$status" != "404" ]]; then
echoerr "Unexpected error encountered when posting comments on job $origin_job_id after investigation job $id failed: '$out'"
return 2
Expand Down Expand Up @@ -377,4 +377,4 @@ main() {
investigate "$@"
}

caller 0 >/dev/null || main "$@"
caller 0 > /dev/null || main "$@"
2 changes: 1 addition & 1 deletion openqa-investigate-multi
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ main() {
exit $rc
}

caller 0 >/dev/null || main "$@"
caller 0 > /dev/null || main "$@"
2 changes: 1 addition & 1 deletion openqa-kill_worker_systemd_jobs_considered_dead
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jobs=$(tail -n 200 /var/log/openqa | sed -n 's/^.*Got \(artefact for job with no worker assigned (maybe running job already considered dead): \(.*\)\|status update for job \([0-9]\+\) with unexpected worker.*expected no updates anymore, job is done with result incomplete.*\)$/\2\3/p' | uniq)
for job in $jobs; do
worker_and_instance=$(sudo -u geekotest psql -q --no-align --tuples-only openqa -c "select host,instance from workers where id=(select assigned_worker_id from jobs where id='$job');")
IFS='|' read worker instance <<<$worker_and_instance
IFS='|' read worker instance <<< $worker_and_instance
salt "${worker}*" cmd.run "grep -q $job /var/lib/openqa/pool/$instance/*.json && systemctl restart openqa-worker@${instance} ||:"
done
6 changes: 3 additions & 3 deletions openqa-label-known-issues
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ handle_unreachable_or_no_log() {

if ! curl "${curl_args[@]}" -s --head "$testurl" -o /dev/null; then
# the page might be gone, try the scheme+host we configured (might be different one though)
if ! grep -q "$host_url" <<<"$testurl"; then
if ! grep -q "$host_url" <<< "$testurl"; then
echoerr "'$testurl' is not reachable and 'host_url' parameter does not match '$testurl', can not check further, continuing with next"
return
fi
Expand Down Expand Up @@ -139,7 +139,7 @@ investigate_issue() {
# combine both the reason and autoinst-log.txt to check known issues
# against even in case when autoinst-log.txt is missing the details, e.g.
# see https://progress.opensuse.org/issues/69178
echo "$reason" >>"$out"
echo "$reason" >> "$out"
if [[ "$curl_output" != "200" ]] && [[ "$curl_output" != "301" ]]; then
# if we can not even access the page it is something more critical
handle_unreachable_or_no_log "$id" "$testurl" "$out"
Expand Down Expand Up @@ -173,4 +173,4 @@ label_issue() {
investigate_issue "$testurl"
}

caller 0 >/dev/null || label_issue "$@"
caller 0 > /dev/null || label_issue "$@"

0 comments on commit f7dc1a0

Please sign in to comment.