Refactor GQS integ tests
@@ -75,17 +75,26 @@ async fn provision_example_graph_schema(tenant_id: uuid::Uuid) -> eyre::Result<(
Ok(())
}
-#[test_log::test(tokio::test)]
-async fn test_query_two_attached_nodes() -> eyre::Result<()> {
+// This should probably replaced by a refactored E2eTestContext at some point.
+struct GraphQueryIntegTestSetup {
+ graph_query_client: GraphQueryClient,
+ graph_mutation_client: GraphMutationClient,
+ tenant_id: uuid::Uuid,
+ _span: tracing::Span,
+}
+
+impl GraphQueryIntegTestSetup {
+ pub async fn setup() -> eyre::Result<GraphQueryIntegTestSetup> {
+ // <setup>
let _span = tracing::info_span!(
"tenant_id", tenant_id=?tracing::field::Empty,
);
let query_client_config = GraphQueryClientConfig::parse();
- let mut graph_query_client = GraphQueryClient::connect_with_config(query_client_config).await?;
+ let graph_query_client = GraphQueryClient::connect_with_config(query_client_config).await?;
let mutation_client_config = GraphMutationClientConfig::parse();
- let mut graph_mutation_client =
+ let graph_mutation_client =
GraphMutationClient::connect_with_config(mutation_client_config).await?;
let provisioner_client_config = ScyllaProvisionerClientConfig::parse();
@@ -105,7 +114,8 @@ async fn test_query_two_attached_nodes() -> eyre::Result<()> {
// otherwise-unrecommended non-caching UidAllocator client.
let mut uid_allocator_client =
- UidAllocatorServiceClient::connect_with_config(UidAllocatorClientConfig::parse()).await?;
+ UidAllocatorServiceClient::connect_with_config(UidAllocatorClientConfig::parse())
+ .await?;
uid_allocator_client
.create_tenant_keyspace(CreateTenantKeyspaceRequest { tenant_id })
.await?;
@@ -113,6 +123,24 @@ async fn test_query_two_attached_nodes() -> eyre::Result<()> {
// Provision a Schema so we can test how edges work
provision_example_graph_schema(tenant_id).await?;
+ Ok(Self {
+ graph_query_client,
+ graph_mutation_client,
+ tenant_id,
+ _span,
+ })
+ }
+}
+
+#[test_log::test(tokio::test)]
+async fn test_query_two_attached_nodes() -> eyre::Result<()> {
+ let GraphQueryIntegTestSetup {
+ mut graph_query_client,
+ mut graph_mutation_client,
+ tenant_id,
+ _span,
+ } = GraphQueryIntegTestSetup::setup().await?;
+
let process_node_type = NodeType::try_from("Process").unwrap();
let file_node_type = NodeType::try_from("File").unwrap();
