at 18.09-beta 2.4 kB view raw
1import ../make-test.nix ({ pkgs, ...} : 2 3let 4 trivialJob = pkgs.writeTextDir "trivial.nix" '' 5 { trivial = builtins.derivation { 6 name = "trivial"; 7 system = "x86_64-linux"; 8 builder = "/bin/sh"; 9 args = ["-c" "echo success > $out; exit 0"]; 10 }; 11 } 12 ''; 13 14 createTrivialProject = pkgs.stdenv.mkDerivation { 15 name = "create-trivial-project"; 16 unpackPhase = ":"; 17 buildInputs = [ pkgs.makeWrapper ]; 18 installPhase = "install -m755 -D ${./create-trivial-project.sh} $out/bin/create-trivial-project.sh"; 19 postFixup = '' 20 wrapProgram "$out/bin/create-trivial-project.sh" --prefix PATH ":" ${pkgs.stdenv.lib.makeBinPath [ pkgs.curl ]} --set EXPR_PATH ${trivialJob} 21 ''; 22 }; 23 24in { 25 name = "hydra-init-localdb"; 26 meta = with pkgs.stdenv.lib.maintainers; { 27 maintainers = [ pstn lewo ma27 ]; 28 }; 29 30 machine = 31 { pkgs, ... }: 32 33 { 34 virtualisation.memorySize = 1024; 35 time.timeZone = "UTC"; 36 37 environment.systemPackages = [ createTrivialProject pkgs.jq ]; 38 services.hydra = { 39 enable = true; 40 41 #Hydra needs those settings to start up, so we add something not harmfull. 42 hydraURL = "example.com"; 43 notificationSender = "example@example.com"; 44 }; 45 nix = { 46 buildMachines = [{ 47 hostName = "localhost"; 48 systems = [ "x86_64-linux" ]; 49 }]; 50 51 binaryCaches = []; 52 }; 53 }; 54 55 testScript = 56 '' 57 # let the system boot up 58 $machine->waitForUnit("multi-user.target"); 59 # test whether the database is running 60 $machine->succeed("systemctl status postgresql.service"); 61 # test whether the actual hydra daemons are running 62 $machine->succeed("systemctl status hydra-queue-runner.service"); 63 $machine->succeed("systemctl status hydra-init.service"); 64 $machine->succeed("systemctl status hydra-evaluator.service"); 65 $machine->succeed("systemctl status hydra-send-stats.service"); 66 67 $machine->succeed("hydra-create-user admin --role admin --password admin"); 68 69 # create a project with a trivial job 70 $machine->waitForOpenPort(3000); 71 72 # make sure the build as been successfully built 73 $machine->succeed("create-trivial-project.sh"); 74 75 $machine->waitUntilSucceeds('curl -L -s http://localhost:3000/build/1 -H "Accept: application/json" | jq .buildstatus | xargs test 0 -eq'); 76 ''; 77})