Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit ebcc213

Browse files
committed
[DEVOPS-985] demo cluster/wallet integration tests
1 parent d53d64b commit ebcc213

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

default.nix

+7-7
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ let
118118
walletConfigFile = ./custom-wallet-config.nix;
119119
walletConfig = if allowCustomConfig then (if builtins.pathExists walletConfigFile then import walletConfigFile else {}) else {};
120120
in
121-
args: pkgs.callPackage ./scripts/launch/connect-to-cluster (args // { inherit gitrev; } // walletConfig );
121+
args: pkgs.callPackage ./scripts/launch/connect-to-cluster (args // { inherit gitrev useStackBinaries; } // walletConfig );
122122
other = rec {
123-
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
123+
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev useStackBinaries; };
124124
validateJson = pkgs.callPackage ./tools/src/validate-json {};
125-
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
125+
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev useStackBinaries; };
126126
demoClusterLaunchGenesis = pkgs.callPackage ./scripts/launch/demo-cluster {
127-
inherit gitrev;
127+
inherit gitrev useStackBinaries;
128128
launchGenesis = true;
129129
configurationKey = "testnet_full";
130130
runWallet = false;
@@ -157,15 +157,15 @@ let
157157
inherit (pkgs) purescript;
158158
connectScripts = {
159159
mainnet = {
160-
wallet = connect { inherit useStackBinaries;};
160+
wallet = connect { };
161161
explorer = connect { executable = "explorer"; };
162162
};
163163
staging = {
164-
wallet = connect { inherit useStackBinaries; environment = "mainnet-staging"; };
164+
wallet = connect { environment = "mainnet-staging"; };
165165
explorer = connect { executable = "explorer"; environment = "mainnet-staging"; };
166166
};
167167
testnet = {
168-
wallet = connect { inherit useStackBinaries; environment = "testnet"; };
168+
wallet = connect { environment = "testnet"; };
169169
explorer = connect { executable = "explorer"; environment = "testnet"; };
170170
};
171171
demoWallet = connect { environment = "demo"; };

scripts/launch/connect-to-cluster/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let
5353
};
5454
executables = {
5555
wallet = if useStackBinaries then "stack exec -- cardano-node" else "${iohkPkgs.cardano-sl-wallet-new}/bin/cardano-node";
56-
explorer = "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
56+
explorer = if useStackBinaries then "stack exec -- cardano-explorer" else "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
5757
x509gen = if useStackBinaries then "stack exec -- cardano-x509-certificates" else "${iohkPkgs.cardano-sl-tools}/bin/cardano-x509-certificates";
5858
};
5959
ifWallet = localLib.optionalString (executable == "wallet");

scripts/launch/demo-cluster/default.nix

+14-17
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,16 @@
1414
, keepAlive ? true
1515
, launchGenesis ? false
1616
, configurationKey ? "default"
17+
, useStackBinaries ? false
1718
}:
1819

1920
with localLib;
2021

2122
let
22-
executables = {
23-
corenode = "${iohkPkgs.cardano-sl-node-static}/bin/cardano-node-simple";
24-
wallet = "${iohkPkgs.cardano-sl-wallet-new}/bin/cardano-node";
25-
integration-test = "${iohkPkgs.cardano-sl-wallet-new}/bin/wal-integr-test";
26-
keygen = "${iohkPkgs.cardano-sl-tools}/bin/cardano-keygen";
27-
explorer = "${iohkPkgs.cardano-sl-explorer-static}/bin/cardano-explorer";
28-
};
29-
demoClusterDeps = with pkgs; (with iohkPkgs; [ jq coreutils pkgs.curl gnused openssl cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ]);
23+
stackExec = optionalString useStackBinaries "stack exec -- ";
24+
cardanoDeps = with iohkPkgs; [ cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ];
25+
demoClusterDeps = with pkgs; [ jq coreutils curl gnused openssl ];
26+
allDeps = demoClusterDeps ++ (optionals (!useStackBinaries ) cardanoDeps);
3027
walletConfig = {
3128
inherit stateDir;
3229
topologyFile = walletTopologyFile;
@@ -39,9 +36,9 @@ let
3936
} else {
4037
environment = "demo";
4138
};
42-
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev; debug = false; } // walletEnvironment // walletConfig);
43-
ifWallet = localLib.optionalString (runWallet);
44-
ifKeepAlive = localLib.optionalString (keepAlive);
39+
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev useStackBinaries; debug = false; } // walletEnvironment // walletConfig);
40+
ifWallet = optionalString (runWallet);
41+
ifKeepAlive = optionalString (keepAlive);
4542
iohkPkgs = import ./../../.. { inherit config system pkgs gitrev; };
4643
src = ./../../..;
4744
topologyFile = import ./make-topology.nix { inherit (pkgs) lib; cores = numCoreNodes; relays = numRelayNodes; };
@@ -52,8 +49,8 @@ let
5249
fallbacks = 1;
5350
};
5451
});
55-
assetLockFile = pkgs.writeText "asset-lock-file" (localLib.intersperse "\n" assetLockAddresses);
56-
ifAssetLock = localLib.optionalString (assetLockAddresses != []);
52+
assetLockFile = pkgs.writeText "asset-lock-file" (intersperse "\n" assetLockAddresses);
53+
ifAssetLock = optionalString (assetLockAddresses != []);
5754
configFiles = pkgs.runCommand "cardano-config" {} ''
5855
mkdir -pv $out
5956
cd $out
@@ -69,7 +66,7 @@ let
6966

