Skip to content

test(gRPC): Add GCSFuse gRPC metrics tests#1240

Merged
alleaditya merged 1 commit intomainfrom
add_grpc_metrics_test
Mar 25, 2026
Merged

test(gRPC): Add GCSFuse gRPC metrics tests#1240
alleaditya merged 1 commit intomainfrom
add_grpc_metrics_test

Conversation

@alleaditya
Copy link
Copy Markdown
Contributor

@alleaditya alleaditya commented Mar 3, 2026

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation

/kind failing-test

/kind feature
/kind flake

What this PR does / why we need it:
The changes test for gRPC metrics from GCSFuse. The test changes are needed for gRPC metrics integration into GCSFuse GKE sidecar integration. More information go/gcsfuse-metrics-onboarding-on-gke

Which issue(s) this PR fixes:

Fixes #489422934

Special notes for your reviewer:
There is a special handling for rls (Route Lookup Service) metrics since RLS metrics count cannot be verified without mocking the Backend connection.

Testing directions for the PR
Run the e2e tests on the clusters with different GCSFUSE_TAG (example v3.8.0 and v3.7.1) to check if the tests are version specific and gRPC

    make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false \
        E2E_TEST_BUILD_DRIVER=true \
        BUILD_GCSFUSE_FROM_SOURCE=true \
        REGISTRY=$REGISTRY \
        STAGINGVERSION=$STAGINGVERSION \
        GCSFUSE_CLIENT_PROTOCOL=http \
        E2E_TEST_FOCUS=metrics.* \
        GCSFUSE_TAG="v3.8.0"
...
Ginkgo ran 1 suite in 4m16.126802733s
  Test Suite Passed
Completed running e2e tests for testing the PR

With the help of debug logs, I verified that the tests skipped gRPC metrics for v3.7.1 and validated gRPC metrics for v3.8.0.
Verified the required metrics were made available when gRPC was enabled (logs)

Does this PR introduce a user-facing change?:

No

@google-oss-prow
Copy link
Copy Markdown

@alleaditya: The label(s) kind/feature cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:
The changes test for gRPC metrics from GCSFuse. The test changes are needed for gRPC metrics integration into GCSFuse GKE sidecar integration. More information go/gcsfuse-metrics-onboarding-on-gke

Which issue(s) this PR fixes:

Fixes #489422934

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces new end-to-end tests to validate the emission and collection of gRPC metrics from GCSFuse within a GKE sidecar integration. The changes ensure that when GCSFuse operates with gRPC as its client protocol, the expected gRPC-specific metrics are correctly reported, which is vital for monitoring and understanding the performance of gRPC-enabled GCSFuse deployments.

Highlights

  • New Test Configuration Prefix: Introduced a new constant EnableGrpcAndMetricsPrefix in test/e2e/specs/specs.go to designate test scenarios specifically for gRPC metrics.
  • GCSFuse Driver Configuration for gRPC Metrics: Modified test/e2e/specs/testdriver.go to automatically configure the GCSFuse driver to use client-protocol=grpc and enable experimental-enable-grpc-metrics when the new EnableGrpcAndMetricsPrefix is active. This ensures gRPC metrics are properly enabled for relevant tests.
  • gRPC Metric Definitions: Added a new list of expectedGrpcMetricNames in test/e2e/testsuites/metrics.go to include specific gRPC client metrics like grpc_client_attempt_started and grpc_client_call_duration.
  • New End-to-End Test Case for gRPC Metrics: Implemented a new ginkgo.It test case in test/e2e/testsuites/metrics.go that verifies the emission and correctness of gRPC metrics when GCSFuse is configured with the gRPC protocol. This test includes logic to filter metrics by relevant labels (bucket, pod, volume, namespace) and handles cases where certain metrics (like RLS) might have zero counts.
Changelog
  • test/e2e/specs/specs.go
    • Added a new constant EnableGrpcAndMetricsPrefix to define a specific test configuration for gRPC metrics.
  • test/e2e/specs/testdriver.go
    • Updated the CreateVolume function to include a new case for EnableGrpcAndMetricsPrefix, which forces client-protocol=grpc and enables experimental-enable-grpc-metrics.
    • Included the new prefix in the switch statement that handles bucket name passing.
  • test/e2e/testsuites/metrics.go
    • Imported the strings package for string manipulation.
    • Defined expectedGrpcMetricNames to list the gRPC-specific metrics to be verified.
    • Modified the DefineTests function to store the original configuration prefix.
    • Added a new conditional block to iterate through and verify the expectedGrpcMetricNames when the EnableGrpcAndMetricsPrefix is active, including label filtering and count assertions.
    • Introduced a new ginkgo.It test case to specifically test the emission of gRPC metrics.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

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 adds end-to-end tests for GCSFuse gRPC metrics, which is a valuable addition. A security review confirmed that no vulnerabilities were identified, as changes are confined to the test suite and involve hardcoded constants or values generated within the test framework. However, there are a few areas for improvement to enhance code quality and maintainability. Specifically, I've identified some leftover conversational comments and an unnecessary configuration in testdriver.go. In metrics.go, the metric filtering logic is overly complex and could be simplified for better readability and robustness, also ensuring pod_uid is excluded from metric labels as per repository guidelines, and a debug statement should be removed.

@alleaditya alleaditya marked this pull request as draft March 3, 2026 18:35
@alleaditya alleaditya marked this pull request as ready for review March 5, 2026 05:05
@thrivikram-karur-g
Copy link
Copy Markdown
Contributor

thrivikram-karur-g commented Mar 10, 2026

Ran the below e2e test command on the branch: add_grpc_metrics_test

