-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sequential write large file integration tests (#1240)
* adding test for writing file of 100MB * adding test for writing file of 100MB * adding commands in script * adding commands in script * small fix * increasing chunk size * small fix * using min function * small fix * adding comment * fixing lint * writing 500MB in more redable way * fixing comments * fixing comments * changing chunksize to 20MB * testing sync * testing * merging * merging * testing sync * small fix
- Loading branch information
Showing
4 changed files
with
154 additions
and
0 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
50 changes: 50 additions & 0 deletions
50
tools/integration_tests/write_large_files/write_large_files_test.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,50 @@ | ||
// 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. | ||
|
||
// Provides integration tests for write large files sequentially and randomly. | ||
package write_large_files | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/static_mounting" | ||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
setup.ParseSetUpFlags() | ||
|
||
flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} | ||
|
||
setup.ExitWithFailureIfBothTestBucketAndMountedDirectoryFlagsAreNotSet() | ||
|
||
if setup.TestBucket() != "" && setup.MountedDirectory() != "" { | ||
log.Print("Both --testbucket and --mountedDirectory can't be specified at the same time.") | ||
os.Exit(1) | ||
} | ||
|
||
// Run tests for mountedDirectory only if --mountedDirectory flag is set. | ||
setup.RunTestsForMountedDirectoryFlag(m) | ||
|
||
// Run tests for testBucket | ||
setup.SetUpTestDirForTestBucketFlag() | ||
|
||
successCode := static_mounting.RunTests(flags, m) | ||
|
||
setup.RemoveBinFileCopiedForTesting() | ||
|
||
os.Exit(successCode) | ||
} |
51 changes: 51 additions & 0 deletions
51
tools/integration_tests/write_large_files/write_one_large_file_sequentially_test.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,51 @@ | ||
// 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 write_large_files | ||
|
||
import ( | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/operations" | ||
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" | ||
) | ||
|
||
const FiveHundredMB = 500 * 1024 * 1024 | ||
const FiveHundredMBFile = "fiveHundredMBFile.txt" | ||
const ChunkSize = 20 * 1024 * 1024 | ||
|
||
func TestWriteLargeFileSequentially(t *testing.T) { | ||
// Clean the mountedDirectory before running test. | ||
setup.CleanMntDir() | ||
|
||
filePath := path.Join(setup.MntDir(), FiveHundredMBFile) | ||
|
||
// Sequentially read the data from file. | ||
err := operations.WriteFileSequentially(filePath, FiveHundredMB, ChunkSize) | ||
if err != nil { | ||
t.Errorf("Error in writing file: %v", err) | ||
} | ||
|
||
// Check if 500MB data written in the file. | ||
fStat, err := os.Stat(filePath) | ||
if err != nil { | ||
t.Errorf("Error in stating file:%v", err) | ||
} | ||
|
||
if fStat.Size() != FiveHundredMB { | ||
t.Errorf("Expecred file size %v found %d", FiveHundredMB, fStat.Size()) | ||
} | ||
} |