Skip to content

Commit d5789b5

Browse files
authored
Merge pull request #105 from Unbox-infinity/szg251/testing-with-process-compose
Test with process-compose
2 parents 527d7df + 16522c7 commit d5789b5

File tree

5 files changed

+19232
-7677
lines changed

5 files changed

+19232
-7677
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
use flake .#dev-tx-bakery-tests-rust
1+
use flake .#dev-tx-bakery-testsuite-rust

extras/tx-bakery-testsuite/tests/build.nix

+48-23
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
}:
1111

1212
let
13+
data = [
14+
{
15+
name = "tx-bakery-test-scripts-config.json";
16+
path = config.packages.tx-bakery-test-scripts-config;
17+
}
18+
];
19+
dataDir = "data";
1320
rustFlake = inputs.flake-lang.lib."${system}".rustFlake {
21+
inherit data;
1422
src = ./.;
15-
crateName = "tx-bakery-tests";
16-
cargoNextestExtraArgs = "--no-capture";
23+
crateName = "tx-bakery-testsuite";
24+
exportTests = true;
1725

1826
extraSources = [
1927
config.packages.tx-bakery-rust-src
@@ -28,60 +36,77 @@
2836
config.packages.lbf-tx-bakery-tests-plutus-api-rust
2937
];
3038

31-
data = [
32-
{
33-
name = "tx-bakery-test-scripts-config.json";
34-
path = config.packages.tx-bakery-test-scripts-config;
35-
}
36-
];
37-
3839
devShellTools = [
39-
self'.packages.tx-bakery-tests
40+
self'.packages.pc-tx-bakery-tests
4041
];
4142

4243
devShellHook =
4344
config.settings.shell.hook
4445
+ ''
4546
echo "TxBakery testsuite"
4647
echo ""
47-
echo "Run tx-bakery-tests to execute the testsuite."
48-
echo "or tx-bakery-tests up ogmios cardano_devnet -t=true to spin up an environment"
48+
echo "Run pc-tx-bakery-tests to execute the testsuite."
49+
echo "or pc-tx-bakery-tests up ogmios cardano_devnet -t=true to spin up an environment"
4950
echo ""
5051
'';
5152
};
5253
in
5354
{
5455
inherit (rustFlake) packages devShells;
5556

56-
checks = {
57-
"tx-bakery-testsuite" = self'.packages.tx-bakery-tests;
58-
};
57+
checks =
58+
let
59+
data-drv = pkgs.linkFarm "data" data;
60+
in
61+
{
62+
"tx-bakery-testsuite" = pkgs.stdenv.mkDerivation {
63+
name = "tx-bakery-testsuite-check";
64+
phases = [
65+
"unpackPhase"
66+
"checkPhase"
67+
"buildPhase"
68+
];
69+
unpackPhase = ''
70+
echo "Linking data"
71+
ln -s ${data-drv} ./${dataDir}
72+
ln -s ${./wallets} ./wallets
73+
'';
74+
checkPhase = ''
75+
${self'.packages.pc-tx-bakery-tests}/bin/pc-tx-bakery-tests
76+
'';
77+
buildPhase = ''
78+
mkdir $out
79+
'';
80+
doCheck = true;
81+
};
82+
};
5983

6084
cardano-devnet.initialFunds = {
6185
"60a5587dc01541d4ad17d7a4416efee274d833f2fc894eef79976a3d06" = 9000000000;
6286
};
6387

64-
process-compose.tx-bakery-tests = {
88+
process-compose.pc-tx-bakery-tests = {
6589
imports = [
6690
inputs.services-flake.processComposeModules.default
6791
];
92+
cli.environment.PC_DISABLE_TUI = true;
6893
settings.processes = {
69-
build = {
70-
command = "${pkgs.cargo}/bin/cargo build --tests";
71-
};
72-
7394
tests = {
74-
command = "${pkgs.cargo}/bin/cargo test";
95+
command = "
96+
${self'.packages.tx-bakery-testsuite-rust-test}/bin/run_tests.sh
97+
";
7598
depends_on = {
76-
build.condition = "process_completed_successfully";
7799
cardano_devnet.condition = "process_healthy";
78100
ogmios.condition = "process_healthy";
79101
};
102+
availability = {
103+
exit_on_end = true;
104+
exit_on_skipped = true;
105+
};
80106
};
81107

82108
cardano_devnet = {
83109
command = config.packages.cardano-devnet;
84-
depends_on.build.condition = "process_completed_successfully";
85110
readiness_probe = {
86111
exec.command = ''
87112
${inputs'.cardano-node.packages.cardano-cli}/bin/cardano-cli query tip \

extras/tx-indexer-testsuite/build.nix

+30-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
rustFlake = inputs.flake-lang.lib.${system}.rustFlake {
1313
src = ./.;
1414
crateName = "tx-indexer-testsuite";
15+
exportTests = true;
1516
extraSources = [
1617
config.packages.tx-bakery-rust-src
1718
config.packages.tx-bakery-ogmios-rust-src
@@ -21,7 +22,7 @@
2122
buildInputs = [ pkgs.postgresql_16.lib ];
2223

2324
devShellTools = [
24-
self'.packages.tx-indexer-tests
25+
self'.packages.pc-tx-indexer-tests
2526
];
2627

2728
devShellHook =
@@ -31,20 +32,44 @@
3132
3233
echo "TxIndexer testsuite"
3334
echo ""
34-
echo "Run tx-indexer-tests to execute the testsuite."
35-
echo "or tx-indexer-tests up db_migration ogmios cardano_devnet -t=true to spin up an environment"
35+
echo "Run pc-tx-indexer-tests to execute the testsuite."
36+
echo "or pc-tx-indexer-tests up db_migration ogmios cardano_devnet -t=true to spin up an environment"
3637
echo ""
3738
'';
3839
};
3940
in
4041
{
4142
inherit (rustFlake) devShells packages;
4243

44+
checks = {
45+
"tx-indexer-testsuite" = pkgs.stdenv.mkDerivation {
46+
name = "tx-indexer-testsuite";
47+
phases = [
48+
"unpackPhase"
49+
"checkPhase"
50+
"buildPhase"
51+
];
52+
unpackPhase = ''
53+
echo "Linking data"
54+
ln -s ${./wallets} ./wallets
55+
mkdir ./tests
56+
ln -s ${./tests/fixtures} ./tests/fixtures
57+
'';
58+
checkPhase = ''
59+
${self'.packages.pc-tx-indexer-tests}/bin/pc-tx-indexer-tests
60+
'';
61+
buildPhase = ''
62+
mkdir $out
63+
'';
64+
doCheck = true;
65+
};
66+
};
67+
4368
cardano-devnet.initialFunds = {
4469
"60a5587dc01541d4ad17d7a4416efee274d833f2fc894eef79976a3d06" = 9000000000;
4570
};
4671

47-
process-compose.tx-indexer-tests = {
72+
process-compose.pc-tx-indexer-tests = {
4873
imports = [
4974
inputs.services-flake.processComposeModules.default
5075
];
@@ -62,13 +87,9 @@
6287
];
6388
};
6489
settings.processes = {
65-
build = {
66-
command = "${pkgs.cargo}/bin/cargo build --tests";
67-
};
6890
tests = {
69-
command = "${pkgs.cargo}/bin/cargo test";
91+
command = "${self'.packages.tx-indexer-testsuite-rust-test}/bin/run_tests.sh";
7092
depends_on = {
71-
build.condition = "process_completed_successfully";
7293
cardano_devnet.condition = "process_healthy";
7394
ogmios.condition = "process_healthy";
7495
db.condition = "process_healthy";
@@ -82,7 +103,6 @@
82103

83104
cardano_devnet = {
84105
command = config.packages.cardano-devnet;
85-
depends_on.build.condition = "process_completed_successfully";
86106
readiness_probe = {
87107
exec.command = ''
88108
${inputs'.cardano-node.packages.cardano-cli}/bin/cardano-cli query tip \

0 commit comments

Comments
 (0)