-
Notifications
You must be signed in to change notification settings - Fork 508
ci: Add emulator tests (and related changes) for stalled API calls to control-client #4566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
gargnitingoogle
wants to merge
3
commits into
master
from
gargnitin/test-ctrl-client-stall-retries/v1
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tools/integration_tests/emulator_tests/configs/control_client_stall_create_40s.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| proxyType: grpc | ||
| targetHost: "localhost:8888" | ||
| retryConfig: | ||
| - method: CreateFolder | ||
| retryInstruction: "stall-for-40s" | ||
| retryCount: 1 | ||
| skipCount: 2 | ||
|
|
||
8 changes: 8 additions & 0 deletions
8
tools/integration_tests/emulator_tests/configs/control_client_stall_delete_40s.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| proxyType: grpc | ||
| targetHost: "localhost:8888" | ||
| retryConfig: | ||
| - method: DeleteFolder | ||
| retryInstruction: "stall-for-40s" | ||
| retryCount: 1 | ||
| skipCount: 0 | ||
|
|
8 changes: 8 additions & 0 deletions
8
tools/integration_tests/emulator_tests/configs/control_client_stall_get_40s.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| proxyType: grpc | ||
| targetHost: "localhost:8888" | ||
| retryConfig: | ||
| - method: GetFolder | ||
| retryInstruction: "stall-for-40s" | ||
| retryCount: 1 | ||
| skipCount: 0 | ||
|
|
8 changes: 8 additions & 0 deletions
8
tools/integration_tests/emulator_tests/configs/control_client_stall_layout_60s.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| proxyType: grpc | ||
| targetHost: "localhost:8888" | ||
| retryConfig: | ||
| - method: GetStorageLayout | ||
| retryInstruction: "stall-for-60s" | ||
| retryCount: 1 | ||
| skipCount: 0 | ||
|
|
8 changes: 8 additions & 0 deletions
8
tools/integration_tests/emulator_tests/configs/control_client_stall_rename_40s.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| proxyType: grpc | ||
| targetHost: "localhost:8888" | ||
| retryConfig: | ||
| - method: RenameFolder | ||
| retryInstruction: "stall-for-40s" | ||
| retryCount: 1 | ||
| skipCount: 0 | ||
|
|
248 changes: 248 additions & 0 deletions
248
tools/integration_tests/emulator_tests/control_client_stall/control_client_stall_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| // 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 | ||
| // | ||
| // http://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 control_client_stall | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "log" | ||
| "os" | ||
| "path" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "github.com/stretchr/testify/suite" | ||
|
|
||
| emulator_tests "github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/emulator_tests/util" | ||
| "github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/mounting/static_mounting" | ||
| "github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/setup" | ||
| ) | ||
|
|
||
| type controlClientStallBase struct { | ||
| port int | ||
| proxyProcessId int | ||
| proxyServerLogFile string | ||
| flags []string | ||
| configFileName string | ||
| maxMountDurationSecs int | ||
| testDirPath string | ||
| suite.Suite | ||
| } | ||
|
|
||
| func (c *controlClientStallBase) SetupTest() { | ||
| c.testDirPath = setup.SetupTestDirectory(c.T().Name()) | ||
| c.proxyServerLogFile = setup.CreateProxyServerLogFile(c.T()) | ||
| var err error | ||
| c.port, c.proxyProcessId, err = emulator_tests.StartProxyServer(c.configFileName, c.proxyServerLogFile) | ||
| require.NoError(c.T(), err) | ||
|
|
||
| // Add proxy server endpoint and configure gRPC testing | ||
| // Copy flags to avoid mutating the original slice across suites | ||
| mountFlags := append([]string(nil), c.flags...) | ||
| mountFlags = append(mountFlags, fmt.Sprintf("--custom-endpoint=localhost:%d", c.port)) | ||
| mountFlags = append(mountFlags, "--anonymous-access") // Required for gRPC localhost endpoint | ||
|
|
||
| startTime := time.Now() | ||
| setup.MountGCSFuseWithGivenMountFunc(mountFlags, static_mounting.MountGcsfuseWithStaticMounting) | ||
| mountTime := time.Since(startTime) | ||
| if c.maxMountDurationSecs != -1 { | ||
| assert.True(c.T(), mountTime < time.Duration(c.maxMountDurationSecs)*time.Second, "Mount time %v should be less than %ds", mountTime, c.maxMountDurationSecs) | ||
| } | ||
| } | ||
|
|
||
| func (c *controlClientStallBase) TearDownTest() { | ||
| setup.UnmountGCSFuse(setup.MntDir()) | ||
| assert.NoError(c.T(), emulator_tests.KillProxyServerProcess(c.proxyProcessId)) | ||
| setup.SaveGCSFuseLogFileInCaseOfFailure(c.T()) | ||
| setup.SaveProxyServerLogFileInCaseOfFailure(c.proxyServerLogFile, c.T()) | ||
| } | ||
|
|
||
| // --- Test Suites --- | ||
|
|
||
| type createFolderStallSuite struct{ controlClientStallBase } | ||
|
|
||
| // TestCreateFolderStallInducedShouldComplete verifies that creating a folder via | ||
| // os.MkdirAll completes successfully even when a stall is induced, | ||
| // proving that the experimental retry logic correctly handles the delayed gRPC response. | ||
| func (c *createFolderStallSuite) TestCreateFolderStallInducedShouldComplete() { | ||
| folderPath := path.Join(c.testDirPath, "stalled_folder_for_create") | ||
|
|
||
| startTime := time.Now() | ||
| err := os.MkdirAll(folderPath, 0755) | ||
| elapsedTime := time.Since(startTime) | ||
|
|
||
| assert.NoError(c.T(), err) | ||
| // Ensure the CreateFolder operation took less than 32 seconds (30 seconds first stalled-call timeout + 2 second wiggle-room) because of the internal abortion and retry. | ||
| assert.True(c.T(), elapsedTime < 32*time.Second, "Elapsed time %v should be less than 32s", elapsedTime) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we create a const for 32s, we can tell why? Also would be good to link the hardcoded initial stall timeout (30s). |
||
| // Validate the directory actually exists | ||
| info, err := os.Stat(folderPath) | ||
| assert.NoError(c.T(), err) | ||
| assert.True(c.T(), info.IsDir()) | ||
| } | ||
|
|
||
| type getFolderStallSuite struct{ controlClientStallBase } | ||
|
|
||
| // TestGetFolderStallInducedShouldComplete verifies that stating a pre-created folder via | ||
| // os.Stat completes successfully even when a stall is induced, | ||
| // proving that the experimental retry logic correctly handles the delayed gRPC response. | ||
| func (c *getFolderStallSuite) TestGetFolderStallInducedShouldComplete() { | ||
| folderPath := path.Join(c.testDirPath, "stalled_folder_for_get") | ||
| err := os.MkdirAll(folderPath, 0755) | ||
| assert.NoError(c.T(), err) | ||
|
|
||
| startTime := time.Now() | ||
| _, err = os.Stat(folderPath) | ||
| elapsedTime := time.Since(startTime) | ||
|
|
||
| assert.NoError(c.T(), err) | ||
| // Ensure the GetFolder operation took less than 32 seconds (30 seconds first stalled-call timeout + 2 second wiggle-room) because of the internal abortion and retry. | ||
| assert.True(c.T(), elapsedTime < 32*time.Second, "Elapsed time %v should be less than 32s", elapsedTime) | ||
| } | ||
|
|
||
| type deleteFolderStallSuite struct{ controlClientStallBase } | ||
|
|
||
| // TestDeleteFolderStallInducedShouldComplete verifies that deleting a pre-created empty folder via | ||
| // os.Remove completes successfully even when a stall is induced, | ||
| // proving that the experimental retry logic correctly handles the delayed gRPC response. | ||
| func (c *deleteFolderStallSuite) TestDeleteFolderStallInducedShouldComplete() { | ||
| folderPath := path.Join(c.testDirPath, "stalled_folder_for_delete") | ||
| err := os.MkdirAll(folderPath, 0755) | ||
| assert.NoError(c.T(), err) | ||
|
|
||
| startTime := time.Now() | ||
| err = os.Remove(folderPath) | ||
| elapsedTime := time.Since(startTime) | ||
|
|
||
| assert.NoError(c.T(), err) | ||
| // Ensure the DeleteFolder operation took less than 32 seconds (30 seconds first stalled-call timeout + 2 second wiggle-room) because of the internal abortion and retry. | ||
| assert.True(c.T(), elapsedTime < 32*time.Second, "Elapsed time %v should be less than 32s", elapsedTime) | ||
| // Validate the directory actually deleted | ||
| _, err = os.Stat(folderPath) | ||
| assert.True(c.T(), os.IsNotExist(err)) | ||
| } | ||
|
|
||
| type renameFolderStallSuite struct{ controlClientStallBase } | ||
|
|
||
| // TestRenameFolderStallInducedShouldComplete verifies that renaming a pre-created folder via | ||
| // os.Rename completes successfully even when a stall is induced, | ||
| // proving that the experimental retry logic correctly handles the delayed gRPC response. | ||
| func (c *renameFolderStallSuite) TestRenameFolderStallInducedShouldComplete() { | ||
| folderPath := path.Join(c.testDirPath, "stalled_folder_for_rename") | ||
| err := os.MkdirAll(folderPath, 0755) | ||
| assert.NoError(c.T(), err) | ||
| destPath := path.Join(c.testDirPath, "stalled_folder_renamed") | ||
|
|
||
| startTime := time.Now() | ||
| err = os.Rename(folderPath, destPath) | ||
| elapsedTime := time.Since(startTime) | ||
|
|
||
| assert.NoError(c.T(), err) | ||
| // Ensure the RenameFolder operation took less than 32 seconds (30 seconds first stalled-call timeout + 2 second wiggle-room) because of the internal abortion and retry. | ||
| assert.True(c.T(), elapsedTime < 32*time.Second, "Elapsed time %v should be less than 32s", elapsedTime) | ||
| // Validate the directory actually renamed | ||
| _, err = os.Stat(destPath) | ||
| assert.NoError(c.T(), err) | ||
| } | ||
|
|
||
| type getStorageLayoutStallSuite struct{ controlClientStallBase } | ||
|
|
||
| // TestGetStorageLayoutStallInducedShouldComplete verifies that a GCSFuse mount | ||
| // completes successfully even when a stall is induced in the very first GetStorageLayout call, | ||
| // proving that the experimental retry logic correctly handles the delayed gRPC response. | ||
| func (c *getStorageLayoutStallSuite) TestGetStorageLayoutStallInducedShouldComplete() { | ||
| // The stall for GetStorageLayout is actually triggered during the bucket mount | ||
| // phase within SetupTest() when GCSFuse queries the bucket layout to determine | ||
| // if Hierarchical Namespace (HNS) is enabled. | ||
| // The fact that this test function is executing means the mount succeeded, | ||
| // effectively proving that GetStorageLayout correctly timed out after 30s, | ||
| // retried successfully, and allowed the mount to complete! | ||
|
|
||
| // Just perform a basic verification to ensure the mount is functional. | ||
| folderPath := path.Join(c.testDirPath, "stalled_folder_for_layout") | ||
| err := os.MkdirAll(folderPath, 0755) | ||
| assert.NoError(c.T(), err) | ||
| // Validate the directory actually exists | ||
| info, err := os.Stat(folderPath) | ||
| assert.NoError(c.T(), err) | ||
| assert.True(c.T(), info.IsDir()) | ||
| } | ||
|
|
||
| func TestControlClientStall(t *testing.T) { | ||
| // Test matrix | ||
| flagsSet := [][]string{ | ||
| { | ||
| "--client-protocol=grpc", | ||
| "--rename-dir-limit=0", // Force use of Control API for folders instead of legacy workarounds | ||
| "--experimental-nonrapid-folder-api-stall-retry=true", // Enable the new flag we are testing! | ||
| "--metadata-cache-ttl-secs=0", // Disable cache so calls definitely hit the backend | ||
| }, | ||
| } | ||
|
|
||
| for _, flags := range flagsSet { | ||
| suites := []suite.TestingSuite{ | ||
| &createFolderStallSuite{ | ||
| controlClientStallBase: controlClientStallBase{ | ||
| flags: flags, | ||
| // Artificially stall the very first CreateFolder call by 40 seconds. | ||
| configFileName: "../configs/control_client_stall_create_40s.yaml", | ||
| // No check on how long mount takes. | ||
| maxMountDurationSecs: -1, | ||
| }, | ||
| }, | ||
| &getFolderStallSuite{ | ||
| controlClientStallBase: controlClientStallBase{ | ||
| flags: flags, | ||
| // Artificially stall the very first GetFolder call by 40 seconds. | ||
| configFileName: "../configs/control_client_stall_get_40s.yaml", | ||
| // No check on how long mount takes. | ||
| maxMountDurationSecs: -1, | ||
| }, | ||
| }, | ||
| &deleteFolderStallSuite{ | ||
| controlClientStallBase: controlClientStallBase{ | ||
| flags: flags, | ||
| // Artificially stall the very first DeleteFolder call by 40 seconds. | ||
| configFileName: "../configs/control_client_stall_delete_40s.yaml", | ||
| // No check on how long mount takes. | ||
| maxMountDurationSecs: -1, | ||
| }, | ||
| }, | ||
| &renameFolderStallSuite{ | ||
| controlClientStallBase: controlClientStallBase{ | ||
| flags: flags, | ||
| // Artificially stall the very first RenameFolder call by 40 seconds. | ||
| configFileName: "../configs/control_client_stall_rename_40s.yaml", | ||
| // No check on how long mount takes. | ||
| maxMountDurationSecs: -1, | ||
| }, | ||
| }, | ||
| &getStorageLayoutStallSuite{ | ||
| controlClientStallBase: controlClientStallBase{ | ||
| flags: flags, | ||
| // Artificially stall the very first GetStorageLayout call by 60 seconds. | ||
| configFileName: "../configs/control_client_stall_layout_60s.yaml", | ||
| // Ensure that the whole mount operation including a stalled GetStorageLayout call took less than 40 seconds (30 seconds first stalled-call GetStorageLayout timeout + 10 second wiggle-room for 2nd attempt and other steps for mount to go through) because of the internal abortion and retry. | ||
| maxMountDurationSecs: 40, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| for _, s := range suites { | ||
| log.Printf("Running Control Client Stall test suite %T with flags: %s", s, flags) | ||
| suite.Run(t, s) | ||
| } | ||
| } | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
tools/integration_tests/emulator_tests/control_client_stall/setup_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // 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 | ||
| // | ||
| // http://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 control_client_stall | ||
|
|
||
| import ( | ||
| "log" | ||
| "os" | ||
| "testing" | ||
|
|
||
| "github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/setup" | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| setup.ParseSetUpFlags() | ||
|
|
||
| if setup.MountedDirectory() != "" { | ||
| log.Printf("These tests will not run with mounted directory.") | ||
| return | ||
| } | ||
|
|
||
| // Set up test directory. | ||
| setup.SetUpTestDirForTestBucketFlag() | ||
|
|
||
| log.Println("Running control client stall tests...") | ||
| successCode := m.Run() | ||
| os.Exit(successCode) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is skipCcount 2here and not everywhere?