@@ -20,7 +20,6 @@ package sidecarmounter
2020import (
2121 "os"
2222 "reflect"
23- "slices"
2423 "strconv"
2524 "testing"
2625
@@ -221,7 +220,7 @@ func TestPrepareMountArgs(t *testing.T) {
221220 BufferDir : "test-buffer-dir" ,
222221 CacheDir : "test-cache-dir" ,
223222 ConfigFile : "test-config-file" ,
224- Options : []string {util .DisableMetricsForGKE + ":true " },
223+ Options : []string {util .DisableMetricsForGKE + ":false " },
225224 },
226225 expectedArgs : map [string ]string {
227226 "app-name" : GCSFuseAppName ,
@@ -234,37 +233,25 @@ func TestPrepareMountArgs(t *testing.T) {
234233 },
235234 expectedConfigMapArgs : defaultConfigFileFlagMap ,
236235 },
237- {
238- name : "should return valid args when metrics is enabled" ,
239- mc : & MountConfig {
240- BucketName : "test-bucket" ,
241- BufferDir : "test-buffer-dir" ,
242- CacheDir : "test-cache-dir" ,
243- ConfigFile : "test-config-file" ,
244- Options : []string {util .DisableMetricsForGKE + ":false" },
245- },
246- expectedArgs : map [string ]string {
247- "app-name" : GCSFuseAppName ,
248- "temp-dir" : "test-buffer-dir/temp-dir" ,
249- "config-file" : "test-config-file" ,
250- "foreground" : "" ,
251- "uid" : "0" ,
252- "gid" : "0" ,
253- },
254- expectedConfigMapArgs : defaultConfigFileFlagMap ,
255- },
256236 }
257237
258- testPrometheusPort := prometheusPort
238+ prometheusPort := 62990
259239 for _ , tc := range testCases {
260240 t .Run (tc .name , func (t * testing.T ) {
261- // Do not parallelize [e.g t.Parallel()] because all testcases share testPrometheusPort.
262- found := slices .Contains (tc .mc .Options , util .DisableMetricsForGKE + ":true" )
263- if ! found {
264- tc .expectedArgs ["prometheus-port" ] = strconv .Itoa (testPrometheusPort )
241+ t .Parallel ()
242+ found := false
243+ for _ , o := range tc .mc .Options {
244+ if o == util .DisableMetricsForGKE + ":false" {
245+ found = true
246+
247+ break
248+ }
249+ }
250+
251+ if found {
252+ tc .expectedArgs ["prometheus-port" ] = strconv .Itoa (prometheusPort )
253+ prometheusPort ++
265254 }
266- // Increase port value to match behavior of prepareMountArgs()
267- testPrometheusPort ++
268255
269256 tc .mc .prepareMountArgs ()
270257 if ! reflect .DeepEqual (tc .mc .FlagMap , tc .expectedArgs ) {
0 commit comments