@@ -56,6 +56,7 @@ const (
5656 testNameInactiveStreamTimeout = "inactive_stream_timeout"
5757 testNameBufferedReads = "buffered_read"
5858 testNameRenameSymlink = "rename_symlink"
59+ testNameRapidAppends = "rapid_appends"
5960
6061 testNamePrefixSucceed = "should succeed in "
6162
@@ -72,6 +73,15 @@ const (
7273 gcsfuseGoEnvSetupFormat = "export GO_VERSION=$(%v) && export GOTOOLCHAIN=go$GO_VERSION && export PATH=$PATH:/usr/local/go/bin"
7374)
7475
76+ // testPackageTimeoutMap controls the duration of the `-timeout` flag passed to the underlying `go test` executions.
77+ // If you need to extend the timeout for a specific test package, add or modify its limit in minutes here.
78+ var testPackageTimeoutMap = map [string ]int {
79+ testNameListLargeDir : 60 ,
80+ testNameWriteLargeFiles : 60 ,
81+ testNameReadLargeFiles : 60 ,
82+ testNameRapidAppends : 60 ,
83+ }
84+
7585var GCSFuseVersionStr = ""
7686
7787const gcsfuseGoVersionLegacyCommand = `grep -o 'go[0-9]\+\.[0-9]\+\.[0-9]\+' ./gcsfuse/tools/cd_scripts/e2e_test.sh | cut -c3-`
@@ -94,6 +104,31 @@ func zbEnabled(driver storageframework.TestDriver) bool {
94104 return gcsfuseCSITestDriver .EnableZB
95105}
96106
107+ // flatEnabled checks if the Flat Namespace feature is enabled for the given driver.
108+ func flatEnabled (driver storageframework.TestDriver ) bool {
109+ gcsfuseCSITestDriver , ok := driver .(* specs.GCSFuseCSITestDriver )
110+ gomega .Expect (ok ).To (gomega .BeTrue (), "failed to cast storageframework.TestDriver to *specs.GCSFuseCSITestDriver" )
111+
112+ return ! gcsfuseCSITestDriver .EnableHierarchicalNamespace && ! gcsfuseCSITestDriver .EnableZB
113+ }
114+
115+ // isConfigCompatible returns true if the parsed config is compatible with the current driver setup.
116+ func isConfigCompatible (config utils.TestConfig , driver storageframework.TestDriver ) bool {
117+ if ! config .RunOnGke {
118+ return false
119+ }
120+ if ! config .Compatible .Flat && flatEnabled (driver ) {
121+ return false
122+ }
123+ if ! config .Compatible .HNS && hnsEnabled (driver ) && ! zbEnabled (driver ) {
124+ return false
125+ }
126+ if ! config .Compatible .Zonal && zbEnabled (driver ) {
127+ return false
128+ }
129+ return true
130+ }
131+
97132// getGoParsingCommand returns the command to get the go version for the gcsfuse integration tests based on the gcsfuse version and branch.
98133// In gcsfuse v3.7.0 the go location was moved to a centralized dir ./gcsfuse/.go-version.
99134// If using v3.6.0 or older, we use gcsfuseGoVersionLegacyCommand; otherwise we use gcsfuseCentralizedLocationGoVersionCommand.
@@ -113,6 +148,72 @@ func getClientProtocol(driver storageframework.TestDriver) string {
113148 return gcsfuseCSITestDriver .ClientProtocol
114149}
115150
151+ type TestCommandConfig struct {
152+ TestPkg string
153+ TestName string
154+ GoEnvSetupCmd string
155+ MountPath string
156+ SecondaryMountPath string // Optional
157+ BucketName string
158+ OnlyDir string
159+ }
160+
161+ // generateTestCommand constructs the test command for validating file cache parameters.
162+ // This is used dynamically across the file cache logic tests including parallel downloads.
163+ func generateTestCommand (opts TestCommandConfig ) string {
164+ timeoutStr := ""
165+ if t , ok := testPackageTimeoutMap [opts .TestPkg ]; ok {
166+ timeoutStr = fmt .Sprintf (" -timeout %dm" , t )
167+ }
168+
169+ goTestCmd := fmt .Sprintf ("GODEBUG=asyncpreemptoff=1 go test ./%v/... -p 1 --integrationTest -v --config-file=../test_config.yaml%s" , opts .TestPkg , timeoutStr )
170+ if opts .TestName != "" {
171+ goTestCmd = fmt .Sprintf ("GODEBUG=asyncpreemptoff=1 go test ./%v/... -p 1 --integrationTest -v -run ^%v$ --config-file=../test_config.yaml%s" , opts .TestPkg , opts .TestName , timeoutStr )
172+ }
173+
174+ commandArgs := []string {
175+ fmt .Sprintf (gcsfuseGoEnvSetupFormat , opts .GoEnvSetupCmd ),
176+ fmt .Sprintf ("export MOUNTED_DIR=%q" , opts .MountPath ),
177+ }
178+
179+ if opts .SecondaryMountPath != "" {
180+ commandArgs = append (commandArgs , fmt .Sprintf ("export MOUNTED_DIR_SECONDARY=%q" , opts .SecondaryMountPath ))
181+ }
182+
183+ commandArgs = append (commandArgs ,
184+ fmt .Sprintf ("export BUCKET_NAME=%q" , opts .BucketName ),
185+ fmt .Sprintf ("export ONLY_DIR=%q" , opts .OnlyDir ),
186+ fmt .Sprintf ("cd %v" , gcsfuseIntegrationTestsBasePath ),
187+ goTestCmd ,
188+ )
189+
190+ return strings .Join (commandArgs , " && " )
191+ }
192+
193+ // configureLargeFileResources configures the pod and sidecar resources for memory-intensive large file tests.
194+ // Note: We only increase memory limits for specific tests like testNameWriteLargeFiles, testNameReadLargeFiles
195+ // and testNameRapidAppends. Other test cases run stable within the default memory for now
196+ // limits and do not require additional resources.
197+ func configureLargeFileResources (tPod * specs.TestPod , testNameOrPkg string , driver storageframework.TestDriver ) (string , string ) {
198+ sidecarMemoryLimit := defaultSidecarMemoryLimit
199+ sidecarMemoryRequest := defaultSidecarMemoryRequest
200+
201+ if testNameOrPkg == testNameWriteLargeFiles || testNameOrPkg == testNameReadLargeFiles {
202+ tPod .SetResource ("1" , "8Gi" , "5Gi" )
203+ sidecarMemoryLimit = "1Gi"
204+ if zbEnabled (driver ) {
205+ sidecarMemoryRequest = "1Gi"
206+ sidecarMemoryLimit = "2Gi"
207+ }
208+ }
209+ if testNameOrPkg == testNameRapidAppends {
210+ sidecarMemoryRequest = "2Gi"
211+ sidecarMemoryLimit = "3Gi"
212+ }
213+
214+ return sidecarMemoryRequest , sidecarMemoryLimit
215+ }
216+
116217type gcsFuseCSIGCSFuseIntegrationTestSuite struct {
117218 tsInfo storageframework.TestSuiteInfo
118219}
@@ -260,17 +361,8 @@ func (t *gcsFuseCSIGCSFuseIntegrationTestSuite) DefineTests(driver storageframew
260361 tPod := specs .NewTestPod (f .ClientSet , f .Namespace )
261362 tPod .SetImage (specs .GolangImage )
262363 tPod .SetResource ("1" , "5Gi" , "5Gi" )
263- sidecarMemoryLimit := defaultSidecarMemoryLimit
264- sidecarMemoryRequest := defaultSidecarMemoryRequest
265-
266- if testName == testNameWriteLargeFiles || testName == testNameReadLargeFiles {
267- tPod .SetResource ("1" , "6Gi" , "5Gi" )
268- sidecarMemoryLimit = "1Gi"
269- if zbEnabled (driver ) {
270- sidecarMemoryRequest = "1Gi"
271- sidecarMemoryLimit = "2Gi"
272- }
273- }
364+
365+ sidecarMemoryRequest , sidecarMemoryLimit := configureLargeFileResources (tPod , testName , driver )
274366
275367 mo := l .volumeResource .VolSource .CSI .VolumeAttributes ["mountOptions" ]
276368 if testName == testNameExplicitDir && strings .Contains (mo , "only-dir" ) {
0 commit comments