Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge #114
Browse files Browse the repository at this point in the history
114: nixos: fix potentialy conflicting option, add testing-mode. r=jbgi a=jbgi

 and enable back nixos test.

Co-authored-by: Jean-Baptiste Giraudeau <jb@giraudeau.info>
  • Loading branch information
iohk-bors[bot] and jbgi authored Dec 10, 2020
2 parents 142c6ab + ed496a8 commit 5f85ce4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
33 changes: 22 additions & 11 deletions nix/nixos/smash-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,39 @@

let
cfg = config.services.smash;
self = config.internal.smashPackages;
inherit (cfg.smashPkgs) smashHaskellPackages smashTestingHaskellPackages iohkNix;
smashConfig = cfg.explorerConfig // {
inherit (cfg.nodeConfig) ByronGenesisFile ShelleyGenesisFile ByronGenesisHash ShelleyGenesisHash Protocol RequiresNetworkMagic;
};
configFile = __toFile "config.json" (__toJSON (smashConfig // cfg.logConfig));
in {

options = {
internal = lib.mkOption {
type = lib.types.attrs;
internal = true;
default = { smashPackages = import ../. {}; };
};
services.smash = {
enable = lib.mkEnableOption "enable the smash server";
script = lib.mkOption {
internal = true;
type = lib.types.package;
};
smashPkgs = lib.mkOption {
type = lib.types.attrs;
default = import ../. {};
defaultText = "smash pkgs";
description = ''
The smash packages and library that should be used.
'';
internal = true;
};
testing-mode = lib.mkOption {
type = lib.types.bool;
default = false;
description = "enable testing APIs";
};
package = lib.mkOption {
type = lib.types.package;
default = pkgs.smashHaskellPackages.smash.components.exes.smash-exe or (import ../. {}).smashHaskellPackages.smash.components.exes.smash-exe;
default = if cfg.testing-mode
then smashTestingHaskellPackages.smash.components.exes.smash-exe
else smashHaskellPackages.smash.components.exes.smash-exe;
};
explorerConfig = lib.mkOption {
type = lib.types.attrs;
Expand All @@ -35,11 +46,11 @@ in {
};
environment = lib.mkOption {
type = lib.types.nullOr lib.types.attrs;
default = self.iohkNix.cardanoLib.environments.${cfg.environmentName};
default = iohkNix.cardanoLib.environments.${cfg.environmentName};
};
logConfig = lib.mkOption {
type = lib.types.attrs;
default = self.iohkNix.cardanoLib.defaultExplorerLogConfig;
default = iohkNix.cardanoLib.defaultExplorerLogConfig;
};
environmentName = lib.mkOption {
type = lib.types.str;
Expand Down Expand Up @@ -107,7 +118,7 @@ in {
export SMASHPGPASSFILE=/$RUNTIME_DIRECTORY/pgpass
''}
${cfg.package}/bin/smash-exe run-migrations --mdir ${../../schema}
${cfg.package}/bin/smash-exe run-migrations --config ${configFile} --mdir ${../../schema}
exec ${cfg.package}/bin/smash-exe run-app-with-db-sync \
--config ${configFile} \
--socket-path "$CARDANO_NODE_SOCKET_PATH" \
Expand All @@ -117,7 +128,7 @@ in {
systemd.services.smash = {
path = [ cfg.package pkgs.netcat pkgs.postgresql ];
preStart = ''
for x in {1..10}; do
for x in {1..30}; do
nc -z localhost ${toString config.services.smash.postgres.port} && break
echo loop $x: waiting for postgresql 2 sec...
sleep 2
Expand Down
2 changes: 1 addition & 1 deletion nix/nixos/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with pkgs.commonLib;
forAllSystems = genAttrs supportedSystems;
importTest = fn: args: system: let
imported = import fn;
test = import (pkgs.path + "/nixos/tests/make-test.nix") imported;
test = import (pkgs.path + "/nixos/tests/make-test-python.nix") imported;
in test ({
inherit pkgs system config;
} // args);
Expand Down
23 changes: 18 additions & 5 deletions nix/nixos/tests/smash-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ with pkgs; with commonLib;
];
services.smash = {
enable = true;
environmentName = "shelley_testnet";
environmentName = "mainnet";
smashPkgs = pkgs;
inherit (config.services.cardano-node) socketPath;
};
systemd.services.smash.serviceConfig = {
# Put cardano-db-sync in "cardano-node" group so that it can write socket file:
SupplementaryGroups = "cardano-node";
};
services.cardano-node = {
enable = true;
environment = "shelley_testnet";
environment = "mainnet";
package = smashHaskellPackages.cardano-node.components.exes.cardano-node;
topology = cardanoLib.mkEdgeTopology {
port = 3001;
edgeNodes = [ "127.0.0.1" ];
};
};
systemd.services.cardano-node.serviceConfig.Restart = lib.mkForce "no";
services.postgresql = {
enable = true;
package = postgresql_12;
Expand All @@ -50,9 +60,12 @@ with pkgs; with commonLib;
};
};
testScript = ''
startAll
$machine->waitForUnit("postgresql.service");
$machine->waitForUnit("cardano-node.service");
start_all()
machine.wait_for_unit("postgresql.service")
machine.wait_for_unit("cardano-node.service")
machine.wait_for_open_port(3001)
machine.wait_for_unit("smash.service")
machine.wait_for_open_port(3100)
'';

}
8 changes: 4 additions & 4 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"cardano-node": {
"branch": "tags/1.14.2",
"branch": "refs/tags/1.24.2",
"description": "The core component that is used to participate in a Cardano decentralised blockchain.",
"homepage": "https://cardano.org",
"owner": "input-output-hk",
"repo": "cardano-node",
"rev": "924a6f7d8c2bdb1bf525be8b0d5626e440697b01",
"sha256": "0bi1vwmb1w6wc2szpr8v1nbsci9y36lnjr4v5pli1wvll1hhpw3c",
"rev": "400d18092ce604352cf36fe5f105b0d7c78be074",
"sha256": "19r4mamm9bxc1hz32qgsrfnrfxwp4pgnb4d28fzai3izznil03vi",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-node/archive/924a6f7d8c2bdb1bf525be8b0d5626e440697b01.tar.gz",
"url": "https://github.com/input-output-hk/cardano-node/archive/400d18092ce604352cf36fe5f105b0d7c78be074.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"haskell.nix": {
Expand Down
5 changes: 4 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ let
(packagePlatforms project);
in (mapTestOn (__trace (__toJSON filteredBuilds) filteredBuilds));
# only build nixos tests on first supported system (linux)
inherit (pkgsFor (builtins.head supportedSystems)) nixosTests;
} // (mkRequiredJob (concatLists [
(collectJobs jobs.native.checks)
(collectJobs jobs.native.libs)
(collectJobs jobs.native.exes)
[ jobs.native.cardano-node.x86_64-linux ]
[ jobs.nixosTests.smashTest.x86_64-linux
jobs.native.cardano-node.x86_64-linux
]
]));

in jobs

0 comments on commit 5f85ce4

Please sign in to comment.