From 66a8557af09a3130e2f25d39d78cd184c78b2fb0 Mon Sep 17 00:00:00 2001 From: tanyasethi-msft Date: Tue, 19 Mar 2024 00:22:38 +0530 Subject: [PATCH] Append With Flush from PR #22245 --- sdk/storage/azdatalake/CHANGELOG.md | 4 --- sdk/storage/azdatalake/file/client_test.go | 34 ++++++++++++++++++++++ sdk/storage/azdatalake/file/models.go | 2 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azdatalake/CHANGELOG.md b/sdk/storage/azdatalake/CHANGELOG.md index 31117bcf435a..972eca7d0b0d 100644 --- a/sdk/storage/azdatalake/CHANGELOG.md +++ b/sdk/storage/azdatalake/CHANGELOG.md @@ -32,10 +32,6 @@ * Updated version of azblob to `1.3.0` * Updated azcore version to `1.9.2` and azidentity version to `1.5.1`. -======= ->>>>>>> 63ae0d232b ([azdatalake] HNS encryption scope (#22346)) -======= ->>>>>>> 63ae0d232b ([azdatalake] HNS encryption scope (#22346)) ## 1.1.0-beta.1 (2024-01-10) ### Features Added diff --git a/sdk/storage/azdatalake/file/client_test.go b/sdk/storage/azdatalake/file/client_test.go index 00de8adbf399..ac8a4f4edee6 100644 --- a/sdk/storage/azdatalake/file/client_test.go +++ b/sdk/storage/azdatalake/file/client_test.go @@ -3654,6 +3654,40 @@ func (s *RecordedTestSuite) TestFileAppendWithFlushReleaseLease() { _require.Equal(lease.StateTypeAvailable, *gResp2.LeaseState) } +func (s *RecordedTestSuite) TestFileAppendWithFlushOption() { + _require := require.New(s.T()) + testName := s.T().Name() + + filesystemName := testcommon.GenerateFileSystemName(testName) + fsClient, err := testcommon.GetFileSystemClient(filesystemName, s.T(), testcommon.TestAccountDatalake, nil) + _require.NoError(err) + defer testcommon.DeleteFileSystem(context.Background(), _require, fsClient) + + _, err = fsClient.Create(context.Background(), nil) + _require.NoError(err) + + srcFileName := "src" + testcommon.GenerateFileName(testName) + + srcFClient, err := testcommon.GetFileClient(filesystemName, srcFileName, s.T(), testcommon.TestAccountDatalake, nil) + _require.NoError(err) + + resp, err := srcFClient.Create(context.Background(), nil) + _require.NoError(err) + _require.NotNil(resp) + + contentSize := 1024 * 8 // 8KB + rsc, _ := testcommon.GenerateData(contentSize) + opts := &file.AppendDataOptions{ + Flush: to.Ptr(true), + } + _, err = srcFClient.AppendData(context.Background(), 0, rsc, opts) + _require.NoError(err) + + gResp2, err := srcFClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*gResp2.ContentLength, int64(contentSize)) +} + func (s *RecordedTestSuite) TestFileAppendAndFlushData() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azdatalake/file/models.go b/sdk/storage/azdatalake/file/models.go index 1c63a8350714..43653da7e167 100644 --- a/sdk/storage/azdatalake/file/models.go +++ b/sdk/storage/azdatalake/file/models.go @@ -260,6 +260,8 @@ type AppendDataOptions struct { ProposedLeaseID *string // CPKInfo contains optional parameters to perform encryption using customer-provided key. CPKInfo *CPKInfo + //Flush Optional. If true, the file will be flushed after append. + Flush *bool } func (o *AppendDataOptions) format(offset int64, body io.ReadSeekCloser) (*generated.PathClientAppendDataOptions,