Skip to content

Commit

Permalink
[DEVOPS-985] demo cluster/wallet integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
disassembler committed Aug 2, 2018
1 parent d53d64b commit d2cbe38
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
14 changes: 7 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ let
walletConfigFile = ./custom-wallet-config.nix;
walletConfig = if allowCustomConfig then (if builtins.pathExists walletConfigFile then import walletConfigFile else {}) else {};
in
args: pkgs.callPackage ./scripts/launch/connect-to-cluster (args // { inherit gitrev; } // walletConfig );
args: pkgs.callPackage ./scripts/launch/connect-to-cluster (args // { inherit gitrev useStackBinaries; } // walletConfig );
other = rec {
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev useStackBinaries; };
validateJson = pkgs.callPackage ./tools/src/validate-json {};
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev useStackBinaries; };
demoClusterLaunchGenesis = pkgs.callPackage ./scripts/launch/demo-cluster {
inherit gitrev;
inherit gitrev useStackBinaries;
launchGenesis = true;
configurationKey = "testnet_full";
runWallet = false;
Expand Down Expand Up @@ -157,15 +157,15 @@ let
inherit (pkgs) purescript;
connectScripts = {
mainnet = {
wallet = connect { inherit useStackBinaries;};
wallet = connect { };
explorer = connect { executable = "explorer"; };
};
staging = {
wallet = connect { inherit useStackBinaries; environment = "mainnet-staging"; };
wallet = connect { environment = "mainnet-staging"; };
explorer = connect { executable = "explorer"; environment = "mainnet-staging"; };
};
testnet = {
wallet = connect { inherit useStackBinaries; environment = "testnet"; };
wallet = connect { environment = "testnet"; };
explorer = connect { executable = "explorer"; environment = "testnet"; };
};
demoWallet = connect { environment = "demo"; };
Expand Down
2 changes: 1 addition & 1 deletion scripts/launch/connect-to-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let
};
executables = {
wallet = if useStackBinaries then "stack exec -- cardano-node" else "${iohkPkgs.cardano-sl-wallet-new}/bin/cardano-node";
explorer = "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
explorer = if useStackBinaries then "stack exec -- cardano-explorer" else "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
x509gen = if useStackBinaries then "stack exec -- cardano-x509-certificates" else "${iohkPkgs.cardano-sl-tools}/bin/cardano-x509-certificates";
};
ifWallet = localLib.optionalString (executable == "wallet");
Expand Down
31 changes: 14 additions & 17 deletions scripts/launch/demo-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@
, keepAlive ? true
, launchGenesis ? false
, configurationKey ? "default"
, useStackBinaries ? false
}:

with localLib;

let
executables = {
corenode = "${iohkPkgs.cardano-sl-node-static}/bin/cardano-node-simple";
wallet = "${iohkPkgs.cardano-sl-wallet-new}/bin/cardano-node";
integration-test = "${iohkPkgs.cardano-sl-wallet-new}/bin/wal-integr-test";
keygen = "${iohkPkgs.cardano-sl-tools}/bin/cardano-keygen";
explorer = "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
};
demoClusterDeps = with pkgs; (with iohkPkgs; [ jq coreutils pkgs.curl gnused openssl cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ]);
stackExec = optionalString useStackBinaries "stack exec -- ";
cardanoDeps = with iohkPkgs; [ cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ];
demoClusterDeps = with pkgs; [ jq coreutils curl gnused openssl ];
allDeps = demoClusterDeps ++ (optionals (!useStackBinaries ) cardanoDeps);
walletConfig = {
inherit stateDir;
topologyFile = walletTopologyFile;
Expand All @@ -39,9 +36,9 @@ let
} else {
environment = "demo";
};
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev; debug = false; } // walletEnvironment // walletConfig);
ifWallet = localLib.optionalString (runWallet);
ifKeepAlive = localLib.optionalString (keepAlive);
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev useStackBinaries; debug = false; } // walletEnvironment // walletConfig);
ifWallet = optionalString (runWallet);
ifKeepAlive = optionalString (keepAlive);
iohkPkgs = import ./../../.. { inherit config system pkgs gitrev; };
src = ./../../..;
topologyFile = import ./make-topology.nix { inherit (pkgs) lib; cores = numCoreNodes; relays = numRelayNodes; };
Expand All @@ -52,8 +49,8 @@ let
fallbacks = 1;
};
});
assetLockFile = pkgs.writeText "asset-lock-file" (localLib.intersperse "\n" assetLockAddresses);
ifAssetLock = localLib.optionalString (assetLockAddresses != []);
assetLockFile = pkgs.writeText "asset-lock-file" (intersperse "\n" assetLockAddresses);
ifAssetLock = optionalString (assetLockAddresses != []);
configFiles = pkgs.runCommand "cardano-config" {} ''
mkdir -pv $out
cd $out
Expand All @@ -69,7 +66,7 @@ let

