Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set asset size on job creation
Browse files Browse the repository at this point in the history
Assets without a size are treated like they don't exist. With POST isos,
referenced assets don't directly get a size and are thus not shown as
downloadable. Only the next limit_assets task run changes this by running
refresh_assets. Improve this by setting the size for assets on job creation.
Vogtinator committed Nov 22, 2023
1 parent 34068e3 commit fb6a34f
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/OpenQA/Schema/Result/ScheduledProducts.pm
Original file line number Diff line number Diff line change
@@ -255,7 +255,8 @@ sub _schedule_iso {
for my $asset (values %{parse_assets_from_settings($args)}) {
my ($name, $type) = ($asset->{name}, $asset->{type});
return {error => 'Asset type and name must not be empty.'} unless $name && $type;
return {error => "Failed to register asset $name."} unless $assets->register($type, $name, {missing_ok => 1});
return {error => "Failed to register asset $name."}
unless $assets->register($type, $name, {missing_ok => 1, refresh_size => 1});
}

# read arguments for deprioritization and obsoleten
11 changes: 11 additions & 0 deletions t/39-scheduled_products-table.t
Original file line number Diff line number Diff line change
@@ -71,6 +71,17 @@ subtest 'handling assets with invalid name' => sub {

is $scheduled_product->schedule_iso(\%settings), undef, 'scheduling the same product again prevented';

subtest 'asset registration on scheduling' => sub {
$schema->storage->dbh->prepare('delete from assets where name = ? ')->execute('dvdsize42.iso');
is $schema->resultset('Assets')->find({type => 'iso', name => 'dvdsize42.iso'}), undef,
'dvdsize42.iso is not known yet';
$scheduled_product = $scheduled_products->create(\%settings);
$scheduled_product->schedule_iso({ISO => 'dvdsize42.iso'});
is $schema->resultset('Assets')->find({type => 'iso', name => 'dvdsize42.iso'})->size, 42,
'dvdsize42.iso has known size';
$scheduled_product->discard_changes;
};

my $test_job = $scheduled_product->jobs->create({TEST => 'testjob'});
subtest 'cancellation after product has been scheduled' => sub {
is $scheduled_product->cancel('test reason 1'), 1, 'cancel returns the number of affected jobs';

0 comments on commit fb6a34f

Please sign in to comment.