Test setup: support arbitrary hydra config

[?]
Feb 23, 2021, 9:08 PM
4WLW4VHSOVVFNMPW3S7XVIC3MH7BSUN3FQ37LXGOJ4ODMPVGLO6AC

Dependencies

  • [2] UIA3ULNU Give each test its own Nix directories
  • [3] OWRS526H Create an ephemeral PostgreSQL database per test
  • [4] HX4QYOYA add first evaluations tests

Change contents

  • replacement in tests/lib/Setup.pm at line 13
    [2.1503][2.1503:1521]()
    sub test_init() {
    [2.1503]
    [2.1521]
    # Set up the environment for running tests.
    #
    # Hash Parameters:
    #
    # * hydra_config: configuration for the Hydra processes for your test.
    #
    # This clears several environment variables and sets them to ephemeral
    # values: a temporary database, temporary Nix store, temporary Hydra
    # data directory, etc.
    #
    # Note: This function must run _very_ early, before nearly any Hydra
    # libraries are loaded. To use this, you very likely need to `use Setup`
    # and then run `test_init`, and then `require` the Hydra libraries you
    # need.
    #
    # It returns a tuple: a handle to a temporary directory and a handle to
    # the postgres service. If either of these variables go out of scope,
    # those resources are released and the test environment becomes invalid.
    #
    # Look at the top of an existing `.t` file to see how this should be used
    # in practice.
    sub test_init {
    my %opts = @_;
  • edit in tests/lib/Setup.pm at line 47
    [2.1893]
    [2.1893]
    $ENV{'HYDRA_CONFIG'} = "$dir/hydra.conf";
  • edit in tests/lib/Setup.pm at line 50
    [2.1894]
    [2.1894]
    open(my $fh, '>', $ENV{'HYDRA_CONFIG'}) or die "Could not open file '" . $ENV{'HYDRA_CONFIG'}. " $!";
    print $fh $opts{'hydra_config'} || "";
    close $fh;