Skip to content

Commit

Permalink
use test-config for hydra-node
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Sep 17, 2024
1 parent 50fe2ac commit c0c0a25
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci-nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ jobs:
- name: ❓ Test
if: ${{ matrix.package != 'hydra-tui'
&& matrix.package != 'hydra-cluster'
&& matrix.package != 'hydra-node'
}}
run: |
cd ${{ matrix.package }}
nix build .#${{ matrix.package }}-tests
nix develop .#${{ matrix.package }}-tests --command tests
- name: ❓ Test
if: ${{ matrix.package == 'hydra-cluster' }}
if: ${{ matrix.package == 'hydra-cluster'
|| matrix.package == 'hydra-node' }}
run: |
nix build --option sandbox false .#checks.x86_64-linux.${{ matrix.package }}
nix build --option sandbox false .#checks.x86_64-linux.${{ matrix.package }} -L
- name: ❓ Test (TUI)
id: test_tui
Expand Down
28 changes: 28 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,34 @@
];
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 = 16;
memorySize = 16384;
};
};
};

testScript = ''
hydraNode.wait_for_unit("multi-user.target")
hydraNode.succeed("cp ${self}/hydra-node/golden . -r")
hydraNode.succeed("cp ${self}/hydra-node/json-schemas . -r")
hydraNode.succeed("mkdir -p test")
hydraNode.succeed("cp ${self}/hydra-node/test/tls test/ -r")
hydraNode.succeed("${hsPkgs.hydra-node.components.exes.test-exe}/bin/test-exe")
'';
};

hydra-cluster = makeTest {
name = "hydra-cluster";
nodes = {
Expand Down
2 changes: 0 additions & 2 deletions hydra-cluster/hydra-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ executable hydra-cluster
common test-config
import: project-config
hs-source-dirs: test
main-is: Main.hs
type: exitcode-stdio-1.0
other-modules:
Paths_hydra_cluster
Spec
Expand Down
12 changes: 11 additions & 1 deletion hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ benchmark micro

ghc-options: -threaded -rtsopts

test-suite tests
common test-config
import: project-config
ghc-options: -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs: test
Expand Down Expand Up @@ -369,3 +369,13 @@ test-suite tests

build-tool-depends: hspec-discover:hspec-discover
ghc-options: -threaded -rtsopts

test-suite tests
import: test-config
type: exitcode-stdio-1.0
main-is: Main.hs

executable test-exe
import: test-config
main-is: Main.hs
type: exitcode-stdio-1.0
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 c0c0a25

Please sign in to comment.