Skip to content

Commit

Permalink
explicitly setup test scenario for test_query_default_page_limit (Mys…
Browse files Browse the repository at this point in the history
…tenLabs#18393)

## Description 

Unblock MystenLabs#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



## 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:
  • Loading branch information
wlmyng authored and tx-tomcat committed Jul 29, 2024
1 parent 2eda186 commit 251dbf8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
8 changes: 8 additions & 0 deletions crates/sui-graphql-rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ impl ConnectionConfig {
}
}

pub fn ci_integration_test_cfg() -> Self {
Self {
db_url: "postgres://postgres:postgrespw@localhost:5432/sui_graphql_rpc_e2e_tests"
.to_string(),
..Default::default()
}
}

pub fn ci_integration_test_cfg_with_db_name(
db_name: String,
port: u16,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-graphql-rpc/src/server/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,15 +916,15 @@ 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,
..Default::default()
},
..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 } } }")
Expand Down
71 changes: 32 additions & 39 deletions crates/sui-graphql-rpc/tests/e2e_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +27,33 @@ mod tests {
use tempfile::tempdir;
use tokio::time::sleep;

async fn prep_cluster() -> (ConnectionConfig, ExecutorCluster) {
let rng = StdRng::from_seed([12; 32]);
let data_ingestion_path = tempdir().unwrap().into_path();
let mut sim = Simulacrum::new_with_rng(rng);
sim.set_data_ingestion_path(data_ingestion_path.clone());

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,
data_ingestion_path,
)
.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() {
Expand Down Expand Up @@ -118,25 +146,7 @@ mod tests {
#[tokio::test]
#[serial]
async fn test_graphql_client_response() {
let rng = StdRng::from_seed([12; 32]);
let data_ingestion_path = tempdir().unwrap().into_path();
let mut sim = Simulacrum::new_with_rng(rng);
sim.set_data_ingestion_path(data_ingestion_path.clone());

sim.create_checkpoint();
sim.create_checkpoint();

let cluster = sui_graphql_rpc::test_infra::cluster::serve_executor(
ConnectionConfig::default(),
DEFAULT_INTERNAL_DATA_SOURCE_PORT,
Arc::new(sim),
None,
data_ingestion_path,
)
.await;
cluster
.wait_for_checkpoint_catchup(0, Duration::from_secs(10))
.await;
let (_, cluster) = prep_cluster().await;

let query = r#"
{
Expand Down Expand Up @@ -165,25 +175,7 @@ mod tests {
#[tokio::test]
#[serial]
async fn test_graphql_client_variables() {
let rng = StdRng::from_seed([12; 32]);
let data_ingestion_path = tempdir().unwrap().into_path();
let mut sim = Simulacrum::new_with_rng(rng);
sim.set_data_ingestion_path(data_ingestion_path.clone());

sim.create_checkpoint();
sim.create_checkpoint();

let cluster = sui_graphql_rpc::test_infra::cluster::serve_executor(
ConnectionConfig::default(),
DEFAULT_INTERNAL_DATA_SOURCE_PORT,
Arc::new(sim),
None,
data_ingestion_path,
)
.await;
cluster
.wait_for_checkpoint_catchup(1, Duration::from_secs(10))
.await;
let (_, cluster) = prep_cluster().await;

let query = r#"{obj1: object(address: $framework_addr) {address}
obj2: object(address: $deepbook_addr) {address}}"#;
Expand Down Expand Up @@ -873,7 +865,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]
Expand Down

0 comments on commit 251dbf8

Please sign in to comment.