From dab6b6db782cafb382a6675bae0976d2b9bbd0fd Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Wed, 28 Jan 2026 09:25:59 -0500 Subject: [PATCH 1/2] refactor: split openapi integration tests --- Cargo.lock | 23 +++++++- Cargo.toml | 3 + src/test-utils/src/resource_names.rs | 44 ++++++++++++++ tests/integration/Cargo.toml | 4 -- tests/integration/src/lib.rs | 2 - tests/integration/src/secret_manager.rs | 2 - .../src/secret_manager/protobuf.rs | 8 +-- tests/integration/tests/driver.rs | 16 ------ tests/integration/tests/serialization.rs | 17 ------ tests/openapi/Cargo.toml | 49 ++++++++++++++++ tests/openapi/README.md | 17 ++++++ .../openapi.rs => openapi/src/global.rs} | 57 +++++++++---------- tests/openapi/src/lib.rs | 35 ++++++++++++ .../src/locational.rs} | 51 +++++++++-------- tests/openapi/tests/driver.rs | 30 ++++++++++ 15 files changed, 254 insertions(+), 104 deletions(-) create mode 100644 tests/openapi/Cargo.toml create mode 100644 tests/openapi/README.md rename tests/{integration/src/secret_manager/openapi.rs => openapi/src/global.rs} (86%) create mode 100644 tests/openapi/src/lib.rs rename tests/{integration/src/secret_manager/openapi_locational.rs => openapi/src/locational.rs} (91%) create mode 100644 tests/openapi/tests/driver.rs diff --git a/Cargo.lock b/Cargo.lock index 0ce25a785b..25dedc9ce3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5836,7 +5836,6 @@ dependencies = [ "mockall", "rand 0.9.2", "reqwest 0.13.1", - "secretmanager-openapi-v1", "serde", "serde_json", "serde_with", @@ -5935,6 +5934,28 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "integration-tests-openapi" +version = "0.0.0" +dependencies = [ + "anyhow", + "bytes", + "chrono", + "crc32c", + "futures", + "google-cloud-gax", + "google-cloud-lro", + "google-cloud-test-utils", + "google-cloud-wkt", + "secretmanager-openapi-v1", + "serde", + "static_assertions", + "test-case", + "tokio", + "tracing", + "tracing-subscriber", +] + [[package]] name = "integration-tests-pubsub" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 98a18f33f0..eae34e6dec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -296,6 +296,7 @@ members = [ "tests/integration", "tests/integration-auth", "tests/o11y", + "tests/openapi", "tests/protojson-conformance", "tests/pubsub", "tests/showcase", @@ -474,10 +475,12 @@ language = { default-features = false, version = "1", pat google-cloud-dns-v1 = { default-features = false, path = "src/generated/cloud/dns/v1" } google-cloud-showcase-v1beta1 = { default-features = false, path = "src/generated/showcase" } google-cloud-trace-v1 = { default-features = false, path = "src/generated/devtools/cloudtrace/v1" } +secretmanager-openapi-v1 = { default-features = false, path = "src/generated/openapi-validation" } # The names on these are too long, I do not want to reformat the whole file for them. google-cloud-workflows-v1 = { default-features = false, path = "src/generated/cloud/workflows/v1" } google-cloud-workflows-executions-v1 = { default-features = false, path = "src/generated/cloud/workflows/executions/v1" } + # Local test packages (never add a version) google-cloud-test-utils = { default-features = false, path = "src/test-utils" } integration-tests = { path = "tests/integration" } diff --git a/src/test-utils/src/resource_names.rs b/src/test-utils/src/resource_names.rs index 36e2ed8900..b81cd66b1b 100644 --- a/src/test-utils/src/resource_names.rs +++ b/src/test-utils/src/resource_names.rs @@ -24,6 +24,9 @@ use rand::{ /// Where possible, we use this prefix for randomly generated resource ids. pub const PREFIX: &str = "rust-sdk-testing-"; +/// The maximum length for a secret ID. +const SECRET_ID_LENGTH: usize = 64; + const BUCKET_ID_LENGTH: usize = 63; const WORKFLOW_ID_LENGTH: usize = 64; @@ -44,6 +47,16 @@ pub fn random_workflow_id() -> String { format!("{PREFIX}{id}") } +/// Generate a random secret id. +pub fn random_secret_id() -> String { + let id: String = rand::rng() + .sample_iter(&Alphanumeric) + .take(SECRET_ID_LENGTH - PREFIX.len()) + .map(char::from) + .collect(); + format!("{PREFIX}{id}") +} + const LOWERCASE_ALPHANUMERIC_CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789"; /// Sample a `u8`, uniformly distributed over ASCII lowercase letters and numbers: a-z and 0-9. @@ -84,6 +97,11 @@ mod tests { #[test] fn bucket_id() { + assert!( + PREFIX.len() < BUCKET_ID_LENGTH, + "{PREFIX} length ({}) should be smaller than {BUCKET_ID_LENGTH}", + PREFIX.len() + ); let got = random_bucket_id(); assert!( got.len() <= BUCKET_ID_LENGTH, @@ -97,6 +115,11 @@ mod tests { #[test] fn workflow_id() { + assert!( + PREFIX.len() < WORKFLOW_ID_LENGTH, + "{PREFIX} length ({}) should be smaller than {WORKFLOW_ID_LENGTH}", + PREFIX.len() + ); let got = random_workflow_id(); assert!( got.len() <= WORKFLOW_ID_LENGTH, @@ -111,6 +134,27 @@ mod tests { ); } + #[test] + fn secret_id() { + assert!( + PREFIX.len() < SECRET_ID_LENGTH, + "{PREFIX} length ({}) should be smaller than {SECRET_ID_LENGTH}", + PREFIX.len() + ); + let got = random_workflow_id(); + assert!( + got.len() <= SECRET_ID_LENGTH, + "{got} has more than {SECRET_ID_LENGTH} characters" + ); + let suffix = got + .strip_prefix(PREFIX) + .expect("{got} should start with {PREFIX}"); + assert!( + suffix.chars().all(|c| c.is_alphanumeric()), + "the suffix should be alphanumeric: {suffix}" + ); + } + #[test] fn lowercase() { let got: String = rand::rng() diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 98be5b7125..f7ebf0407c 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -75,10 +75,6 @@ path = "../../src/firestore" package = "google-cloud-secretmanager-v1" path = "../../src/generated/cloud/secretmanager/v1" -[dependencies.smo] -package = "secretmanager-openapi-v1" -path = "../../src/generated/openapi-validation" - [dependencies.storage] package = "google-cloud-storage" path = "../../src/storage" diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 4bba302939..525f79e905 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -26,8 +26,6 @@ pub mod secret_manager; pub mod storage; pub mod workflows; -pub const SECRET_ID_LENGTH: usize = 64; - pub const VM_ID_LENGTH: usize = 63; pub fn report_error(e: anyhow::Error) -> anyhow::Error { diff --git a/tests/integration/src/secret_manager.rs b/tests/integration/src/secret_manager.rs index b468851206..f4b0ec9bd7 100644 --- a/tests/integration/src/secret_manager.rs +++ b/tests/integration/src/secret_manager.rs @@ -12,6 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub mod openapi; -pub mod openapi_locational; pub mod protobuf; diff --git a/tests/integration/src/secret_manager/protobuf.rs b/tests/integration/src/secret_manager/protobuf.rs index 29e4bec0f3..daf1be9f37 100644 --- a/tests/integration/src/secret_manager/protobuf.rs +++ b/tests/integration/src/secret_manager/protobuf.rs @@ -14,16 +14,12 @@ use crate::Result; use gax::paginator::{ItemPaginator, Paginator}; +use google_cloud_test_utils::resource_names::random_secret_id; use google_cloud_test_utils::runtime_config::{project_id, test_service_account}; -use rand::{Rng, distr::Alphanumeric}; pub async fn run(builder: sm::builder::secret_manager_service::ClientBuilder) -> Result<()> { let project_id = project_id()?; - let secret_id: String = rand::rng() - .sample_iter(&Alphanumeric) - .take(crate::SECRET_ID_LENGTH) - .map(char::from) - .collect(); + let secret_id = random_secret_id(); let client = builder.build().await?; cleanup_stale_secrets(&client, &project_id, &secret_id).await?; diff --git a/tests/integration/tests/driver.rs b/tests/integration/tests/driver.rs index 23e12b846e..402fd65aba 100644 --- a/tests/integration/tests/driver.rs +++ b/tests/integration/tests/driver.rs @@ -129,22 +129,6 @@ mod driver { .map_err(integration_tests::report_error) } - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn run_secretmanager_openapi() -> integration_tests::Result<()> { - let _guard = enable_tracing(); - integration_tests::secret_manager::openapi::run() - .await - .map_err(integration_tests::report_error) - } - - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn run_secretmanager_openapi_locational() -> integration_tests::Result<()> { - let _guard = enable_tracing(); - integration_tests::secret_manager::openapi_locational::run() - .await - .map_err(integration_tests::report_error) - } - #[test_case(StorageControl::builder().with_tracing().with_retry_policy(retry_policy()); "with tracing and retry enabled")] #[test_case(StorageControl::builder().with_endpoint("https://www.googleapis.com"); "with global endpoint")] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] diff --git a/tests/integration/tests/serialization.rs b/tests/integration/tests/serialization.rs index 15eb0efec5..468cab4616 100644 --- a/tests/integration/tests/serialization.rs +++ b/tests/integration/tests/serialization.rs @@ -17,23 +17,6 @@ #[cfg(test)] mod serialization { use anyhow::Result; - use static_assertions::{assert_impl_all, assert_not_impl_any}; - - // The generator introduces synthetic messages for the requests in - // OpenAPI-based services. Those should not have serialization or - // deserialization functions. - #[test] - fn synthetic_message_serialization() -> Result<()> { - use smo::model::{Secret, secret_manager_service::CreateSecretRequest}; - - assert_impl_all!(CreateSecretRequest: std::fmt::Debug); - assert_not_impl_any!(CreateSecretRequest: serde::Serialize); - assert_not_impl_any!(CreateSecretRequest: serde::de::DeserializeOwned); - assert_impl_all!(Secret: std::fmt::Debug); - assert_impl_all!(Secret: serde::Serialize); - assert_impl_all!(Secret: serde::de::DeserializeOwned); - Ok(()) - } #[test] fn multiple_serde_attributes() -> Result<()> { diff --git a/tests/openapi/Cargo.toml b/tests/openapi/Cargo.toml new file mode 100644 index 0000000000..4c4dce0b92 --- /dev/null +++ b/tests/openapi/Cargo.toml @@ -0,0 +1,49 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[package] +description = "Integration tests for an OpenAPI-based service." +edition.workspace = true +name = "integration-tests-openapi" +publish = false +version = "0.0.0" + +[features] +# These are normally disabled because they run against production. +run-integration-tests = [] +# Enable additional logging in the integration tests. +log-integration-tests = ["google-cloud-test-utils/log-integration-tests"] + +[dependencies] +anyhow.workspace = true +bytes.workspace = true +chrono = { workspace = true, features = ["now"] } +crc32c.workspace = true +futures.workspace = true +google-cloud-gax.workspace = true +google-cloud-lro.workspace = true +google-cloud-test-utils = { workspace = true } +google-cloud-wkt.workspace = true +secretmanager-openapi-v1 = { workspace = true, features = ["default"] } +serde.workspace = true +tokio.workspace = true +tracing.workspace = true +tracing-subscriber = { workspace = true, features = ["fmt"] } + +[dev-dependencies] +static_assertions.workspace = true +test-case.workspace = true + +[lints] +workspace = true diff --git a/tests/openapi/README.md b/tests/openapi/README.md new file mode 100644 index 0000000000..27e63110e4 --- /dev/null +++ b/tests/openapi/README.md @@ -0,0 +1,17 @@ +# Integration tests for an OpenAPI-based client + +[Sidekick] supports multiple different specification formats, including OpenAPI. +This directory contains integration tests for one client generated from an +OpenAPI specification. + +We use the [Secret Manager] service and client in these tests as: + +- Secret Manager does not have very restrictive quota requirements. +- Secret Manager uses many different field types, including maps, bytes an anys. +- Secret Manager has pagination methods, some mixins, and regional endpoints. + +The one large gap is LROs, but it is unclear how LROs will work for OpenAPI in +the first place. + +[secret manager]: https://docs.cloud.google.com/secret-manager/docs +[sidekick]: https://github.com/googleapis/librarian diff --git a/tests/integration/src/secret_manager/openapi.rs b/tests/openapi/src/global.rs similarity index 86% rename from tests/integration/src/secret_manager/openapi.rs rename to tests/openapi/src/global.rs index 533bf9217b..196987242d 100644 --- a/tests/integration/src/secret_manager/openapi.rs +++ b/tests/openapi/src/global.rs @@ -12,20 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::Result; -use gax::paginator::Paginator; +use anyhow::Result; +use google_cloud_gax::paginator::Paginator; +use google_cloud_test_utils::resource_names::random_secret_id; use google_cloud_test_utils::runtime_config::{project_id, test_service_account}; -use rand::{Rng, distr::Alphanumeric}; +use google_cloud_wkt::FieldMask; +use secretmanager_openapi_v1::client::SecretManagerService; +use secretmanager_openapi_v1::model::{ + AddSecretVersionRequest, Automatic, Binding, Replication, Secret, SecretPayload, + SetIamPolicyRequest, TestIamPermissionsRequest, +}; pub async fn run() -> Result<()> { let project_id = project_id()?; - let secret_id: String = rand::rng() - .sample_iter(&Alphanumeric) - .take(crate::SECRET_ID_LENGTH) - .map(char::from) - .collect(); + let secret_id = random_secret_id(); - let client = smo::client::SecretManagerService::builder() + let client = SecretManagerService::builder() .with_tracing() .build() .await?; @@ -36,10 +38,8 @@ pub async fn run() -> Result<()> { .set_project(&project_id) .set_secret_id(&secret_id) .set_body( - smo::model::Secret::new() - .set_replication( - smo::model::Replication::new().set_automatic(smo::model::Automatic::new()), - ) + Secret::new() + .set_replication(Replication::new().set_automatic(Automatic::new())) .set_labels([("integration-test", "true")]), ) .send() @@ -72,8 +72,8 @@ pub async fn run() -> Result<()> { .update_secret() .set_project(&project_id) .set_secret(&secret_id) - .set_update_mask(wkt::FieldMask::default().set_paths(["labels"])) - .set_body(smo::model::Secret::new().set_labels(new_labels)) + .set_update_mask(FieldMask::default().set_paths(["labels"])) + .set_body(Secret::new().set_labels(new_labels)) .send() .await?; println!("UPDATE = {update:?}"); @@ -101,7 +101,7 @@ pub async fn run() -> Result<()> { Ok(()) } -async fn run_locations(client: &smo::client::SecretManagerService, project_id: &str) -> Result<()> { +async fn run_locations(client: &SecretManagerService, project_id: &str) -> Result<()> { println!("\nTesting list_locations()"); let locations = client .list_locations() @@ -134,11 +134,7 @@ async fn run_locations(client: &smo::client::SecretManagerService, project_id: & Ok(()) } -async fn run_iam( - client: &smo::client::SecretManagerService, - project_id: &str, - secret_id: &str, -) -> Result<()> { +async fn run_iam(client: &SecretManagerService, project_id: &str, secret_id: &str) -> Result<()> { let service_account = test_service_account()?; println!("\nTesting get_iam_policy()"); @@ -156,8 +152,7 @@ async fn run_iam( .set_project(project_id) .set_secret(secret_id) .set_body( - smo::model::TestIamPermissionsRequest::new() - .set_permissions(["secretmanager.versions.access"]), + TestIamPermissionsRequest::new().set_permissions(["secretmanager.versions.access"]), ) .send() .await?; @@ -179,7 +174,7 @@ async fn run_iam( } if !found { new_policy.bindings.push( - smo::model::Binding::new() + Binding::new() .set_role(ROLE.to_string()) .set_members([format!("serviceAccount:{service_account}")]), ); @@ -189,8 +184,8 @@ async fn run_iam( .set_project(project_id) .set_secret(secret_id) .set_body( - smo::model::SetIamPolicyRequest::new() - .set_update_mask(wkt::FieldMask::default().set_paths(["bindings"])) + SetIamPolicyRequest::new() + .set_update_mask(FieldMask::default().set_paths(["bindings"])) .set_policy(new_policy), ) .send() @@ -201,7 +196,7 @@ async fn run_iam( } async fn run_secret_versions( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, secret_id: &str, ) -> Result<()> { @@ -213,8 +208,8 @@ async fn run_secret_versions( .set_project(project_id) .set_secret(secret_id) .set_body( - smo::model::AddSecretVersionRequest::new().set_payload( - smo::model::SecretPayload::new() + AddSecretVersionRequest::new().set_payload( + SecretPayload::new() .set_data(bytes::Bytes::from(data)) .set_data_crc_32_c(checksum as i64), ), @@ -306,7 +301,7 @@ async fn run_secret_versions( } async fn get_all_secret_version_names( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, secret_id: &str, ) -> Result> { @@ -334,7 +329,7 @@ async fn get_all_secret_version_names( } async fn get_all_secret_names( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, ) -> Result> { let mut names = Vec::new(); diff --git a/tests/openapi/src/lib.rs b/tests/openapi/src/lib.rs new file mode 100644 index 0000000000..4a6433bda9 --- /dev/null +++ b/tests/openapi/src/lib.rs @@ -0,0 +1,35 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod global; +pub mod locational; + +#[cfg(test)] +mod tests { + use secretmanager_openapi_v1::model::{Secret, secret_manager_service::CreateSecretRequest}; + use static_assertions::{assert_impl_all, assert_not_impl_any}; + + // The generator introduces synthetic messages for the requests in + // OpenAPI-based services. Those should not have serialization or + // deserialization functions. + #[test] + fn synthetic_message_serialization() { + assert_impl_all!(CreateSecretRequest: std::fmt::Debug); + assert_not_impl_any!(CreateSecretRequest: serde::Serialize); + assert_not_impl_any!(CreateSecretRequest: serde::de::DeserializeOwned); + assert_impl_all!(Secret: std::fmt::Debug); + assert_impl_all!(Secret: serde::Serialize); + assert_impl_all!(Secret: serde::de::DeserializeOwned); + } +} diff --git a/tests/integration/src/secret_manager/openapi_locational.rs b/tests/openapi/src/locational.rs similarity index 91% rename from tests/integration/src/secret_manager/openapi_locational.rs rename to tests/openapi/src/locational.rs index 8a08b1eb87..84ae7e2651 100644 --- a/tests/integration/src/secret_manager/openapi_locational.rs +++ b/tests/openapi/src/locational.rs @@ -12,24 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::Result; +use anyhow::Result; use anyhow::anyhow; -use gax::options::RequestOptionsBuilder; +use google_cloud_gax::options::RequestOptionsBuilder; +use google_cloud_test_utils::resource_names::random_secret_id; use google_cloud_test_utils::runtime_config::{project_id, test_service_account}; -use rand::{Rng, distr::Alphanumeric}; +use google_cloud_wkt::{FieldMask, Timestamp}; +use secretmanager_openapi_v1::client::SecretManagerService; +use secretmanager_openapi_v1::model::{ + AddSecretVersionRequest, Binding, Secret, SecretPayload, SetIamPolicyRequest, + TestIamPermissionsRequest, +}; pub async fn run() -> Result<()> { let project_id = project_id()?; - let secret_id: String = rand::rng() - .sample_iter(&Alphanumeric) - .take(crate::SECRET_ID_LENGTH) - .map(char::from) - .collect(); + let secret_id = random_secret_id(); // We must override the configuration to use a regional endpoint. let location_id = "us-central1".to_string(); let endpoint = format!("https://secretmanager.{location_id}.rep.googleapis.com"); - let client = smo::client::SecretManagerService::builder() + let client = SecretManagerService::builder() .with_tracing() .with_endpoint(endpoint) .build() @@ -43,7 +45,7 @@ pub async fn run() -> Result<()> { .set_project(&project_id) .set_location(&location_id) .set_secret_id(&secret_id) - .set_body(smo::model::Secret::new().set_labels([("integration-test", "true")])) + .set_body(Secret::new().set_labels([("integration-test", "true")])) .with_idempotency(true) .send() .await?; @@ -64,7 +66,7 @@ pub async fn run() -> Result<()> { println!("\nTesting update_secret_by_project_and_location_and_secret()"); let mut new_labels = get.labels.clone(); new_labels.insert("updated".to_string(), "true".to_string()); - let mut body = smo::model::Secret::new().set_labels(new_labels); + let mut body = Secret::new().set_labels(new_labels); if let Some(etag) = &get.etag { body = body.set_etag(etag); } @@ -73,7 +75,7 @@ pub async fn run() -> Result<()> { .set_project(&project_id) .set_location(&location_id) .set_secret(&secret_id) - .set_update_mask(wkt::FieldMask::default().set_paths(["labels"])) + .set_update_mask(FieldMask::default().set_paths(["labels"])) .set_body(body) .with_idempotency(true) .send() @@ -108,7 +110,7 @@ pub async fn run() -> Result<()> { } async fn run_iam( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, location_id: &str, secret_id: &str, @@ -132,8 +134,7 @@ async fn run_iam( .set_location(location_id) .set_secret(secret_id) .set_body( - smo::model::TestIamPermissionsRequest::new() - .set_permissions(["secretmanager.versions.access"]), + TestIamPermissionsRequest::new().set_permissions(["secretmanager.versions.access"]), ) .with_idempotency(true) .send() @@ -156,7 +157,7 @@ async fn run_iam( } if !found { new_policy.bindings.push( - smo::model::Binding::new() + Binding::new() .set_role(ROLE.to_string()) .set_members([format!("serviceAccount:{service_account}")]), ); @@ -167,8 +168,8 @@ async fn run_iam( .set_location(location_id) .set_secret(secret_id) .set_body( - smo::model::SetIamPolicyRequest::new() - .set_update_mask(wkt::FieldMask::default().set_paths(["bindings"])) + SetIamPolicyRequest::new() + .set_update_mask(FieldMask::default().set_paths(["bindings"])) .set_policy(new_policy), ) .with_idempotency(true) @@ -180,7 +181,7 @@ async fn run_iam( } async fn run_secret_versions( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, location_id: &str, secret_id: &str, @@ -194,8 +195,8 @@ async fn run_secret_versions( .set_location(location_id) .set_secret(secret_id) .set_body( - smo::model::AddSecretVersionRequest::new().set_payload( - smo::model::SecretPayload::default() + AddSecretVersionRequest::new().set_payload( + SecretPayload::default() .set_data(bytes::Bytes::from(data)) .set_data_crc_32_c(checksum as i64), ), @@ -297,7 +298,7 @@ async fn run_secret_versions( } async fn get_all_secret_version_names( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, location_id: &str, secret_id: &str, @@ -327,7 +328,7 @@ async fn get_all_secret_version_names( } async fn get_all_secret_names( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, location_id: &str, ) -> Result> { @@ -355,14 +356,14 @@ async fn get_all_secret_names( } async fn cleanup_stale_secrets( - client: &smo::client::SecretManagerService, + client: &SecretManagerService, project_id: &str, location_id: &str, ) -> Result<()> { use std::time::{Duration, SystemTime, UNIX_EPOCH}; let stale_deadline = SystemTime::now().duration_since(UNIX_EPOCH)?; let stale_deadline = stale_deadline - Duration::from_secs(48 * 60 * 60); - let stale_deadline = wkt::Timestamp::clamp(stale_deadline.as_secs() as i64, 0); + let stale_deadline = Timestamp::clamp(stale_deadline.as_secs() as i64, 0); let mut stale_secrets = Vec::new(); let mut page_token = None::; diff --git a/tests/openapi/tests/driver.rs b/tests/openapi/tests/driver.rs new file mode 100644 index 0000000000..07030d67b0 --- /dev/null +++ b/tests/openapi/tests/driver.rs @@ -0,0 +1,30 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(all(test, feature = "run-integration-tests"))] +mod openapi { + use google_cloud_test_utils::tracing::enable_tracing; + + #[tokio::test(flavor = "multi_thread")] + async fn run_global() -> anyhow::Result<()> { + let _guard = enable_tracing(); + integration_tests_openapi::global::run().await + } + + #[tokio::test(flavor = "multi_thread")] + async fn run_locational() -> anyhow::Result<()> { + let _guard = enable_tracing(); + integration_tests_openapi::locational::run().await + } +} From 6101a8e52df8d696b659fab45288870ea60f9e9b Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Wed, 28 Jan 2026 16:46:01 -0500 Subject: [PATCH 2/2] Ooops, testing the wrong thing --- src/test-utils/src/resource_names.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test-utils/src/resource_names.rs b/src/test-utils/src/resource_names.rs index b81cd66b1b..9d3e722f2e 100644 --- a/src/test-utils/src/resource_names.rs +++ b/src/test-utils/src/resource_names.rs @@ -141,7 +141,7 @@ mod tests { "{PREFIX} length ({}) should be smaller than {SECRET_ID_LENGTH}", PREFIX.len() ); - let got = random_workflow_id(); + let got = random_secret_id(); assert!( got.len() <= SECRET_ID_LENGTH, "{got} has more than {SECRET_ID_LENGTH} characters"