-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2938 from GoogleCloudPlatform/streaming-writes-it
Add Symlink/ReadFile tests for streaming writes scenario and run CommonLocalFileTestSuite from Streaming writes package.
- Loading branch information
Showing
18 changed files
with
246 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2025 Google LLC | ||
// | ||
// 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 local_file | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"cloud.google.com/go/storage" | ||
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client" | ||
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations" | ||
) | ||
|
||
const ( | ||
onlyDirMounted = "OnlyDirMountLocalFiles" | ||
testDirLocalFileTest = "LocalFileTest" | ||
) | ||
|
||
var ( | ||
testDirName string | ||
testDirPath string | ||
storageClient *storage.Client | ||
ctx context.Context | ||
) | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
// Helpers | ||
//////////////////////////////////////////////////////////////////////// | ||
|
||
func WritingToLocalFileShouldNotWriteToGCS(ctx context.Context, storageClient *storage.Client, | ||
fh *os.File, testDirName, fileName string, t *testing.T) { | ||
operations.WriteWithoutClose(fh, client.FileContents, t) | ||
client.ValidateObjectNotFoundErrOnGCS(ctx, storageClient, testDirName, fileName, t) | ||
} | ||
|
||
func NewFileShouldGetSyncedToGCSAtClose(ctx context.Context, storageClient *storage.Client, | ||
testDirPath, fileName string, t *testing.T) { | ||
// Create a local file. | ||
_, fh := client.CreateLocalFileInTestDir(ctx, storageClient, testDirPath, fileName, t) | ||
|
||
// Writing contents to local file shouldn't create file on GCS. | ||
testDirName := client.GetDirName(testDirPath) | ||
WritingToLocalFileShouldNotWriteToGCS(ctx, storageClient, fh, testDirName, fileName, t) | ||
|
||
// Close the file and validate if the file is created on GCS. | ||
client.CloseFileAndValidateContentFromGCS(ctx, storageClient, fh, testDirName, fileName, client.FileContents, t) | ||
} | ||
|
||
// Following setters are required to setup ctx, storageClient, testDirName for the local file tests | ||
// getting executed from different package. | ||
func SetCtx(otherCtx context.Context) { | ||
if ctx == nil { | ||
ctx = otherCtx | ||
} | ||
} | ||
|
||
func SetStorageClient(otherStorageClient *storage.Client) { | ||
if storageClient == nil { | ||
storageClient = otherStorageClient | ||
} | ||
} | ||
|
||
func SetTestDirName(otherTestDirName string) { | ||
if testDirName == "" { | ||
testDirName = otherTestDirName | ||
} | ||
} |
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
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
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
Oops, something went wrong.