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 jobs running without needing to set needles URL specifically #5804

Merged
merged 1 commit into from
Aug 7, 2024
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
8 changes: 2 additions & 6 deletions script/openqa-clone-custom-git-refspec
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ clone_job() {
local host=${job_url%%/t*}
local job=${job_url##*/}
fi
if [[ -z "$testsuite" ]] || [[ -z "$needles_dir" ]] || [[ -z "$productdir" ]]; then
if [[ -z "$testsuite" ]] || [[ -z "$productdir" ]]; then
local json_url=${host}/tests/${job}/file/vars.json
local json_data
json_data=$(eval "${curl_openqa} -s ${json_url}")
Expand All @@ -157,10 +157,6 @@ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $h
local productdir="${productdir:-"${repo_name##*/}/${old_productdir#*"${old_casedir##*/}"}"}"
fi
productdir="${productdir/\/\//\/}" # avoid consecutive slashes
local old_needledir
old_needledir=$(echo "$json_data" | jq -r '.NEEDLES_DIR | select (.!=null)') || throw_json_error "$json_url" "$json_data"
local needles_dir="${needles_dir:-"$old_needledir"}"
needles_dir="${needles_dir:-"$old_productdir/needles"}"
fi
local repo_branch="${repo_branch:-"$repo_name#$branch"}"
local test_suffix="${test_suffix:-"@$repo_branch"}"
Expand All @@ -170,7 +166,7 @@ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $h
local dry_run="${dry_run:-""}"
local scriptdir
scriptdir=$(dirname "${BASH_SOURCE[0]}")
local cmd="$dry_run $scriptdir/openqa-clone-job $clone_args \"$host\" \"$job\" _GROUP=\"$GROUP\" TEST+=\"$test_suffix\" BUILD=\"$build\" CASEDIR=\"$casedir\" PRODUCTDIR=\"$productdir\" NEEDLES_DIR=\"$needles_dir\""
local cmd="$dry_run $scriptdir/openqa-clone-job $clone_args \"$host\" \"$job\" _GROUP=\"$GROUP\" TEST+=\"$test_suffix\" BUILD=\"$build\" CASEDIR=\"$casedir\" PRODUCTDIR=\"$productdir\""
[[ ${#args[@]} -ne 0 ]] && cmd=$cmd"$(printf " '%s'" "${args[@]}")"
if [[ -n "$MARKDOWN" ]]; then
eval "$cmd" | sed 's/^Created job.*: \([^ ]*\) -> \(.*\)$/* [\1](\2)/'
Expand Down
21 changes: 8 additions & 13 deletions t/40-script_openqa-clone-custom-git-refspec.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ isnt run_once($args), 0, 'without network we fail (without error)';
# mock any external access with all arguments
$ENV{curl_github} = qq{echo -e '{"head": {"label": "user:my/branch"}, "body": "Lorem ipsum"}'; true};
$ENV{curl_openqa}
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/case/dir", "PRODUCTDIR": "/my/case/dir/product", "NEEDLES_DIR": "/my/case/dir/product/needles"}'; true};
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/case/dir", "PRODUCTDIR": "/my/case/dir/product"}'; true};
my $clone_job
= 'openqa-clone-job --skip-chained-deps --parental-inheritance --within-instance https://openqa.opensuse.org ';
my $dirs
= 'CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/product NEEDLES_DIR=/my/case/dir/product/needles';
my $dirs = 'CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/product';
my $expected = $clone_job . '1234 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#9128 ' . $dirs;
my $expected_re = qr/${expected}/;
test_once $args, $expected_re, 'clone-job command line is correct';
Expand All @@ -53,7 +52,7 @@ my $prefix = 'env repo_name=user/repo pr=9128 host=https://openqa.opensuse.org j
combined_like { $ret = run_once('', $prefix) } $expected_re, 'environment variables can be used instead';
is $ret, 0, 'exits successfully';
$prefix .= ' testsuite=new_test needles_dir=/my/needles productdir=my/product';
$dirs = 'PRODUCTDIR=my/product NEEDLES_DIR=/my/needles';
$dirs = 'PRODUCTDIR=my/product';
my $expected_custom_re = qr{https://openqa.opensuse.org 1234 _GROUP=0 .*${dirs}};
combined_like { $ret = run_once('', $prefix) } $expected_custom_re, 'testsuite and dirs can be overridden';
is $ret, 0, 'exits successfully';
Expand Down Expand Up @@ -103,26 +102,22 @@ $expected_re = qr/${expected}/s;
test_once $args, $expected_re, 'clone-job command with multiple URLs in PR and job URL';

$ENV{curl_github} = qq{echo -e '{"head": {"label": "user:my/branch"}, "body": "Lorem ipsum"}'; true};
my $needles = 'my/distri/products/sle/needles';
$ENV{curl_openqa}
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "my/distri", "PRODUCTDIR": "distri/products/sle", "NEEDLES_DIR": "$needles"}'; true};
$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle NEEDLES_DIR=$needles";
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "my/distri", "PRODUCTDIR": "distri/products/sle"}'; true};
$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle";
$expected = $clone_job . '1169326 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#9539 ';
$expected_re = qr/${expected}${dirs}/;
test_once $args, $expected_re, "PRODUCTDIR is correct when the source job's PRODUCTDIR is a relative directory";

$needles = "/$needles";
$ENV{curl_openqa}
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/distri", "PRODUCTDIR": "products/sle", "NEEDLES_DIR": "$needles"}'; true};
$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle NEEDLES_DIR=$needles";
$ENV{curl_openqa} = qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/distri", "PRODUCTDIR": "products/sle"}'; true};
$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle";
$expected_re = qr/${expected}${dirs}/;
test_once $args, $expected_re, 'Correct PRODUCTDIR for relative non-prefixed dir';

my $casedir = '/openqa/cache/openqa1-opensuse/tests/opensuse';
$ENV{curl_openqa}
= qq{echo -e '{"TEST": "my_test", "CASEDIR": "$casedir", "PRODUCTDIR": "$casedir/products/opensuse"}'; true};
$dirs
= "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/opensuse NEEDLES_DIR=$casedir/products/opensuse/needles";
$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/opensuse";
$expected_re = qr/${expected}${dirs}/;
test_once $args, $expected_re, "PRODUCTDIR is correct when the source job's PRODUCTDIR includes specific word";

Expand Down
Loading