Repository navigation
test(storage): Add integration tests for Storage Control RapidCache CRUD APIs - #14529
Conversation
…RUD APIs Adds integration tests for Storage Control RapidCache CRUD operations in ITRapidCacheTest.java. [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request introduces a new integration test class, ITRapidCacheTest, to verify the CRUD lifecycle and negative scenarios for the Storage Control RapidCache API. The review feedback highlights an improvement opportunity in the creation retry logic of rapidCache_crudLifecycle; instead of repeatedly calling the asynchronous creation API, which can cause rate limiting or unexpected backend behavior, the test should call it once and poll the get API until the resource is active.
Resolve review feedback on RapidCache CRUD lifecycle test by invoking createRapidCacheAsync once and polling getRapidCache until active. [Generated-by: AI]
Remove temporary workarounds for b/564257939 in ITRapidCacheTest: - Remove retry and polling workaround on createRapidCacheAsync in rapidCache_crudLifecycle - Directly assert ExecutionException with cause ApiException(ALREADY_EXISTS) on duplicate cache creation - Directly assert ApiException(INVALID_ARGUMENT) on invalid cache configuration [Generated-by: AI]
…ndle unimplemented disable - Split rapidCache_crudLifecycle into independent @test methods - Share bucket and cache created in setUpClass across read-only tests - Isolate createAndDisableRapidCache in a dedicated bucket with clean cleanup - Gracefully handle UNIMPLEMENTED for DisableRapidCache via logging and Assume - Add disableRapidCache_nonExistent negative test for full parity with C++ PR 16512 - Gracefully catch exceptions during tearDownClass cleanup [Generated-by: AI]
There was a problem hiding this comment.
I noticed we are using a Thread.sleep(20000) here to wait for the bucket metadata to propagate. Out of curiosity, how was the 20-second value chosen?
There was a problem hiding this comment.
The 20-second delay was chosen empirically during integration testing due to cross-service metadata propagation.
The bucket is created via the standard Storage client, while RapidCache is provisioned via the separate Storage Control plane service (StorageControlClient). Because it takes a few seconds for newly created bucket metadata and its HNS configuration to propagate to the Control plane backends, attempting cache creation too quickly caused the service to throw FAILED_PRECONDITION (the bucket is not yet recognized as HNS-enabled) or UNAVAILABLE. A 20-second wait reliably ensures the metadata has settled across services, preventing test flakiness.
Co-authored by AI Agent
…pidCacheTest Accommodate the current production DisableRapidCache LRO response where DisableRapidCacheOpTypeHandler::GetOperationResponse returns a default AnywhereCacheInstance (translating to name prefix 'projects/_/buckets/<bucket>/rapidCaches/' and state 'anywhere-cache-state-unspecified') until CL 990396263 rolls out. [Generated-by: AI]
Dhriti07
left a comment
There was a problem hiding this comment.
Nit: Use Locale.ROOT with toLowerCase()
…ation test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
…ation test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; the auto-run asserts running state, cache type, list membership and the updated ttl, and bounds the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
…ration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with #14529. b/482946642 [Generated-by: AI]
Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
…CU is in prod Co-authored-by: Gemini CLI <[email protected]> [Generated-by: AI]
|
Updated all Co-authored by AI Agent |
* feat(storagecontrol): add Rapid Cache samples Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with tests. Bumps google/cloud-storage-control to ^1.12. b/482946642 [Generated-by: AI] * docs(storagecontrol): align rapid cache samples with reference integration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI] * fix(storagecontrol): resolve PR comments for rapid cache samples - Rename rapidCacheTest to RapidCacheTest (PSR-1 StudlyCaps). - Guard TTL output with hasTtl() in update_rapid_cache. [Generated-by: AI] * fix(storagecontrol): drop TTL from rapid cache create sample and simplify test teardown - create_rapid_cache: set only name, zone and cache type (rapid-cache-ultra), matching create_anywhere_cache; TTL is left to update_rapid_cache. - create_rapid_cache: use $rapidCacheId, consistent with get/update/disable. - RapidCacheTest: rename $cacheDisabled to $cacheActive, flatten tearDownAfterClass into disableCacheQuietly/deleteBucketQuietly helpers, and use a constant for the updated TTL. [Generated-by: AI] --------- Co-authored-by: Brent Shaffer <[email protected]>
* feat(storage): add Storage Control Rapid Cache samples Adds samples for the Storage Control Rapid Cache CRUD APIs: storage_control_create_rapid_cache, storage_control_get_rapid_cache, storage_control_list_rapid_caches, storage_control_update_rapid_cache, storage_control_disable_rapid_cache. Refs b/482946642 [Generated-by: AI] * docs(storage): align rapid cache samples with reference integration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI] * fix(storage): retry rapid cache test bucket cleanup on any error Retry bucket deletion on any non-404 error until the cleanup deadline, addressing review feedback. [Generated-by: AI] * refactor(storage): drop TTL from rapid cache create sample Set only the required fields (name, zone, cache type) when creating a Rapid Cache, matching the Anywhere Cache create sample. The TTL is left at its default and is set by the update sample. Use a cacheID variable consistent with the get/update samples, and rename the test flag to the positive cacheActive, clearing it only once the cache is confirmed disabled. [Generated-by: AI] * fix(storage): don't wait for rapid cache disable operation The DisableRapidCache operation only completes once the cache is fully removed, which can take more than an hour, while the cache state changes to disabled within seconds. The disable sample now only starts the operation and creates its own context like the other samples. The test checks the cache state with getRapidCache, and cleanup sends the disable request directly. [Generated-by: AI] * feat(storage): print TTL in get rapid cache sample [Generated-by: AI]
Adds Storage Control samples for Rapid Cache: create, get, list, update
(TTL through a `FieldMask`), and disable.
Region tags:
- `storage_control_create_rapid_cache`
- `storage_control_get_rapid_cache`
- `storage_control_list_rapid_caches`
- `storage_control_update_rapid_cache`
- `storage_control_disable_rapid_cache`
Notes:
- `create` uses `cache_type = "rapid-cache-ultra"` and does not set a
name. The service assigns the cache ID, so the driver finds it by
listing caches and parsing the name.
- `disable` starts the long-running operation and does not wait for it.
The cache reaches the `disabled` state within seconds, but the operation
only completes once the cache is fully removed, which can take more than
30 minutes. The driver polls `get_rapid_cache` until the state is
`disabled`.
- Unlike the Anywhere Cache samples, these samples print specific fields
instead of `{:?}`, to match the samples in other languages.
- The test bucket is a regional HNS + UBLA bucket in the region of
`GOOGLE_CLOUD_RUST_TEST_ZONE` (default `us-central1-a`).
- The new `rapid_cache_examples` integration test is gated behind
`skipped-integration-tests`, like the Anywhere Cache examples.
- Bucket cleanup is best-effort. Deleting the bucket returns
`FAILED_PRECONDITION` ("The bucket you tried to delete has Rapid Cache
Ultra") for a long time after the cache is disabled. The test retries
for about 2 minutes, then leaves the bucket for the stale bucket
cleanup, which now also disables rapid caches.
- The API is in the released `google-cloud-storage` 1.21.0.
Testing: `cargo fmt --check` and `cargo clippy --all-targets
--all-features -- --deny warnings` pass. I also ran the full integration
test once against a live project:
cargo test -p storage-samples --features
run-integration-tests,skipped-integration-tests --test integration
rapid_cache_examples
Internal bug: b/482946642
## Update: aligned with googleapis/google-cloud-java#14529
The samples and the test now follow the reference integration test
(`ITRapidCacheTest.java`). This replaces the `create` and `disable`
notes above.
- `create`: sets the cache name explicitly
(`projects/_/buckets/{bucket}/rapidCaches/{zone}`; the backend requires
the cache ID to equal the zone), with `cache_type = "rapid-cache-ultra"`
and a 24h TTL (86400s).
- `disable`: now waits for the long-running operation with
`.poller().until_done()` instead of returning right away.
- Driver: waits 20s after the bucket is created, uses `cache_id = zone`
(no more listing to find the service-assigned ID), and checks that the
cache is `running` with the right cache type after create, that list
returns it, and that the TTL is 172800s after update.
- Driver: wraps the disable sample in `tokio::time::timeout(600s)`. If
it times out, it calls `get_rapid_cache` and accepts the `disabled`
state, so the test never hangs.
Testing: `cargo fmt --check`, `cargo clippy -p storage-samples
--all-targets --all-features -- --deny warnings`, and one live run of
`rapid_cache_examples` (passed; the disable operation hit the 600s
timeout and the cache state was `disabled`).
* feat(storagecontrol): add Rapid Cache samples Adds samples for the Storage Control Rapid Cache CRUD APIs: storage_control_create_rapid_cache, storage_control_get_rapid_cache, storage_control_list_rapid_caches, storage_control_update_rapid_cache, storage_control_disable_rapid_cache. Bumps google-cloud-storage-control to 1.17.0. Refs b/482946642 [Generated-by: AI] * docs(storage): align rapid cache samples with reference integration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI] * fix(storagecontrol): resolve flake8 import-order lint failures Reorder imports in storagecontrol/conftest.py and storagecontrol/rapid_cache_test.py to match the repository-root flake8-import-order configuration used by the GitHub Actions Lint workflow. [Generated-by: AI] * fix(storagecontrol): address rapid cache sample review comments - create_rapid_cache: set only the required fields (name, zone, cache_type) and leave TTL to the update sample; use a cache_id variable consistent with get/update. - tests: move cleanup into a rapid_cache_id fixture that disables the cache on teardown if it is still active, so cleanup runs even when assertions fail; keep the test flow linear without nested try/except/finally; bound the disable wait with the native operation timeout. - disable_rapid_cache: document that the operation completes only after the cache is fully removed. [Generated-by: AI] * fix(storagecontrol): address Rapid Cache sample review feedback - disable_rapid_cache: start the LRO without waiting; print the cache path and operation name and point users to get_rapid_cache. - create_rapid_cache: drop the unused RapidCache.name; note that Rapid Cache Ultra requires a regional HNS bucket. - get_rapid_cache: print the TTL when set. - Soften cache ID comments; the ID is not guaranteed to equal the zone. - rapid_cache_test: opt-in via RUN_RAPID_CACHE_TESTS=True; assert the disable output and tolerate NotFound when checking the disabled state. - conftest: validate RAPID_CACHE_ZONE, remove the 20s sleep, use a single best-effort bucket delete, and disable caches by name on teardown. [Generated-by: AI]
* docs(storagecontrol): add Rapid Cache samples Adds samples for the Storage Control Rapid Cache CRUD APIs: storage_control_create_rapid_cache, storage_control_get_rapid_cache, storage_control_list_rapid_caches, storage_control_update_rapid_cache, storage_control_disable_rapid_cache. Refs b/482946642 [Generated-by: AI] * docs(storagecontrol): align rapid cache samples with reference integration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; the auto-run asserts running state, cache type, list membership and the updated ttl, and bounds the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI] * docs(storagecontrol): use explicit types in rapid cache samples Replace auto with explicit StatusOr<RapidCache>, std::optional, bool and std::string types, as required by the repository style guide. [Generated-by: AI] * docs(storagecontrol): drop TTL from rapid cache create sample The create sample now only sets the name, zone and cache type, like the Anywhere Cache create sample. The TTL is set by the update sample. The create sample names the ID cache_id, like get and update. The auto-run always disables the cache it created (linear flow, no nested try/catch), bounds the disable wait with the native polling policy instead of a sleep loop, and only accepts a DEADLINE_EXCEEDED timeout. The disable sample comment explains that the operation completes only once the cache is removed. b/482946642 [Generated-by: AI] * docs(storagecontrol): avoid unnecessary copy in rapid cache sample Bind cache_id by const reference to zone_name in CreateRapidCache() to satisfy clang-tidy performance-unnecessary-copy-initialization. [Generated-by: AI] * docs(storagecontrol): do not wait for rapid cache removal in disable sample Start DisableRapidCache with NoAwaitTag and print the operation name. The cache moves to the disabled state in seconds, but the operation only completes once the cache is fully removed, which can take over an hour. AutoRun now polls GetRapidCache for the disabled state instead. Require GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_BUCKET_NAME via CheckEnvironmentVariablesAreSet() instead of silently skipping, and soften the wording about the cache ID matching the zone. [Generated-by: AI]
* samples(storage-control): add Rapid Cache samples Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with an acceptance test gated by STORAGE_CONTROL_RUN_RAPID_CACHE_TESTS. b/482946642 [Generated-by: AI] * docs(storage-control): align rapid cache samples with reference integration test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI] * docs(storage-control): drop TTL from rapid cache create sample and simplify test teardown Create sets only name, zone and cache_type, matching the Anywhere Cache create sample; TTL is left to UpdateRapidCache. Rename the create ID variable to cache_id. The acceptance test now runs linearly and disables the cache in after(:all) if it is still active, and the disable sample reports an in-progress operation on timeout instead of raising. [Generated-by: AI] * docs(storage-control): don't wait on rapid cache disable LRO and print TTL The DisableRapidCache operation only completes once the cache has been fully removed, which can take over an hour, while the cache state becomes "disabled" within seconds. The disable sample now starts the operation and prints its name instead of polling it, and the acceptance test polls the cache state directly. The get sample now also prints the TTL. [Generated-by: AI]
Description
Adds integration tests for Rapid Cache Ultra (RCU) control plane operations (
ITRapidCacheTest.java) using theStorageControlClient.Scope & Operations Tested
ALREADY_EXISTSor expected service error).running).@AfterClass.Verification
google-java-format.mvn test-compile -Dtest=ITRapidCacheTest.assertThrowsand Google Truth.[Generated-by: AI]