Skip to content

Commit

Permalink
Reuse retry from openqa-cli api in openqa-cli schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Mar 16, 2023
1 parent 1f1ce10 commit 2b84f6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/OpenQA/CLI/schedule.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ has post_url => sub { shift->url_for('isos') };

sub _create_jobs ($self, $client, $args, $param_file, $job_ids) {
my $params = $self->parse_params($args, $param_file);
my $tx = $client->start($client->build_tx(POST => $self->post_url, {}, form => $params));
my $res = $self->handle_result($tx, {pretty => 0, quiet => 1, links => 0, verbose => 0});
my $tx = $client->build_tx(POST => $self->post_url, {}, form => $params);
my $res = $self->retry_tx($client, $tx, {pretty => 0, quiet => 1, links => 0, verbose => 0});
return $res if $res != 0;
my $json = $tx->res->json;
push @$job_ids, $json->{id} if defined $json->{id} && ref $json->{id} eq '';
Expand All @@ -28,8 +28,8 @@ sub _create_jobs ($self, $client, $args, $param_file, $job_ids) {
sub _monitor_jobs ($self, $client, $poll_interval, $job_ids, $job_results) {
while (@$job_results < @$job_ids) {
my $job_id = $job_ids->[@$job_results];
my $tx = $client->start($client->build_tx(GET => $self->url_for("experimental/jobs/$job_id/status"), {}));
my $res = $self->handle_result($tx, {pretty => 0, quiet => 1, links => 0, verbose => 0});
my $tx = $client->build_tx(GET => $self->url_for("experimental/jobs/$job_id/status"), {});
my $res = $self->retry_tx($client, $tx, {pretty => 0, quiet => 1, links => 0, verbose => 0});
return $res if $res != 0;
my $job = $tx->res->json;
my $job_state = $job->{state} // NONE;
Expand Down
1 change: 1 addition & 0 deletions t/43-cli-schedule.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use Test::Output qw(combined_like);
use Test::MockModule;

my ($archive, $res) = OpenQA::CLI::schedule->new;
$ENV{OPENQA_CLI_RETRIES} = 0;
OpenQA::Test::Case->new->init_data(fixtures_glob => '03-users.pl');

# change API to simulate job state/result changes
Expand Down

0 comments on commit 2b84f6a

Please sign in to comment.