Skip to content

Conversation

bmwill
Copy link
Contributor

@bmwill bmwill commented Sep 1, 2024

Description

Convert all tests that relied on an external postgres db to use an ephemeral pstrgres db enabling them all to be run in parallel.

After this patch the graphql-test workflow takes ~7 minutes compared to ~19 minutes it used to take.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Sep 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 3:03pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 3:03pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 3:03pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 3:03pm

Introduce LocalDatabase, a local instance of a postgres server, as well
as TempDb, a way to create ephemeral postgres databases for use in
testing enviornments.
Convert remaining graphql tests to use an ephemeral pstrgres db enabling
them all to be run in parallel.

After this patch the graphql-test workflow takes ~7 minutes compared
to ~19 minutes it used to take.
@bmwill bmwill changed the title ephemeral postgres db for testing graphql, indexer: introduce ephemeral postgres db for testing Sep 3, 2024
@bmwill bmwill marked this pull request as ready for review September 3, 2024 14:59
@bmwill bmwill enabled auto-merge (rebase) September 3, 2024 15:21
@bmwill bmwill requested review from gegaowp and lxfind September 3, 2024 15:24
Copy link
Contributor

@wlmyng wlmyng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dope

cancellation_tokens.push(writer_token.drop_guard());

// Start in reader mode
// Start indexer jsonrpc service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been noticing this shift in terminology and big fan of it

ReaderWriterConfig::writer_mode(None, None),
/* reset_database */ true,
Some(data_ingestion_path),
/* reset_database */ false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to not reset db?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I think after this PR that flag is obsolete, as in we unconditionally reset the db when starting a writer in tests. This is contrary to this flags existence of course....which i think we specifically about deleting the DB in a shared postgres service.

Comment on lines +234 to +238
sim.advance_clock(
std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.unwrap(),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we advance clock for each checkpoint to better emulate what happens in prod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is specifically to get the clock to be close to "current time" for the health check test. there's probably some changes we could make to Simulacrum to make this a bit easier of course

/// Return an ephemeral, available port. On unix systems, the port returned will be in the
/// TIME_WAIT state ensuring that the OS won't hand out this port for some grace period.
/// Callers should be able to bind to this port given they use SO_REUSEADDR.
pub fn get_available_port() -> u16 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throughout our tests we have a few places that do ("127.0.0.1:{}", get_available_port), what are your thoughts on having a function here that's like, build_db_address(host: Option<u64>) so we can reduce the manual 127.0.0.1

@bmwill bmwill merged commit dd8e82c into MystenLabs:main Sep 3, 2024
61 of 76 checks passed
@bmwill bmwill deleted the indexer-async branch September 4, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants