这是indexloc提供的服务,不要输入任何密码
Skip to content

test(rapid appends): validate content appended in non-append mode available on GCS only after close() #3530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
32 changes: 32 additions & 0 deletions tools/integration_tests/rapid_appends/appends_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@ func (t *RapidAppendsSuite) TestAppendSessionInvalidatedByAnotherClientUponTakeo
assert.Equal(t.T(), expectedContent, string(content))
}

func (t *RapidAppendsSuite) TestContentAppendedInNonAppendModeNotVisibleTillClose() {
// Skipping test for now until CreateObject() is supported for unfinalized objects.
// Ref: b/424253611
t.T().Skip()

initialContent := t.fileContent
// Append to the file from the primary mount in non-append mode
wh, err := os.OpenFile(path.Join(primaryMntTestDirPath, t.fileName), os.O_WRONLY|syscall.O_DIRECT, operations.FilePermission_0600)
require.NoError(t.T(), err)

// Write sufficient data to the end of file.
data := setup.GenerateRandomString(contentSizeForBW * operations.OneMiB)
n, err := wh.WriteAt([]byte(data), int64(len(initialContent)))
require.NoError(t.T(), err)
require.Equal(t.T(), len(data), n)

// Read from back-door to validate that appended content is yet not visible on GCS.
contentBeforeClose, err := client.ReadObjectFromGCS(ctx, storageClient, path.Join(testDirName, t.fileName))
require.NoError(t.T(), err)
assert.Equal(t.T(), initialContent, contentBeforeClose)

// Close() from primary mount to ensure data persists in GCS.
err = wh.Close()
require.NoError(t.T(), err)

// Validate that appended content is visible in GCS.
expectedContent := initialContent + data
contentAfterClose, err := client.ReadObjectFromGCS(ctx, storageClient, path.Join(path.Join(testDirName, t.fileName)))
require.NoError(t.T(), err)
assert.Equal(t.T(), expectedContent, contentAfterClose)
}

////////////////////////////////////////////////////////////////////////
// Test Function (Runs once before all tests)
////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 6 additions & 3 deletions tools/integration_tests/rapid_appends/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
fileNamePrefix = "rapid-append-file-"
initialContent = "dummy content"
appendContent = "appended content"
// Minimum content size to write in order to trigger block upload while writing ; calculated as (2*blocksize+1) mb.
// Block size for buffered writes is set to 1MiB.
contentSizeForBW = 3
)

var (
Expand Down Expand Up @@ -91,7 +94,7 @@ func TestMain(m *testing.M) {
primaryMntLogFilePath = setup.LogFile()
// TODO(b/432179045): `--write-global-max-blocks=-1` is needed right now because of a bug in global semaphore release.
// Remove this flag once bug is fixed.
primaryMountFlags := []string{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0", "--write-global-max-blocks=-1"}
primaryMountFlags := []string{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0", "--write-global-max-blocks=-1", "--write-block-size-mb=1"}
err := static_mounting.MountGcsfuseWithStaticMounting(primaryMountFlags)
if err != nil {
log.Fatalf("Unable to mount primary mount: %v", err)
Expand All @@ -116,8 +119,8 @@ func TestMain(m *testing.M) {
}()
// Define flag set for secondary mount to run the tests.
flagsSet := [][]string{
{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0"},
{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0", "--file-cache-max-size-mb=-1", "--cache-dir=" + rapidAppendsCacheDir},
{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0", "--write-block-size-mb=1"},
{"--write-experimental-enable-rapid-appends=true", "--metadata-cache-ttl-secs=0", "--write-block-size-mb=1", "--file-cache-max-size-mb=-1", "--cache-dir=" + rapidAppendsCacheDir},
}

log.Println("Running static mounting tests...")
Expand Down
Loading