-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persistent mounting integration tests (#1218)
* adding test for persistent mounting * adding test for persistent mounting * adding test for persistent mounting * adding test for persistent mounting * Testing * Testing * Testing * Testing * Testing * Testing * Testing * Testing * Testing * testing * formating argument * adding -o flag * adding mounting test in every package * small fix * removing --o in * removing --o in * adding commands to run tests for mountedDirectory flag * small fix * fixing commands * adding comment * small fix * small fix * adding comment * adding comments and small fixed * fixing lint * fixing merge conflict * smallfi x * testing * testing * small fix * removing unnecessary commands * removing extra line * removing extra line
- Loading branch information
Showing
10 changed files
with
247 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
90 changes: 90 additions & 0 deletions
90
tools/integration_tests/util/mounting/persistent_mounting/perisistent_mounting.go
This file contains 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,90 @@ | ||
//Copyright 2023 Google Inc. All Rights Reserved. | ||
// | ||
//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 persistent_mounting | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting" | ||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" | ||
) | ||
|
||
// make e.g --enable-storage-client-library in enable_storage_client_library | ||
func makePersistentMountingArgs(flags []string) (args []string, err error) { | ||
var s string | ||
for i := range flags { | ||
// We are already passing flags with -o flag. | ||
s = strings.Replace(flags[i], "--o=", "", -1) | ||
// e.g. Convert --enable-storage-client-library to __enable_storage_client_library | ||
s = strings.Replace(s, "-", "_", -1) | ||
// e.g. Convert __enable_storage_client_library to enable_storage_client_library | ||
s = strings.Replace(s, "__", "", -1) | ||
args = append(args, s) | ||
} | ||
return | ||
} | ||
|
||
func mountGcsfuseWithStaticMounting(flags []string) (err error) { | ||
defaultArg := []string{setup.TestBucket(), | ||
setup.MntDir(), | ||
"-o", | ||
"debug_gcs", | ||
"-o", | ||
"debug_fs", | ||
"-o", | ||
"debug_fuse", | ||
"-o", | ||
"log_file=" + setup.LogFile(), | ||
"-o", | ||
"log_format=text", | ||
} | ||
|
||
persistentMountingArgs, err := makePersistentMountingArgs(flags) | ||
if err != nil { | ||
setup.LogAndExit("Error in converting flags for persistent mounting.") | ||
} | ||
|
||
for i := 0; i < len(persistentMountingArgs); i++ { | ||
// e.g. -o flag1, -o flag2, ... | ||
defaultArg = append(defaultArg, "-o", persistentMountingArgs[i]) | ||
} | ||
|
||
err = mounting.MountGcsfuse(setup.SbinFile(), defaultArg) | ||
|
||
return err | ||
} | ||
|
||
func executeTestsForStatingMounting(flags [][]string, m *testing.M) (successCode int) { | ||
var err error | ||
|
||
for i := 0; i < len(flags); i++ { | ||
if err = mountGcsfuseWithStaticMounting(flags[i]); err != nil { | ||
setup.LogAndExit(fmt.Sprintf("mountGcsfuse: %v\n", err)) | ||
} | ||
setup.ExecuteTestForFlagsSet(flags[i], m) | ||
} | ||
return | ||
} | ||
|
||
func RunTests(flags [][]string, m *testing.M) (successCode int) { | ||
successCode = executeTestsForStatingMounting(flags, m) | ||
|
||
log.Printf("Test log: %s\n", setup.LogFile()) | ||
|
||
return successCode | ||
} |
Oops, something went wrong.