Skip to content

Commit

Permalink
Merge branch 'main' into adreed/e2e-test-inherit-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
wonwuakpa-msft authored Feb 25, 2025
2 parents 5d99ca5 + 7d84120 commit 78a23e1
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 4 deletions.
1 change: 1 addition & 0 deletions common/fe-ste-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
CPK_ERROR_SERVICE_CODE = "BlobUsesCustomerSpecifiedEncryption"
BLOB_NOT_FOUND = "BlobNotFound"
FILE_NOT_FOUND = "The specified file was not found."
EINTR_RETRY_COUNT = 5
)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 7 additions & 1 deletion common/writeThoughFile_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ func CreateFileOfSizeWithWriteThroughOption(destinationPath string, fileSize int
return f, err
}

err = syscall.Fallocate(int(f.Fd()), 0, 0, fileSize)
for i := 0; i < EINTR_RETRY_COUNT; i++ { // Perform up to 5 EINTR error retries
err = syscall.Fallocate(int(f.Fd()), 0, 0, fileSize)
if err == nil || err != syscall.EINTR {
break
}
}

if err != nil {
// To solve the case that Fallocate cannot work well with cifs/smb3.
if err == syscall.ENOTSUP {
Expand Down
30 changes: 30 additions & 0 deletions common/writeThroughFile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
package common_test

import (
"fmt"
"github.com/Azure/azure-storage-azcopy/v10/common"
"github.com/Azure/azure-storage-azcopy/v10/ste"
"github.com/stretchr/testify/assert"
"os"
"runtime"
"syscall"
"testing"
)

Expand Down Expand Up @@ -65,3 +68,30 @@ func TestCreateParentDirectoryIfNotExist(t *testing.T) {
err = common.CreateParentDirectoryIfNotExist(fullPath, tracker)
a.Nil(err)
}

// Test EINTR errors are not returned on Linux
func TestCreateFileOfSizeWithWriteThroughOption(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("EINTR errors are POSIX specific")
return
}
a := assert.New(t)
destinationPath := "/"

plan := &ste.JobPartPlanHeader{}
fpo := common.EFolderPropertiesOption.AllFolders()
tracker := ste.NewFolderCreationTracker(fpo, plan)

_, err := common.CreateFileOfSizeWithWriteThroughOption(destinationPath, 1,
false,
tracker,
false)

if err != nil {
a.NotEqual(syscall.EINTR, err)
return
}
a.NoError(err, fmt.Sprintf("Error creating file: %v", err))


}
14 changes: 14 additions & 0 deletions e2etest/newe2e_task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ func ValidateContainsError(a Asserter, stdout AzCopyStdout, errorMsg []string) {
a.Error(fmt.Sprintf("expected error message %v not found in azcopy output", errorMsg))
}

// ValidateDoesNotContainError Validates specific errorMsg is not returned in AzCopy run
func ValidateDoesNotContainError(a Asserter, stdout AzCopyStdout, errorMsg []string) {
if dryrunner, ok := a.(DryrunAsserter); ok && dryrunner.Dryrun() {
return
}
for _, line := range stdout.RawStdout() {
if !checkMultipleErrors(errorMsg, line) {
return
}
}
fmt.Println(stdout.String())
a.Error(fmt.Sprintf("error message %v not expected was found in azcopy output", errorMsg))
}

func checkMultipleErrors(errorMsg []string, line string) bool {
for _, e := range errorMsg {
if strings.Contains(line, e) {
Expand Down
23 changes: 23 additions & 0 deletions e2etest/zt_newe2e_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,26 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
DerefOrZero(shareResource.GetProperties(svm).FileContainerProperties.Quota),
newQuota)
}

// Test that POSIX errors are not returned in a RemoteLocal transfer
func (s *FileTestSuite) Scenario_SingleFileDownloadNoError(svm *ScenarioVariationManager) {
body := NewRandomObjectContentContainer(0)
srcObj := CreateResource[ObjectResourceManager](svm,
GetRootResource(svm, common.ELocation.File()),
ResourceDefinitionObject{Body: body})
destObj := CreateResource[ObjectResourceManager](svm,
GetRootResource(svm, common.ELocation.Local()),
ResourceDefinitionObject{Body: body})

stdOut, _ := RunAzCopy(svm, AzCopyCommand{
Verb: AzCopyVerbCopy,
Targets: []ResourceManager{srcObj, destObj},
ShouldFail: false,
})

//ValidateResource[ObjectResourceManager](svm, destObj, ResourceDefinitionObject{
// Body: body,
//}, true)

ValidateDoesNotContainError(svm, stdOut, []string{"interrupted system call"})
}
11 changes: 9 additions & 2 deletions ste/downloader-blobFS_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package ste
Expand Down Expand Up @@ -83,7 +84,13 @@ func (bd *blobFSDownloader) CreateFile(jptm IJobPartTransferMgr, destination str
return
}

err = syscall.Fallocate(int(file.(*os.File).Fd()), 0, 0, size)
for i := 0; i < common.EINTR_RETRY_COUNT; i++ { // Perform up to 5 EINTR error retries
err = syscall.Fallocate(int(file.(*os.File).Fd()), 0, 0, size)
if err == nil || err != syscall.EINTR {
break
}
}

if err == syscall.ENOTSUP {
err = file.(*os.File).Truncate(size) // err will get returned at the end
}
Expand Down Expand Up @@ -189,4 +196,4 @@ func (bd *blobFSDownloader) SetFolderProperties(jptm IJobPartTransferMgr) error
}

return nil
}
}
9 changes: 8 additions & 1 deletion ste/downloader-blob_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package ste
Expand Down Expand Up @@ -82,7 +83,13 @@ func (bd *blobDownloader) CreateFile(jptm IJobPartTransferMgr, destination strin
return
}

err = syscall.Fallocate(int(file.(*os.File).Fd()), 0, 0, size)
for i := 0; i < common.EINTR_RETRY_COUNT; i++ {
err = syscall.Fallocate(int(file.(*os.File).Fd()), 0, 0, size)
if err == nil || err != syscall.EINTR {
break
}
}

if err == syscall.ENOTSUP {
err = file.(*os.File).Truncate(size) // err will get returned at the end
}
Expand Down

0 comments on commit 78a23e1

Please sign in to comment.