From 246f4e4230094ff6c0f57040c791cecceda0a256 Mon Sep 17 00:00:00 2001 From: wlmyng <127570466+wlmyng@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:39:40 -0700 Subject: [PATCH] =?UTF-8?q?[pick][gql-2024.1.0]=20explicitly=20setup=20tes?= =?UTF-8?q?t=20scenario=20for=20test=5Fquery=5Fdefault=5Fpage=5Flimit=20(#?= =?UTF-8?q?18=E2=80=A6=20(#18395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …393) Unblock https://github.com/MystenLabs/sui/pull/18277 by explicitly setting up the correct test scenario for the `test_query_default_page_limit` test. I think we can follow this up with 1. instead of using the same db url, follow sui-graphql-e2e-tests pattern and generate unique db urls for each test 2. this is so that we can run tests in parallel instead of sequentially (which is the case today due to the serial) 3. we can leverage ExecutorCluster.cleanup_resources to cleanup each test How did you test the new or updated feature? --- 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: ## Description Describe the changes or additions included in this PR. ## 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: --- crates/sui-graphql-rpc/src/server/builder.rs | 4 +- crates/sui-graphql-rpc/tests/e2e_tests.rs | 58 ++++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/crates/sui-graphql-rpc/src/server/builder.rs b/crates/sui-graphql-rpc/src/server/builder.rs index 6570aa0708259..ff0ed06c438cc 100644 --- a/crates/sui-graphql-rpc/src/server/builder.rs +++ b/crates/sui-graphql-rpc/src/server/builder.rs @@ -873,7 +873,7 @@ pub mod tests { ); } - pub async fn test_query_default_page_limit_impl() { + pub async fn test_query_default_page_limit_impl(connection_config: ConnectionConfig) { let service_config = ServiceConfig { limits: Limits { default_page_size: 1, @@ -881,7 +881,7 @@ pub mod tests { }, ..Default::default() }; - let schema = prep_schema(None, Some(service_config)).build_schema(); + let schema = prep_schema(Some(connection_config), Some(service_config)).build_schema(); let resp = schema .execute("{ checkpoints { nodes { sequenceNumber } } }") diff --git a/crates/sui-graphql-rpc/tests/e2e_tests.rs b/crates/sui-graphql-rpc/tests/e2e_tests.rs index d2ce28600d7df..493a684176df2 100644 --- a/crates/sui-graphql-rpc/tests/e2e_tests.rs +++ b/crates/sui-graphql-rpc/tests/e2e_tests.rs @@ -14,6 +14,7 @@ mod tests { use sui_graphql_rpc::client::simple_client::GraphqlQueryVariable; use sui_graphql_rpc::client::ClientError; use sui_graphql_rpc::config::ConnectionConfig; + use sui_graphql_rpc::test_infra::cluster::ExecutorCluster; use sui_graphql_rpc::test_infra::cluster::DEFAULT_INTERNAL_DATA_SOURCE_PORT; use sui_types::digests::ChainIdentifier; use sui_types::gas_coin::GAS; @@ -25,6 +26,30 @@ mod tests { use sui_types::SUI_FRAMEWORK_PACKAGE_ID; use tokio::time::sleep; + async fn prep_cluster() -> (ConnectionConfig, ExecutorCluster) { + let rng = StdRng::from_seed([12; 32]); + let mut sim = Simulacrum::new_with_rng(rng); + + sim.create_checkpoint(); + sim.create_checkpoint(); + + let connection_config = ConnectionConfig::ci_integration_test_cfg(); + + let cluster = sui_graphql_rpc::test_infra::cluster::serve_executor( + connection_config.clone(), + DEFAULT_INTERNAL_DATA_SOURCE_PORT, + Arc::new(sim), + None, + ) + .await; + + cluster + .wait_for_checkpoint_catchup(1, Duration::from_secs(10)) + .await; + + (connection_config, cluster) + } + #[tokio::test] #[serial] async fn test_simple_client_validator_cluster() { @@ -111,20 +136,7 @@ mod tests { #[tokio::test] #[serial] async fn test_graphql_client_response() { - let rng = StdRng::from_seed([12; 32]); - let mut sim = Simulacrum::new_with_rng(rng); - - sim.create_checkpoint(); - sim.create_checkpoint(); - - let connection_config = ConnectionConfig::ci_integration_test_cfg(); - let cluster = sui_graphql_rpc::test_infra::cluster::serve_executor( - connection_config, - DEFAULT_INTERNAL_DATA_SOURCE_PORT, - Arc::new(sim), - None, - ) - .await; + let (_, cluster) = prep_cluster().await; let query = r#" { @@ -153,20 +165,7 @@ mod tests { #[tokio::test] #[serial] async fn test_graphql_client_variables() { - let rng = StdRng::from_seed([12; 32]); - let mut sim = Simulacrum::new_with_rng(rng); - - sim.create_checkpoint(); - sim.create_checkpoint(); - - let connection_config = ConnectionConfig::ci_integration_test_cfg(); - let cluster = sui_graphql_rpc::test_infra::cluster::serve_executor( - connection_config, - DEFAULT_INTERNAL_DATA_SOURCE_PORT, - Arc::new(sim), - None, - ) - .await; + let (_, cluster) = prep_cluster().await; let query = r#"{obj1: object(address: $framework_addr) {address} obj2: object(address: $deepbook_addr) {address}}"#; @@ -830,7 +829,8 @@ mod tests { #[tokio::test] #[serial] async fn test_query_default_page_limit() { - test_query_default_page_limit_impl().await; + let (connection_config, _) = prep_cluster().await; + test_query_default_page_limit_impl(connection_config).await; } #[tokio::test]