Skip to content

Commit 772a84f

Browse files
authored
cleanup: reduce integration test matrix wrt client config (#3366)
1 parent cd5c0a8 commit 772a84f

File tree

9 files changed

+106
-138
lines changed

9 files changed

+106
-138
lines changed

src/integration-tests/src/bigquery.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use rand::{Rng, distr::Alphanumeric};
1919

2020
const INSTANCE_LABEL: &str = "rust-sdk-integration-test";
2121

22-
pub async fn dataset_admin(
23-
builder: bigquery::builder::dataset_service::ClientBuilder,
24-
) -> Result<()> {
22+
pub async fn dataset_admin() -> Result<()> {
2523
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2624
// verify tracing is doing something.
2725
#[cfg(feature = "log-integration-tests")]
@@ -37,7 +35,10 @@ pub async fn dataset_admin(
3735
};
3836

3937
let project_id = crate::project_id()?;
40-
let client: bigquery::client::DatasetService = builder.build().await?;
38+
let client = bigquery::client::DatasetService::builder()
39+
.with_tracing()
40+
.build()
41+
.await?;
4142
cleanup_stale_datasets(&client, &project_id).await?;
4243

4344
let dataset_id = random_dataset_id();
@@ -187,7 +188,7 @@ fn extract_dataset_id(project_id: &str, id: &str) -> Option<String> {
187188
.map(|v| v.to_string())
188189
}
189190

190-
pub async fn job_service(builder: bigquery::builder::job_service::ClientBuilder) -> Result<()> {
191+
pub async fn job_service() -> Result<()> {
191192
// Enable a basic subscriber. Useful to troubleshoot problems and visually
192193
// verify tracing is doing something.
193194
#[cfg(feature = "log-integration-tests")]
@@ -203,7 +204,10 @@ pub async fn job_service(builder: bigquery::builder::job_service::ClientBuilder)
203204
};
204205

205206
let project_id = crate::project_id()?;
206-
let client: bigquery::client::JobService = builder.build().await?;
207+
let client = bigquery::client::JobService::builder()
208+
.with_tracing()
209+
.build()
210+
.await?;
207211
cleanup_stale_jobs(&client, &project_id).await?;
208212

209213
let job_id = random_job_id();

src/integration-tests/src/error_details.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use crate::Result;
1616
use gax::retry_policy::{AlwaysRetry, RetryPolicyExt};
17+
use storage::client::StorageControl;
1718

18-
pub async fn error_details_http(
19-
builder: ta::builder::telco_automation::ClientBuilder,
20-
) -> Result<()> {
19+
pub async fn error_details_http() -> Result<()> {
2120
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2221
// verify tracing is doing something.
2322
#[cfg(feature = "log-integration-tests")]
@@ -34,7 +33,8 @@ pub async fn error_details_http(
3433

3534
let project_id = crate::project_id()?;
3635
let region_id = crate::region_id();
37-
let client = builder
36+
let client = ta::client::TelcoAutomation::builder()
37+
.with_tracing()
3838
.with_retry_policy(AlwaysRetry.with_attempt_limit(2))
3939
.build()
4040
.await?;
@@ -54,9 +54,7 @@ pub async fn error_details_http(
5454
Ok(())
5555
}
5656

57-
pub async fn error_details_grpc(
58-
builder: storage::builder::storage_control::ClientBuilder,
59-
) -> Result<()> {
57+
pub async fn error_details_grpc() -> Result<()> {
6058
#[cfg(feature = "log-integration-tests")]
6159
let _guard = {
6260
use tracing_subscriber::fmt::format::FmtSpan;
@@ -69,7 +67,7 @@ pub async fn error_details_grpc(
6967
tracing::subscriber::set_default(subscriber)
7068
};
7169

72-
let client = builder.build().await?;
70+
let client = StorageControl::builder().with_tracing().build().await?;
7371
let err = client
7472
.get_bucket()
7573
.set_name("malformed/_/bucket/name")
@@ -84,7 +82,7 @@ pub async fn error_details_grpc(
8482
Ok(())
8583
}
8684

87-
pub async fn check_code_for_http(builder: wf::builder::workflows::ClientBuilder) -> Result<()> {
85+
pub async fn check_code_for_http() -> Result<()> {
8886
#[cfg(feature = "log-integration-tests")]
8987
let _guard = {
9088
use tracing_subscriber::fmt::format::FmtSpan;
@@ -102,7 +100,10 @@ pub async fn check_code_for_http(builder: wf::builder::workflows::ClientBuilder)
102100
let workflow_id = crate::random_workflow_id();
103101
let workflow_name =
104102
format!("projects/{project_id}/locations/{location_id}/workflows/{workflow_id}");
105-
let client = builder.build().await?;
103+
let client = wf::client::Workflows::builder()
104+
.with_tracing()
105+
.build()
106+
.await?;
106107

107108
match client.get_workflow().set_name(&workflow_name).send().await {
108109
Ok(g) => panic!("unexpected success {g:?}"),
@@ -119,9 +120,7 @@ pub async fn check_code_for_http(builder: wf::builder::workflows::ClientBuilder)
119120
Ok(())
120121
}
121122

122-
pub async fn check_code_for_grpc(
123-
builder: storage::builder::storage_control::ClientBuilder,
124-
) -> Result<()> {
123+
pub async fn check_code_for_grpc() -> Result<()> {
125124
#[cfg(feature = "log-integration-tests")]
126125
let _guard = {
127126
use tracing_subscriber::fmt::format::FmtSpan;
@@ -136,7 +135,7 @@ pub async fn check_code_for_grpc(
136135

137136
let bucket_id = crate::random_bucket_id();
138137
let bucket_name = format!("projects/_/buckets/{bucket_id}");
139-
let client = builder.build().await?;
138+
let client = StorageControl::builder().with_tracing().build().await?;
140139

141140
match client.get_bucket().set_name(&bucket_name).send().await {
142141
Ok(g) => panic!("unexpected success {g:?}"),

src/integration-tests/src/firestore.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn new_collection_id() -> String {
3030
format!("{prefix}{collection_id}")
3131
}
3232

33-
pub async fn basic(builder: firestore::builder::firestore::ClientBuilder) -> Result<()> {
33+
pub async fn basic() -> Result<()> {
3434
// Enable a basic subscriber. Useful to troubleshoot problems and visually
3535
// verify tracing is doing something.
3636
#[cfg(feature = "log-integration-tests")]
@@ -45,10 +45,10 @@ pub async fn basic(builder: firestore::builder::firestore::ClientBuilder) -> Res
4545
tracing::subscriber::set_default(subscriber)
4646
};
4747

48-
cleanup_stale_documents().await?;
48+
let client = Firestore::builder().with_tracing().build().await?;
49+
cleanup_stale_documents(&client).await?;
4950

5051
let project_id = crate::project_id()?;
51-
let client = builder.build().await?;
5252
let collection_id = new_collection_id();
5353
let response = client
5454
.create_document()
@@ -113,19 +113,15 @@ pub async fn basic(builder: firestore::builder::firestore::ClientBuilder) -> Res
113113
Ok(())
114114
}
115115

116-
async fn cleanup_stale_documents() -> Result<()> {
116+
async fn cleanup_stale_documents(client: &Firestore) -> Result<()> {
117+
use gax::options::RequestOptionsBuilder;
117118
use gax::retry_policy::RetryPolicyExt;
118119
use std::time::{Duration, SystemTime, UNIX_EPOCH};
119120

120121
let stale_deadline = SystemTime::now().duration_since(UNIX_EPOCH)?;
121122
let stale_deadline = stale_deadline - Duration::from_secs(48 * 60 * 60);
122123
let stale_deadline = wkt::Timestamp::clamp(stale_deadline.as_secs() as i64, 0);
123124

124-
let client = Firestore::builder()
125-
.with_retry_policy(gax::retry_policy::AlwaysRetry.with_attempt_limit(3))
126-
.build()
127-
.await?;
128-
129125
let mut stale_documents = Vec::new();
130126

131127
let project_id = crate::project_id()?;
@@ -152,7 +148,13 @@ async fn cleanup_stale_documents() -> Result<()> {
152148
let stale_documents = stale_documents;
153149
let pending = stale_documents
154150
.iter()
155-
.map(|name| client.delete_document().set_name(name).send())
151+
.map(|name| {
152+
client
153+
.delete_document()
154+
.set_name(name)
155+
.with_retry_policy(gax::retry_policy::AlwaysRetry.with_attempt_limit(3))
156+
.send()
157+
})
156158
.collect::<Vec<_>>();
157159

158160
futures::future::join_all(pending)

src/integration-tests/src/secret_manager/openapi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::Result;
1616
use gax::paginator::Paginator;
1717
use rand::{Rng, distr::Alphanumeric};
1818

19-
pub async fn run(builder: smo::builder::secret_manager_service::ClientBuilder) -> Result<()> {
19+
pub async fn run() -> Result<()> {
2020
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2121
// verify tracing is doing something.
2222
#[cfg(feature = "log-integration-tests")]
@@ -37,7 +37,10 @@ pub async fn run(builder: smo::builder::secret_manager_service::ClientBuilder) -
3737
.map(char::from)
3838
.collect();
3939

40-
let client = builder.build().await?;
40+
let client = smo::client::SecretManagerService::builder()
41+
.with_tracing()
42+
.build()
43+
.await?;
4144

4245
println!("\nTesting create_secret()");
4346
let create = client

src/integration-tests/src/secret_manager/openapi_locational.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use crate::Result;
1616
use rand::{Rng, distr::Alphanumeric};
1717

18-
pub async fn run(builder: smo::builder::secret_manager_service::ClientBuilder) -> Result<()> {
18+
pub async fn run() -> Result<()> {
1919
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2020
// verify tracing is doing something.
2121
#[cfg(feature = "log-integration-tests")]
@@ -40,7 +40,11 @@ pub async fn run(builder: smo::builder::secret_manager_service::ClientBuilder) -
4040
// We must override the configuration to use a regional endpoint.
4141
let location_id = "us-central1".to_string();
4242
let endpoint = format!("https://secretmanager.{location_id}.rep.googleapis.com");
43-
let client = builder.with_endpoint(endpoint).build().await?;
43+
let client = smo::client::SecretManagerService::builder()
44+
.with_tracing()
45+
.with_endpoint(endpoint)
46+
.build()
47+
.await?;
4448

4549
cleanup_stale_secrets(&client, &project_id, &location_id).await?;
4650

src/integration-tests/src/sql.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use rand::Rng;
1919
use sql::model;
2020
use storage_samples::RandomChars;
2121

22-
pub async fn run_sql_instances_service(
23-
builder: sql::builder::sql_instances_service::ClientBuilder,
24-
) -> Result<()> {
22+
pub async fn run_sql_instances_service() -> Result<()> {
2523
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2624
// verify tracing is doing something.
2725
#[cfg(feature = "log-integration-tests")]
@@ -38,7 +36,10 @@ pub async fn run_sql_instances_service(
3836

3937
let project_id = crate::project_id()?;
4038
let name = random_sql_instance_name(&project_id);
41-
let client: sql::client::SqlInstancesService = builder.build().await?;
39+
let client = sql::client::SqlInstancesService::builder()
40+
.with_tracing()
41+
.build()
42+
.await?;
4243

4344
cleanup_stale_sql_instances(&client, &project_id).await?;
4445

@@ -168,9 +169,7 @@ async fn cleanup_stale_sql_instances(
168169
Ok(())
169170
}
170171

171-
pub async fn run_sql_tiers_service(
172-
builder: sql::builder::sql_tiers_service::ClientBuilder,
173-
) -> Result<()> {
172+
pub async fn run_sql_tiers_service() -> Result<()> {
174173
// Enable a basic subscriber. Useful to troubleshoot problems and visually
175174
// verify tracing is doing something.
176175
#[cfg(feature = "log-integration-tests")]
@@ -186,7 +185,10 @@ pub async fn run_sql_tiers_service(
186185
};
187186

188187
let project_id = crate::project_id()?;
189-
let client: sql::client::SqlTiersService = builder.build().await?;
188+
let client = sql::client::SqlTiersService::builder()
189+
.with_tracing()
190+
.build()
191+
.await?;
190192

191193
let list = client.list().set_project(&project_id).send().await?;
192194

src/integration-tests/src/workflows.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use gax::paginator::ItemPaginator as _;
1919
use lro::Poller;
2020
use std::time::Duration;
2121

22-
pub async fn until_done(builder: wf::builder::workflows::ClientBuilder) -> Result<()> {
22+
pub async fn until_done() -> Result<()> {
2323
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2424
// verify tracing is doing something.
2525
#[cfg(feature = "log-integration-tests")]
@@ -38,7 +38,10 @@ pub async fn until_done(builder: wf::builder::workflows::ClientBuilder) -> Resul
3838
let location_id = crate::region_id();
3939
let workflows_runner = crate::workflows_runner()?;
4040

41-
let client = builder.build().await?;
41+
let client = wf::client::Workflows::builder()
42+
.with_tracing()
43+
.build()
44+
.await?;
4245
cleanup_stale_workflows(&client, &project_id, &location_id).await?;
4346

4447
let source_contents = r###"# Test only workflow
@@ -81,7 +84,7 @@ main:
8184
Ok(())
8285
}
8386

84-
pub async fn explicit_loop(builder: wf::builder::workflows::ClientBuilder) -> Result<()> {
87+
pub async fn explicit_loop() -> Result<()> {
8588
// Enable a basic subscriber. Useful to troubleshoot problems and visually
8689
// verify tracing is doing something.
8790
#[cfg(feature = "log-integration-tests")]
@@ -100,7 +103,10 @@ pub async fn explicit_loop(builder: wf::builder::workflows::ClientBuilder) -> Re
100103
let location_id = crate::region_id();
101104
let workflows_runner = crate::workflows_runner()?;
102105

103-
let client = builder.build().await?;
106+
let client = wf::client::Workflows::builder()
107+
.with_tracing()
108+
.build()
109+
.await?;
104110
cleanup_stale_workflows(&client, &project_id, &location_id).await?;
105111

106112
let source_contents = r###"# Test only workflow
@@ -238,7 +244,10 @@ pub async fn manual(
238244
workflow_id: String,
239245
workflow: wf::model::Workflow,
240246
) -> Result<()> {
241-
let client = wf::client::Workflows::builder().build().await?;
247+
let client = wf::client::Workflows::builder()
248+
.with_tracing()
249+
.build()
250+
.await?;
242251

243252
println!("\n\nStart create_workflow() LRO and poll it to completion");
244253
let create = client

src/integration-tests/src/workflows_executions.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use lro::Poller;
2121
use std::time::Duration;
2222

2323
// Verify enum query parameters are serialized correctly.
24-
pub async fn list(builder: wfe::builder::executions::ClientBuilder) -> Result<()> {
24+
pub async fn list() -> Result<()> {
2525
// Enable a basic subscriber. Useful to troubleshoot problems and visually
2626
// verify tracing is doing something.
2727
#[cfg(feature = "log-integration-tests")]
@@ -40,7 +40,10 @@ pub async fn list(builder: wfe::builder::executions::ClientBuilder) -> Result<()
4040
// workflows integration tests to delete it if something fails or crashes
4141
// in this test.
4242
let parent = create_test_workflow().await?;
43-
let client = builder.build().await?;
43+
let client = wfe::client::Executions::builder()
44+
.with_tracing()
45+
.build()
46+
.await?;
4447

4548
// Create an execution with a label. The label is not returned for the `BASIC` view.
4649
let start = client

0 commit comments

Comments
 (0)