forked from lix-project/hydra
Merge pull request #775 from knl/path-input-cache-validity-fix
Make PathInput plugin cache validity configurable
This commit is contained in:
commit
56b1660c4d
|
@ -198,7 +198,14 @@
|
||||||
tests.api.x86_64-linux =
|
tests.api.x86_64-linux =
|
||||||
with import (nixpkgs + "/nixos/lib/testing-python.nix") { system = "x86_64-linux"; };
|
with import (nixpkgs + "/nixos/lib/testing-python.nix") { system = "x86_64-linux"; };
|
||||||
simpleTest {
|
simpleTest {
|
||||||
machine = hydraServer;
|
machine = { pkgs, ... }: {
|
||||||
|
imports = [ hydraServer ];
|
||||||
|
# No caching for PathInput plugin, otherwise we get wrong values
|
||||||
|
# (as it has a 30s window where no changes to the file are considered).
|
||||||
|
services.hydra-dev.extraConfig = ''
|
||||||
|
path_input_cache_validity_seconds = 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
testScript =
|
testScript =
|
||||||
let dbi = "dbi:Pg:dbname=hydra;user=root;"; in
|
let dbi = "dbi:Pg:dbname=hydra;user=root;"; in
|
||||||
''
|
''
|
||||||
|
|
|
@ -22,9 +22,11 @@ sub fetchInput {
|
||||||
my $sha256;
|
my $sha256;
|
||||||
my $storePath;
|
my $storePath;
|
||||||
|
|
||||||
|
my $timeout = $self->{config}->{path_input_cache_validity_seconds} // 30;
|
||||||
|
|
||||||
# Some simple caching: don't check a path more than once every N seconds.
|
# Some simple caching: don't check a path more than once every N seconds.
|
||||||
(my $cachedInput) = $self->{db}->resultset('CachedPathInputs')->search(
|
(my $cachedInput) = $self->{db}->resultset('CachedPathInputs')->search(
|
||||||
{srcpath => $uri, lastseen => {">", $timestamp - 30}},
|
{srcpath => $uri, lastseen => {">", $timestamp - $timeout}},
|
||||||
{rows => 1, order_by => "lastseen DESC"});
|
{rows => 1, order_by => "lastseen DESC"});
|
||||||
|
|
||||||
if (defined $cachedInput && isValidPath($cachedInput->storepath)) {
|
if (defined $cachedInput && isValidPath($cachedInput->storepath)) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Test::Simple tests => 19;
|
use Test::Simple tests => 20;
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new;
|
||||||
$ua->cookie_jar({});
|
$ua->cookie_jar({});
|
||||||
|
@ -59,6 +59,7 @@ ok($eval->{hasnewbuilds} == 1, "The first eval of a jobset has new builds");
|
||||||
|
|
||||||
system("echo >> /run/jobset/default.nix; hydra-eval-jobset sample default");
|
system("echo >> /run/jobset/default.nix; hydra-eval-jobset sample default");
|
||||||
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
|
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
|
||||||
|
ok(scalar(@$evals) == 2, "Changing a jobset source creates the second evaluation");
|
||||||
ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
|
ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
|
||||||
|
|
||||||
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
|
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
|
||||||
|
|
Loading…
Reference in a new issue