7067
in pkgs.writeScript "demo-cluster" ''
7168
#!${pkgs.stdenv.shell}
72-
export PATH=${pkgs.lib.makeBinPath demoClusterDeps}
69+
export PATH=${pkgs.lib.makeBinPath allDeps}:$PATH
7370
# Set to 0 (passing) by default. Tests using this cluster can set this variable
7471
# to force the `stop_cardano` function to exit with a different code.
7572
EXIT_STATUS=0
@@ -111,7 +108,7 @@ in pkgs.writeScript "demo-cluster" ''
111108
'' else ''
112109
echo "Creating genesis keys..."
113110
config_files=${configFiles}
114-
cardano-keygen --system-start 0 generate-keys-by-spec --genesis-out-dir ${stateDir}/genesis-keys --configuration-file $config_files/configuration.yaml --configuration-key ${configurationKey}
111+
${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}
115112
''}
116113
117114
trap "stop_cardano" INT TERM
@@ -120,15 +117,15 @@ in pkgs.writeScript "demo-cluster" ''
120117
do
121118
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}"}"
122119
echo Launching core node $i: cardano-node-simple $node_args
123-
cardano-node-simple $node_args &> ${stateDir}/logs/core$i.log &
120+
${stackExec}cardano-node-simple $node_args &> ${stateDir}/logs/core$i.log &
124121
core_pid[$i]=$!
125122
126123
done
127124
for i in {1..${builtins.toString numRelayNodes}}
128125
do
129126
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}"
130127
echo Launching relay node $i: cardano-node-simple $node_args
131-
cardano-node-simple $node_args &> ${stateDir}/logs/relay$i.log &
128+
${stackExec}cardano-node-simple $node_args &> ${stateDir}/logs/relay$i.log &
132129
relay_pid[$i]=$!
133130
134131
done

scripts/test/wallet/integration/default.nix

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
, gitrev ? "123456" # Dummy git revision to prevent mass rebuilds
88
, ghcRuntimeArgs ? "-N2 -qg -A1m -I0 -T"
99
, additionalNodeArgs ? ""
10+
, useStackBinaries ? false
1011
}:
1112

1213
with localLib;
1314

1415
let
16+
stackExec = optionalString useStackBinaries "stack exec -- ";
17+
cardanoDeps = with iohkPkgs; [ cardano-sl-tools ];
18+
integrationTestDeps = with pkgs; [ gnugrep ];
19+
allDeps = integrationTestDeps ++ (optionals (!useStackBinaries ) cardanoDeps);
1520
demo-cluster = iohkPkgs.demoCluster.override {
16-
inherit gitrev numCoreNodes stateDir;
21+
inherit gitrev numCoreNodes stateDir useStackBinaries;
1722
keepAlive = false;
1823
assetLockAddresses = [ "DdzFFzCqrhswMWoTiWaqXUDZJuYUx63qB6Aq8rbVbhFbc8NWqhpZkC7Lhn5eVA7kWf4JwKvJ9PqQF78AewMCzDZLabkzm99rFzpNDKp5" ];
1924
};
@@ -22,14 +27,16 @@ let
2227
};
2328
iohkPkgs = import ./../../../.. { inherit config system pkgs gitrev; };
2429
in pkgs.writeScript "integration-tests" ''
30+
#!${pkgs.stdenv.shell}
31+
export PATH=${pkgs.lib.makeBinPath allDeps}:$PATH
2532
set -e
2633
source ${demo-cluster}
27-
${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
34+
${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
2835
EXIT_STATUS=$?
2936
# Verify we see "transaction list is empty after filtering out asset-locked source addresses" in at least 1 core node log file
3037
if [[ $EXIT_STATUS -eq 0 ]]
3138
then
32-
${pkgs.gnugrep}/bin/grep "transaction list is empty after filtering out asset-locked source addresses" state-demo/logs/core*.json
39+
grep "transaction list is empty after filtering out asset-locked source addresses" state-demo/logs/core*.json
3340
EXIT_STATUS=$?
3441
fi
3542
stop_cardano

0 commit comments

Comments
 (0)