make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false
E2E_TEST_BUILD_DRIVER=true
BUILD_GCSFUSE_FROM_SOURCE=true
REGISTRY=$REGISTRY
STAGINGVERSION=$STAGINGVERSION
GCSFUSE_TAG="v3.7.1"

Test results are as below:

[ReportAfterSuite] PASSED [3327.121 seconds]
[ReportAfterSuite] Autogenerated ReportAfterSuite for --junit-report
autogenerated by Ginkgo

Ran 349 of 484 Specs in 10022.728 seconds
SUCCESS! -- 349 Passed | 0 Failed | 1 Flaked | 0 Pending | 135 Skipped

Ginkgo ran 1 suite in 2h47m11.053118779s
Test Suite Passed
Completed running e2e tests for testing the PR

Comment on lines +278 to +285
case EnableGrpcAndMetricsPrefix:
// Ensure gRPC is used for this test, as it's required for gRPC metrics.
if !strings.Contains(mountOptions, "client-protocol=grpc") {
mountOptions += ",client-protocol=grpc"
}
mountOptions += ",experimental-enable-grpc-metrics"
v.enableMetrics = true
v.fileCacheCapacity = "100Mi"
Copy link
Copy Markdown
Collaborator

@amacaskill amacaskill Mar 12, 2026

Choose a reason for hiding this comment

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

Please do not set this here:

// Ensure gRPC is used for this test, as it's required for gRPC metrics.
			if !strings.Contains(mountOptions, "client-protocol=grpc") {
				mountOptions += ",client-protocol=grpc"
			}
			mountOptions += ",experimental-enable-grpc-metrics"

Instead, check within the metrics test if client protocol is already set to grpc on the test driver and if GCSFuse version supports experimental-enable-grpc-metrics, then run the new grpc metrics. See here: https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/pull/1240/changes#r2927336840.

For v.fileCacheCapacity = "100Mi", please try to set that within the if checks described in https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/pull/1240/changes#r2927336840 in metrics.go itself. That way, we wouldn't need EnableGrpcAndMetricsPrefix at all. As mentioned in other comment, v.enableMetrics = true isn't needed since metrics is enabled by default on all GKE versions where we run the tests.


//nolint:maintidx
func (t *gcsFuseCSIMetricsTestSuite) DefineTests(driver storageframework.TestDriver, pattern storageframework.TestPattern) {
gcsfuseDriver, ok := driver.(*specs.GCSFuseCSITestDriver)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here is where you would check if gcsfuseDriver.ClientProtocol is grpc, then you need to append expectedGrpcMetricNames to expectedMetricNames for all of the metrics tests to use. This means when running the tests manually, you need to set GCSFUSE_CLIENT_PROTOCOL=grpc since we don't force grpc to be enabled now in mountOption. We rely on GCSFUSE_CLIENT_PROTOCOL

In follow up PR, when you address https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/pull/1240/changes#r2927119458 comment , you will change the if gcsfuseDriver.ClientProtocol == grpc check to also check that the current min GCSFuseVersion supports the experimental flag metric. If it does, you would add the experimental flag mountOption from https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/pull/1240/changes#r2927289786 here.

For the v.fileCacheCapacity = "100Mi", please check on where you should set that. Try to set it in here if possible.

@alleaditya alleaditya force-pushed the add_grpc_metrics_test branch from 6e9dff7 to 8ac3644 Compare March 24, 2026 16:32
@amacaskill
Copy link
Copy Markdown
Collaborator

Can you please update the PR description with how you tested? We want to see that E2E_TEST_FOCUS=metrics.* tests are passing for make e2e-test with GCSFUSE_CLIENT_PROTOCOL=http and with GCSFUSE_CLIENT_PROTOCOL=grpc @alleaditya

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alleaditya, amacaskill

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@alleaditya
Copy link
Copy Markdown
Contributor Author

alleaditya commented Mar 25, 2026

Testing results

    make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false \
        E2E_TEST_BUILD_DRIVER=true \
        BUILD_GCSFUSE_FROM_SOURCE=true \
        REGISTRY=$REGISTRY \
        STAGINGVERSION=$STAGINGVERSION \
        GCSFUSE_CLIENT_PROTOCOL=grpc \
        E2E_TEST_FOCUS=metrics.* \
        GCSFUSE_TAG="v3.8.0"

Results indicate

  [ReportAfterSuite] PASSED [0.081 seconds]
  [ReportAfterSuite] Autogenerated ReportAfterSuite for --junit-report
  autogenerated by Ginkgo
  ------------------------------

  Ran 8 of 502 Specs in 251.261 seconds
  SUCCESS! -- 8 Passed | 0 Failed | 0 Pending | 494 Skipped


  Ginkgo ran 1 suite in 4m16.126802733s
  Test Suite Passed

@alleaditya
Copy link
Copy Markdown
Contributor Author

Testing results

    make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false \
        E2E_TEST_BUILD_DRIVER=true \
        BUILD_GCSFUSE_FROM_SOURCE=true \
        REGISTRY=$REGISTRY \
        STAGINGVERSION=$STAGINGVERSION \
        GCSFUSE_CLIENT_PROTOCOL=http \
        E2E_TEST_FOCUS=metrics.* \
        GCSFUSE_TAG="v3.8.0"

Results indicate

  ------------------------------
  [ReportAfterSuite] PASSED [0.093 seconds]
  [ReportAfterSuite] Autogenerated ReportAfterSuite for --junit-report
  autogenerated by Ginkgo
  ------------------------------

  Ran 8 of 502 Specs in 261.709 seconds
  SUCCESS! -- 8 Passed | 0 Failed | 0 Pending | 494 Skipped


  Ginkgo ran 1 suite in 4m27.217458492s
  Test Suite Passed
Completed running e2e tests for testing the PR

@alleaditya alleaditya merged commit 0008beb into main Mar 25, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants