-
Notifications
You must be signed in to change notification settings - Fork 753
Add nixos CI test for db-tools with node/cli #6472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
johnalotoski
wants to merge
3
commits into
master
Choose a base branch
from
jl/db-tools-ci
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+120
−2
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| {pkgs, ...}: let | ||
| inherit (lib) getExe; | ||
| inherit (pkgs) cardanoNodePackages lib; | ||
|
|
||
| # NixosTest script fns supporting a timeout have a default of 900 seconds. | ||
| # | ||
| # There is no pre-existing history for chain synthesis, and default | ||
| # cardano-testnet genesis parameters set epochs to be short and fast, so a 30 | ||
| # second global timeout should be more than sufficient. | ||
| globalTimeout = 30; | ||
|
|
||
| testDir = "testnet"; | ||
| in { | ||
| inherit globalTimeout; | ||
|
|
||
| name = "cardano-node-dbtools-test"; | ||
| nodes = { | ||
| machine = _: { | ||
| nixpkgs.pkgs = pkgs; | ||
|
|
||
| environment = { | ||
| systemPackages = with cardanoNodePackages; [ | ||
| cardano-cli | ||
| cardano-node | ||
| cardano-testnet | ||
| db-analyser | ||
| db-synthesizer | ||
| db-truncater | ||
| ]; | ||
|
|
||
| variables = { | ||
| CARDANO_CLI = getExe cardanoNodePackages.cardano-cli; | ||
| CARDANO_NODE = getExe cardanoNodePackages.cardano-node; | ||
| KES_KEY = "${testDir}/pools-keys/pool1/kes.skey"; | ||
| OPCERT = "${testDir}/pools-keys/pool1/opcert.cert"; | ||
| VRF_KEY = "${testDir}/pools-keys/pool1/vrf.skey"; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| testScript = '' | ||
| import re | ||
| countRegex = r'Counted (\d+) blocks\.' | ||
|
|
||
| start_all() | ||
| print(machine.succeed("cardano-node --version")) | ||
| print(machine.succeed("cardano-cli --version")) | ||
| print(machine.succeed("cardano-testnet version")) | ||
| print(machine.succeed("cardano-testnet create-env --output ${testDir}")) | ||
|
|
||
| # TODO: Until db-synthesizer is fixed upstream | ||
| # print(machine.succeed("db-synthesizer \ | ||
| # --config ${testDir}/configuration.yaml \ | ||
| # --db db \ | ||
| # --shelley-operational-certificate $OPCERT \ | ||
| # --shelley-vrf-key $VRF_KEY \ | ||
| # --shelley-kes-key $KES_KEY \ | ||
| # --epochs 1 \ | ||
| # 2>&1") | ||
|
|
||
| print(machine.succeed("echo Analyze synthesized chain")) | ||
| out = machine.succeed("db-analyser \ | ||
| --db db \ | ||
| --verbose \ | ||
| --count-blocks \ | ||
| --v2-in-mem \ | ||
| --config ${testDir}/configuration.yaml \ | ||
| 2>&1" | ||
| ) | ||
| print(out) | ||
| match = re.search(countRegex, out) | ||
| assert match is not None, f"Could not find block count in post-synthesis output: {out}" | ||
| blocks_before = int(match.group(1)) | ||
| print(f"Found {blocks_before} blocks post synthesis") | ||
|
|
||
| # TODO: Until db-synthesizer is fixed upstream | ||
| # assert blocks_before > 0, f"No blocks were synthesized: {blocks_before}" | ||
|
|
||
| print(machine.succeed("echo Truncate synthesized chain")) | ||
| print(machine.succeed("db-truncater \ | ||
| --db db \ | ||
| --truncate-after-block 1 \ | ||
| --verbose \ | ||
| --config ${testDir}/configuration.yaml \ | ||
| 2>&1") | ||
| ) | ||
|
|
||
| print(machine.succeed("echo Analyze truncated chain")) | ||
| out = machine.succeed("db-analyser \ | ||
| --db db \ | ||
| --verbose \ | ||
| --count-blocks \ | ||
| --v2-in-mem \ | ||
| --config ${testDir}/configuration.yaml \ | ||
| 2>&1" | ||
| ) | ||
| print(out) | ||
| match = re.search(countRegex, out) | ||
| assert match is not None, f"Could not find block count in post-truncation output: {out}" | ||
| blocks_after = int(match.group(1)) | ||
| print(f"Found {blocks_after} blocks post truncation") | ||
|
|
||
| # TODO: Until db-synthesizer is fixed upstream | ||
| # assert blocks_after == 1, f"Expected exactly 1 block after truncation, got {blocks_after}" | ||
| # assert blocks_before > blocks_after, f"Pre-truncation blockHeight of {blocks_before} should be larger than post-truncation blockHeight of {blocks_after}" | ||
| ''; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.