Skip to content

Commit

Permalink
Merge pull request #107 from Martchus/latest-job-from-build
Browse files Browse the repository at this point in the history
Find job to clone from o3 in a more reliable way
  • Loading branch information
Martchus authored Feb 9, 2023
2 parents dc8b61d + 4a62f27 commit 04465c2
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/osautoinst/start_test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ use testapi;
use utils;

sub run {
# please forgive the hackiness: using the openQA API but parsing the
# human-readable output of 'client' to get the most recent job
# clone the latest "minimalx" job for the most recent Tumbleweed build with matching architecture
my $arch = get_var('ARCH');
my $ttest = 'minimalx';
my $openqa_url = get_var('OPENQA_HOST', 'https://openqa.opensuse.org');
my $cmd = <<"EOF";
set -o pipefail
last_tw_build=\$(OPENQA_CLI_RETRIES=5 openqa-cli api --host $openqa_url assets | jq '.assets | .[] | .name' | sed -n 's/.*Tumbleweed-NET-$arch-Snapshot\\([0-9]\\+\\)-Media.*\$/\\1/p' | sort -n | tail -n 1)
echo "Last Tumbleweed build on openqa.opensuse.org: \$last_tw_build"
[ ! -z \$last_tw_build ]
zypper -n in jq
resp=\$(OPENQA_CLI_RETRIES=5 openqa-cli api --host $openqa_url jobs version=Tumbleweed scope=relevant arch=$arch build=\$last_tw_build flavor=NET latest=1)
job_id=\$(echo "\$resp" | jq '.jobs | .[] | select(.test == "$ttest") | .id')
echo "Job Id: \$job_id"
if [ -z \$job_id ]; then echo "Response: \$resp" && false; fi
resp=\$(OPENQA_CLI_RETRIES=5 openqa-cli api --host $openqa_url jobs version=Tumbleweed scope=relevant arch='$arch' flavor=NET test='$ttest' latest=1)
job_id=\$(echo "\$resp" | jq -r '.jobs | max_by(.settings.BUILD) .id')
echo "Job ID: \$job_id"
if [ -z \$job_id ]; then echo "Unable to find a suitable job to clone from o3. The API query returned: \$resp" && false; fi
echo "Scenario: $arch-$ttest-NET: \$job_id"
EOF
assert_script_run($_) foreach (split /\n/, $cmd);
Expand Down

0 comments on commit 04465c2

Please sign in to comment.