Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/integration_tests/improved_run_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ TEST_PACKAGES_COMMON=(
"buffered_read"
"flag_optimizations"
"symlink_handling"
"shared_chunk_cache"
)

# filter_array: Filters an array in place keeping only elements matching the regex.
Expand Down
2 changes: 1 addition & 1 deletion tools/integration_tests/shared_chunk_cache/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ func TestMain(m *testing.M) {

successCode := m.Run()

setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(setup.TestBucket(), testDirName))
setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(testEnv.cfg.TestBucket, testDirName))
os.Exit(successCode)
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (t *BaseSuite) TearDownTest() {

if testEnv.cfg.GKEMountedDirectory != "" {
// GKE Mode: Just cleanup files
setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(setup.TestBucket(), testDirName))
setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(testEnv.cfg.TestBucket, testDirName))
} else {
// GCE Mode: Unmount and clean up
t.unmountAndCleanupMount(t.primaryMount, "primary")
Expand Down Expand Up @@ -144,7 +144,7 @@ func (t *BaseSuite) mountGcsfuse(mnt mountPoint, mountType string, flags []strin
func (t *BaseSuite) unmountAndCleanupMount(m mountPoint, name string) {
setup.UnmountGCSFuse(m.mntDir)
// Cleaning up the intermediate generated test files.
setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(setup.TestBucket(), testDirName))
setup.CleanupDirectoryOnGCS(testEnv.ctx, testEnv.storageClient, path.Join(testEnv.cfg.TestBucket, testDirName))
}

func (t *BaseSuite) createTestFile(fileName string, fileSize int) {
Expand Down Expand Up @@ -350,10 +350,10 @@ func RunTests(t *testing.T, runName string, factory func(primaryFlags, secondary
for _, cfg := range testEnv.cfg.Configs {
if cfg.Run == runName {
for i, flagStr := range cfg.Flags {
primaryFlags := strings.Fields(flagStr)
primaryFlags := strings.Split(flagStr, ",")
var secondaryFlags []string
if len(cfg.SecondaryFlags) > i {
secondaryFlags = strings.Fields(cfg.SecondaryFlags[i])
secondaryFlags = strings.Split(cfg.SecondaryFlags[i], ",")
}
Comment on lines +353 to 357

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using strings.Split directly can lead to empty or whitespace-only strings in the flags slice if the config contains consecutive, leading, or trailing commas, or spaces around commas (e.g., "--flag1, ,--flag2"). This can cause unexpected test failures. A more robust approach is to trim whitespace from each part and filter out any empty strings.

                                var primaryFlags []string
				for _, f := range strings.Split(flagStr, ",") {
					if flag := strings.TrimSpace(f); flag != "" {
						primaryFlags = append(primaryFlags, flag)
					}
				}
				var secondaryFlags []string
				if len(cfg.SecondaryFlags) > i {
					secondaryFlags = []string{}
					for _, f := range strings.Split(cfg.SecondaryFlags[i], ",") {
						if flag := strings.TrimSpace(f); flag != "" {
							secondaryFlags = append(secondaryFlags, flag)
						}
					}
				}

suite.Run(t, factory(primaryFlags, secondaryFlags))
}
Expand Down
16 changes: 16 additions & 0 deletions tools/integration_tests/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2356,3 +2356,19 @@ concurrent_operations:
different_zone: false
run: TestConcurrentListing
run_on_gke: true

shared_chunk_cache:
- mounted_directory: "${MOUNTED_DIR}"
mounted_directory_secondary: "${MOUNTED_DIR_SECONDARY}"
test_bucket: "${BUCKET_NAME}"
configs:
- flags:
- "--enable-experimental-shared-chunk-cache,--file-cache-max-size-mb=-1,--cache-dir=/gcsfuse-tmp/shared-cache"
secondary_flags:
- "--enable-experimental-shared-chunk-cache,--file-cache-max-size-mb=-1,--cache-dir=/gcsfuse-tmp/shared-cache"
compatible:
flat: true
hns: true
zonal: true
run: TestSharedChunkCacheTestSuite
run_on_gke: true
Loading