Repository navigation
feat(storagecontrol): add Rapid Cache samples - #2343
Conversation
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]
There was a problem hiding this comment.
Code Review
This pull request updates the google/cloud-storage-control dependency and introduces new PHP code samples for managing the lifecycle of Rapid Cache instances, including creation, retrieval, listing, updating, and disabling. It also adds a comprehensive integration test suite. The feedback highlights a PSR-1/PSR-12 style guide violation regarding the test class name casing, and suggests guarding against a potential null pointer dereference in the update sample when retrieving the TTL from the response.
…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]
- Rename rapidCacheTest to RapidCacheTest (PSR-1 StudlyCaps). - Guard TTL output with hasTtl() in update_rapid_cache. [Generated-by: AI]
…lify 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]
|
Here is the summary of changes. You are about to add 5 region tags.
This comment is generated by snippet-bot.
|
…cache-samples-php
Adds Storage Control samples for Rapid Cache, plus a test:
create_rapid_cache.php(storage_control_create_rapid_cache): creates arapid-cache-ultracache in a zone and waits for the LRO to finish. The server assigns the cache name.get_rapid_cache.php(storage_control_get_rapid_cache)list_rapid_caches.php(storage_control_list_rapid_caches)update_rapid_cache.php(storage_control_update_rapid_cache): sets the TTL with update maskttl.disable_rapid_cache.php(storage_control_disable_rapid_cache): starts the disable LRO and prints the operation name. It does not wait, because the operation runs for more than an hour.test/rapidCacheTest.php: runs the whole lifecycle on a regional HNS + UBLA bucket, then pollsgetuntil the state isdisabled. Bucket deletion fails with 409 for a long time after a cache is disabled, so cleanup is best-effort: it retries briefly, then logs the name of any bucket it left behind.google/cloud-storage-controlto^1.12, which has the RapidCache API.b/482946642
Validation: php-cs-fixer and PHPStan both pass. The live test has not been run yet. Rapid Cache RPCs work only over gRPC, and the authoring environment has no
ext-grpc. CI does have it.[Generated-by: AI]
Update: aligned with googleapis/google-cloud-java#14529
The samples now follow the reference integration test (
ITRapidCacheTest). Where this section conflicts with the notes above, this section is current.projects/_/buckets/{bucket}/rapidCaches/{zone}(the backend requires the cache ID to equal the zone), withcache_typerapid-cache-ultraandttl86400s (24h). It also prints the state.totalPollTimeoutMillis0). Before, they used the 5-minute client default. If the operation fails, they print the error.$timeoutMillisargument (default 0 = no limit) bounds the wait. If the wait times out, the sample prints that the operation is still running. If the operation fails, it prints the error.State: running, the cache type, list membership, and TTL 172800s after update.getshowsState: disabledand does not fail.Validation:
php -l, php-cs-fixer (repo config), and PHPStan (repo config) all pass. The live test was not run locally becauseext-grpcis missing in the authoring environment.[Generated-by: AI]