Skip to content

feat(storagecontrol): add rapid cache samples and integration tests - #16512

Draft
kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feat/rcu-tests
Draft

kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feat/rcu-tests

Conversation

@kalragauri

Copy link
Copy Markdown
Contributor

No description provided.

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Sep 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces integration tests and code samples for the Rapid Cache Ultra feature, along with the necessary CI and build configuration updates. The review feedback highlights several violations of the repository's style guide, primarily concerning the over-use of auto where explicit types (such as StatusOr<T> or primitives) are required, as well as a case of swallowing a potential error during bucket listing instead of handling it explicitly.

auto constexpr kStaleBucketAge = std::chrono::hours(48);

// Deleting a bucket may fail for a short time after its cache is disabled.
auto constexpr kDeleteBucketAttempts = 5;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should disallow auto for primitives and require explicit numeric and scalar types rather than deducing them from literals. Please use int instead of auto.

int constexpr kDeleteBucketAttempts = 5;
References
  1. Disallow auto for Primitives: Require explicit numeric and scalar types (std::size_t, std::int64_t, bool, etc.) rather than deducing them from literals. (link)

std::make_unique<StorageControlClient>(MakeStorageControlConnection());
RemoveStaleRapidCacheBuckets();

auto bucket = CreateRapidCacheBucket();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type StatusOr<std::string> instead of auto.

    StatusOr<std::string> bucket = CreateRapidCacheBucket();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +157 to +163
auto metadata = MakeBucketIntegrationTestClient().CreateBucketForProject(
name, project_id_,
BucketMetadata()
.set_location(region_name_)
.set_hierarchical_namespace(BucketHierarchicalNamespace{true})
.set_iam_configuration(BucketIamConfiguration{
UniformBucketLevelAccess{true, {}}, std::nullopt}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type StatusOr<BucketMetadata> instead of auto.

    StatusOr<BucketMetadata> metadata =
        MakeBucketIntegrationTestClient().CreateBucketForProject(
            name, project_id_,
            BucketMetadata()
                .set_location(region_name_)
                .set_hierarchical_namespace(BucketHierarchicalNamespace{true})
                .set_iam_configuration(BucketIamConfiguration{
                    UniformBucketLevelAccess{true, {}}, std::nullopt}));
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

return;
}
}
auto client = MakeBucketIntegrationTestClient();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides domain objects or function return types. Please use the explicit type Client instead of auto.

    Client client = MakeBucketIntegrationTestClient();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +220 to +221
for (auto& bucket :
MakeBucketIntegrationTestClient().ListBucketsForProject(project_id_)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type StatusOr<BucketMetadata> const& instead of auto& to avoid hiding the type and to prevent unnecessary copies.

    for (StatusOr<BucketMetadata> const& bucket :
         MakeBucketIntegrationTestClient().ListBucketsForProject(project_id_)) {
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

cache.mutable_ttl()->set_seconds(86400); // 24 hours

auto const parent = "projects/_/buckets/" + bucket_name;
auto operation = client.CreateRapidCache(parent, cache).get();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type google::cloud::StatusOr<google::storage::control::v2::RapidCache> instead of auto.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        operation = client.CreateRapidCache(parent, cache).get();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

namespace storagecontrol = google::cloud::storagecontrol_v2;
[](storagecontrol::StorageControlClient client,
std::string const& cache_name) {
auto cache = client.GetRapidCache(cache_name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type google::cloud::StatusOr<google::storage::control::v2::RapidCache> instead of auto.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache> cache =
        client.GetRapidCache(cache_name);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

[](storagecontrol::StorageControlClient client,
std::string const& bucket_name) {
auto const parent = std::string{"projects/_/buckets/"} + bucket_name;
for (auto cache : client.ListRapidCaches(parent)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Also, using auto without reference qualifiers causes unnecessary copies of non-fundamental types. Please use the explicit type google::cloud::StatusOr<google::storage::control::v2::RapidCache> const& instead of auto.

    for (google::cloud::StatusOr<google::storage::control::v2::RapidCache> const&
             cache : client.ListRapidCaches(parent)) {
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

cache.set_name(cache_name);
cache.mutable_ttl()->set_seconds(172800); // 48 hours

auto operation = client.UpdateRapidCache(cache, field_mask).get();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type google::cloud::StatusOr<google::storage::control::v2::RapidCache> instead of auto.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        operation = client.UpdateRapidCache(cache, field_mask).get();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

namespace storagecontrol = google::cloud::storagecontrol_v2;
[](storagecontrol::StorageControlClient client,
std::string const& cache_name) {
auto operation = client.DisableRapidCache(cache_name).get();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (Type Deduction (auto)), we should reject auto when it hides StatusOr<T>, domain objects, or function return types. Please use the explicit type google::cloud::StatusOr<google::storage::control::v2::RapidCache> instead of auto.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        operation = client.DisableRapidCache(cache_name).get();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.34%. Comparing base (c5873e0) to head (b521303).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16512      +/-   ##
==========================================
- Coverage   92.35%   92.34%   -0.02%     
==========================================
  Files        2260     2260              
  Lines      216842   216842              
==========================================
- Hits       200268   200239      -29     
- Misses      16574    16603      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch was successfully deployed

1 active deployment
false — b5213033 Deployed Sep 30, 2026 by kalragauri via Save PR ref #12159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant