forked from lix-project/hydra
Merge pull request #1163 from DeterminateSystems/constituents
Constituents: Add a GC root for indirect aggregates
This commit is contained in:
commit
a2546121f0
|
@ -504,6 +504,17 @@ int main(int argc, char * * argv)
|
|||
|
||||
job.erase("namedConstituents");
|
||||
|
||||
/* Register the derivation as a GC root. !!! This
|
||||
registers roots for jobs that we may have already
|
||||
done. */
|
||||
auto localStore = store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (gcRootsDir != "" && localStore) {
|
||||
auto drvPath = job["drvPath"].get<std::string>();
|
||||
Path root = gcRootsDir + "/" + std::string(baseNameOf(drvPath));
|
||||
if (!pathExists(root))
|
||||
localStore->addPermRoot(localStore->parseStorePath(drvPath), root);
|
||||
}
|
||||
|
||||
if (!brokenJobs.empty()) {
|
||||
std::stringstream ss;
|
||||
for (const auto& [jobName, error] : brokenJobs) {
|
||||
|
|
20
t/evaluator/evaluate-constituents-gc.t
Normal file
20
t/evaluator/evaluate-constituents-gc.t
Normal file
|
@ -0,0 +1,20 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
use Test2::V0;
|
||||
|
||||
my $ctx = test_context();
|
||||
|
||||
my $builds = $ctx->makeAndEvaluateJobset(
|
||||
expression => 'constituents.nix',
|
||||
);
|
||||
|
||||
my $constituentA = $builds->{"constituentA"};
|
||||
my $directAggregate = $builds->{"direct_aggregate"};
|
||||
my $indirectAggregate = $builds->{"indirect_aggregate"};
|
||||
|
||||
is(system('nix-store', '--delete', $constituentA->drvpath), 256, "Deleting a constituent derivation fails");
|
||||
is(system('nix-store', '--delete', $directAggregate->drvpath), 256, "Deleting the direct aggregate derivation fails");
|
||||
is(system('nix-store', '--delete', $indirectAggregate->drvpath), 256, "Deleting the indirect aggregate derivation fails");
|
||||
|
||||
done_testing;
|
40
t/jobs/constituents.nix
Normal file
40
t/jobs/constituents.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
with import ./config.nix;
|
||||
rec {
|
||||
constituentA = mkDerivation {
|
||||
name = "empty-dir-A";
|
||||
builder = ./empty-dir-builder.sh;
|
||||
};
|
||||
|
||||
constituentB = mkDerivation {
|
||||
name = "empty-dir-B";
|
||||
builder = ./empty-dir-builder.sh;
|
||||
};
|
||||
|
||||
direct_aggregate = mkDerivation {
|
||||
name = "direct_aggregate";
|
||||
_hydraAggregate = true;
|
||||
constituents = [
|
||||
constituentA
|
||||
];
|
||||
builder = ./empty-dir-builder.sh;
|
||||
};
|
||||
|
||||
indirect_aggregate = mkDerivation {
|
||||
name = "indirect_aggregate";
|
||||
_hydraAggregate = true;
|
||||
constituents = [
|
||||
"constituentA"
|
||||
];
|
||||
builder = ./empty-dir-builder.sh;
|
||||
};
|
||||
|
||||
mixed_aggregate = mkDerivation {
|
||||
name = "mixed_aggregate";
|
||||
_hydraAggregate = true;
|
||||
constituents = [
|
||||
"constituentA"
|
||||
constituentB
|
||||
];
|
||||
builder = ./empty-dir-builder.sh;
|
||||
};
|
||||
}
|
35
t/queue-runner/direct-indirect-constituents.t
Normal file
35
t/queue-runner/direct-indirect-constituents.t
Normal file
|
@ -0,0 +1,35 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
use Test2::V0;
|
||||
|
||||
my $ctx = test_context();
|
||||
|
||||
my $builds = $ctx->makeAndEvaluateJobset(
|
||||
expression => 'constituents.nix',
|
||||
);
|
||||
|
||||
my $constituentBuildA = $builds->{"constituentA"};
|
||||
my $constituentBuildB = $builds->{"constituentB"};
|
||||
|
||||
my $eval = $constituentBuildA->jobsetevals->first();
|
||||
is($eval->evaluationerror->errormsg, "");
|
||||
|
||||
subtest "Verifying the direct aggregate" => sub {
|
||||
my $aggBuild = $builds->{"direct_aggregate"};
|
||||
is($aggBuild->constituents->first()->id, $constituentBuildA->id, "The ID of the constituent is correct");
|
||||
};
|
||||
|
||||
subtest "Verifying the indirect aggregate" => sub {
|
||||
my $indirectBuild = $builds->{"indirect_aggregate"};
|
||||
is($indirectBuild->constituents->first()->id, $constituentBuildA->id, "The ID of the constituent is correct");
|
||||
};
|
||||
|
||||
subtest "Verifying a mix of direct and indirect aggregate references" => sub {
|
||||
my $mixedBuild = $builds->{"mixed_aggregate"};
|
||||
my ($constituentA, $constituentB) = $mixedBuild->constituents()->search({}, {order_by => { -asc => "job"} });
|
||||
is($constituentA->id, $constituentBuildA->id, "The ID of the constituent is correct");
|
||||
is($constituentB->id, $constituentBuildB->id, "The ID of the constituent is correct");
|
||||
};
|
||||
|
||||
done_testing;
|
Loading…
Reference in a new issue