in pkgs.writeScript "demo-cluster" ''
#!${pkgs.stdenv.shell}
export PATH=${pkgs.lib.makeBinPath demoClusterDeps}
export PATH=${pkgs.lib.makeBinPath allDeps}:$PATH
# Set to 0 (passing) by default. Tests using this cluster can set this variable
# to force the `stop_cardano` function to exit with a different code.
EXIT_STATUS=0
Expand Down Expand Up @@ -111,7 +108,7 @@ in pkgs.writeScript "demo-cluster" ''
'' else ''
echo "Creating genesis keys..."
config_files=${configFiles}
cardano-keygen --system-start 0 generate-keys-by-spec --genesis-out-dir ${stateDir}/genesis-keys --configuration-file $config_files/configuration.yaml --configuration-key ${configurationKey}
${stackExec}cardano-keygen --system-start 0 generate-keys-by-spec --genesis-out-dir ${stateDir}/genesis-keys --configuration-file $config_files/configuration.yaml --configuration-key ${configurationKey}
''}
trap "stop_cardano" INT TERM
Expand All @@ -120,15 +117,15 @@ in pkgs.writeScript "demo-cluster" ''
do
node_args="--db-path ${stateDir}/core-db$i --rebuild-db ${if launchGenesis then "--keyfile ${stateDir}/genesis-keys/generated-keys/rich/key$((i - 1)).sk" else "--genesis-secret $i"} --listen 127.0.0.1:$((3000 + i)) --json-log ${stateDir}/logs/core$i.json --logs-prefix ${stateDir}/logs --system-start $system_start --metrics +RTS -N2 -qg -A1m -I0 -T -RTS --node-id core$i --topology ${topologyFile} --configuration-file $config_files/configuration.yaml --configuration-key ${configurationKey} ${ifAssetLock "--asset-lock-file ${assetLockFile}"}"
echo Launching core node $i: cardano-node-simple $node_args
cardano-node-simple $node_args &> ${stateDir}/logs/core$i.log &
${stackExec}cardano-node-simple $node_args &> ${stateDir}/logs/core$i.log &
core_pid[$i]=$!
done
for i in {1..${builtins.toString numRelayNodes}}
do
node_args="--db-path ${stateDir}/relay-db$i --rebuild-db --listen 127.0.0.1:$((3100 + i)) --json-log ${stateDir}/logs/relay$i.json --logs-prefix ${stateDir}/logs --system-start $system_start --metrics +RTS -N2 -qg -A1m -I0 -T -RTS --node-id relay$i --topology ${topologyFile} --configuration-file $config_files/configuration.yaml --configuration-key ${configurationKey}"
echo Launching relay node $i: cardano-node-simple $node_args
cardano-node-simple $node_args &> ${stateDir}/logs/relay$i.log &
${stackExec}cardano-node-simple $node_args &> ${stateDir}/logs/relay$i.log &
relay_pid[$i]=$!
done
Expand Down
13 changes: 10 additions & 3 deletions scripts/test/wallet/integration/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
, gitrev ? "123456" # Dummy git revision to prevent mass rebuilds
, ghcRuntimeArgs ? "-N2 -qg -A1m -I0 -T"
, additionalNodeArgs ? ""
, useStackBinaries ? false
}:

with localLib;

let
stackExec = optionalString useStackBinaries "stack exec -- ";
cardanoDeps = with iohkPkgs; [ cardano-sl-tools ];
integrationTestDeps = with pkgs; [ gnugrep ];
allDeps = integrationTestDeps ++ (optionals (!useStackBinaries ) cardanoDeps);
demo-cluster = iohkPkgs.demoCluster.override {
inherit gitrev numCoreNodes stateDir;
inherit gitrev numCoreNodes stateDir useStackBinaries;
keepAlive = false;
assetLockAddresses = [ "DdzFFzCqrhswMWoTiWaqXUDZJuYUx63qB6Aq8rbVbhFbc8NWqhpZkC7Lhn5eVA7kWf4JwKvJ9PqQF78AewMCzDZLabkzm99rFzpNDKp5" ];
};
Expand All @@ -22,14 +27,16 @@ let
};
iohkPkgs = import ./../../../.. { inherit config system pkgs gitrev; };
in pkgs.writeScript "integration-tests" ''
#!${pkgs.stdenv.shell}
export PATH=${pkgs.lib.makeBinPath allDeps}:$PATH
set -e
source ${demo-cluster}
${executables.integration-test} --tls-ca-cert ${stateDir}/tls/client/ca.crt --tls-client-cert ${stateDir}/tls/client/client.pem --tls-key ${stateDir}/tls/client/client.key
${stackExec}wal-integr-test --tls-ca-cert ${stateDir}/tls/client/ca.crt --tls-client-cert ${stateDir}/tls/client/client.pem --tls-key ${stateDir}/tls/client/client.key
EXIT_STATUS=$?
# Verify we see "transaction list is empty after filtering out asset-locked source addresses" in at least 1 core node log file
if [[ $EXIT_STATUS -eq 0 ]]
then
${pkgs.gnugrep}/bin/grep "transaction list is empty after filtering out asset-locked source addresses" state-demo/logs/core*.json
grep "transaction list is empty after filtering out asset-locked source addresses" state-demo/logs/core*.json
EXIT_STATUS=$?
fi
stop_cardano
Expand Down

0 comments on commit d2cbe38

Please sign in to comment.