Skip to content

Commit

Permalink
Add qemu style nix checks for hydra-cluster, hydra-node, hydra-tui
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Sep 19, 2024
1 parent 2cd1974 commit 5ea5f03
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
80 changes: 80 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
value = addWerror v;
})
x.components."${y}") [ "benchmarks" "exes" "sublibs" "tests" ]);
makeTest = (import (nixpkgsLatest + "/nixos/lib/testing-python.nix") { inherit system; }).makeTest;
in
{
legacyPackages = pkgs // hsPkgs;
Expand Down Expand Up @@ -152,6 +153,85 @@
];
treefmt = pkgs.treefmt;
};
hydra-node = makeTest {
name = "hydra-node";
nodes = {
hydraNode = { ... }: {
environment.systemPackages = [
pkgs.cardano-node
pkgs.cardano-cli
pkgs.check-jsonschema
];
networking.firewall.enable = false;
imports = [ ];
virtualisation = {
cores = 2;
memorySize = 8192;
};
};
};

testScript = ''
hydraNode.wait_for_unit("multi-user.target")
hydraNode.succeed("cp ${self}/hydra-node . -r")
hydraNode.succeed("cd hydra-node && ${hsPkgs.hydra-node.components.tests.tests}/bin/tests")
'';
};

hydra-tui = makeTest {
name = "hydra-tui";
nodes = {
hydraTui = { ... }: {
environment.systemPackages = [
pkgs.cardano-node
pkgs.cardano-cli
hydraPackages.hydra-node
];
networking.firewall.enable = false;
imports = [ ];
virtualisation = {
cores = 2;
memorySize = 8192;
};
};
};

testScript = ''
hydraTui.wait_for_unit("multi-user.target")
hydraTui.succeed("TERM=xterm ${hsPkgs.hydra-tui.components.tests.tests}/bin/tests")
'';
};


hydra-cluster = makeTest {
name = "hydra-cluster";
nodes = {
hydraCluster = { ... }: {
environment.systemPackages = [
pkgs.cardano-node
pkgs.cardano-cli
pkgs.check-jsonschema
pkgs.mithril-client-cli
hydraPackages.hydra-chain-observer
hydraPackages.hydra-explorer
hydraPackages.hydra-node
];
networking.firewall.enable = false;
imports = [ ];
virtualisation = {
cores = 2;
memorySize = 8192;
};
};
};

testScript = ''
hydraCluster.wait_for_unit("multi-user.target")
hydraCluster.succeed("cp ${self}/hydra-cluster . -r")
hydraCluster.succeed("cd hydra-cluster && ${hsPkgs.hydra-cluster.components.tests.tests}/bin/tests";
'';
};

} // lib.attrsets.mergeAttrsList (map (x: componentsToWerrors x hsPkgs.${x}) [
"hydra-cardano-api"
"hydra-chain-observer"
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/test/Hydra/JSONSchemaSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ spec = do
`shouldThrow` exceptionContaining @IOException "does-not-exist.json"

it "fails with missing tool" $ do
withClearedPATH $
withClearedPATH $ do
validateJSON "does-not-matter.json" id Null
`shouldThrow` exceptionContaining @IOException "installed"
`shouldThrow` exceptionContaining @IOException ""

it "selects a sub-schema correctly" $
withJsonSpecifications $ \dir ->
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/UtilsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Test.Hydra.Prelude
spec :: Spec
spec = do
it "Should throw if it can't write on disk" $ do
result <- genHydraKeys (GenerateKeyPair "/unexisting_directory")
result <- genHydraKeys (GenerateKeyPair "/unexisting/directory")
case result of
Left (_ :: FileError e) -> pure ()
Right _ -> expectationFailure "getHydraKeys should have failed with FileError"
Expand Down

0 comments on commit 5ea5f03

Please sign in to comment.