-
Couldn't load subscription status.
- Fork 583
Archive: implement live upgrade node test #17850
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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
62 changes: 62 additions & 0 deletions
62
src/test/archive/archive_node_tests/live_upgrade_archive.ml
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,62 @@ | ||
| open Async | ||
| open Core | ||
| open Mina_automation | ||
| open Mina_automation_fixture.Archive | ||
| open Common | ||
|
|
||
| (* NOTE: | ||
| To run this test, several preparation is needed | ||
| - ensure we have this test, replayer & archive node build with devnet profile | ||
| - ensure we have a data base instance up | ||
| - Run the following: | ||
| ``` | ||
| MINA_TEST_POSTGRES_URI=postgres://postgres:xxxx@localhost:5432 \ | ||
| MINA_TEST_NETWORK_DATA=./src/test/archive/sample_db \ | ||
| ./_build/default/src/test/archive/archive_node_tests/archive_node_tests.exe \ | ||
| test live_upgrade_archive | ||
| ``` | ||
| *) | ||
|
|
||
| type t = Mina_automation_fixture.Archive.after_bootstrap | ||
|
|
||
| let test_case (test_data : t) = | ||
| let open Deferred.Let_syntax in | ||
| let daemon = Daemon.default () in | ||
| let archive_uri = test_data.archive.config.postgres_uri in | ||
| let temp_dir = test_data.temp_dir in | ||
| let%bind precomputed_blocks = | ||
| unpack_precomputed_blocks ~temp_dir test_data.network_data | ||
| in | ||
| let logger = Logger.create () in | ||
| let log_file = temp_dir ^ "/live_upgrade.log" in | ||
| let upgrade_path = | ||
| Archive.Scripts.filepath `Upgrade | ||
| |> Option.value_exn ~message:"Failed to find upgrade script" | ||
| in | ||
| let upgrade_script_finished = Ivar.create () in | ||
| (let%bind () = after (Time.Span.of_min (Random.float_range 0. 5.)) in | ||
| [%log info] "Starting upgrade script" ; | ||
| let%map result = | ||
| Psql.run_script ~connection:(Psql.Conn_str archive_uri) upgrade_path | ||
| in | ||
| [%log info] "Finished executing upgrade script" | ||
| ~metadata:[ ("result", `String result) ] ; | ||
| Ivar.fill upgrade_script_finished () ) | ||
| |> Deferred.don't_wait_for ; | ||
| Archive.Process.start_logging test_data.archive ~log_file ; | ||
|
|
||
| let%bind () = | ||
| Daemon.archive_blocks_from_files daemon.executor | ||
| ~archive_address:test_data.archive.config.server_port ~format:`Precomputed | ||
| ~sleep:5 precomputed_blocks | ||
| in | ||
| [%log info] "Loaded all precomputed blocks" ; | ||
| let%bind () = Ivar.read upgrade_script_finished in | ||
| let%bind () = | ||
| assert_replayer_run_against_last_block | ||
| ~replayer_input_file_path: | ||
| (Network_data.replayer_input_file_path test_data.network_data) | ||
| archive_uri temp_dir | ||
| in | ||
|
|
||
| Deferred.Or_error.return Mina_automation_fixture.Intf.Passed | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is 0-5 minutes, but the sleep in
archive_blocks_from_filesis 0-5 seconds. Should this one be seconds too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, 5min is the time it takes to run the whole test on my machine. I'm expecting the upgrade script to be ran any time during the process of loading precomputed blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see - this delay wasn't supposed to match up with the delay from
archive_blocks_from_files. This is a random delay to put the start of the upgrade script somewhere in the middle of that other function's execution.