Skip to content

Commit

Permalink
Backport sharequota test change
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Jan 22, 2025
1 parent 83fe460 commit 7e83830
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
33 changes: 13 additions & 20 deletions e2etest/zt_newe2e_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,28 +561,22 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
svm.Assert("Quota is 1GB", Equal{Deep: true},
DerefOrZero(shareResource.GetProperties(svm).FileContainerProperties.Quota), int32(1))

fileNames := []string{"file_1.txt", "file_2.txt"}

// Create src obj mapping
srcObjs := make(ObjectResourceMappingFlat)

// Create source files
srcContainer := CreateResource[ContainerResourceManager](svm, GetRootResource(svm, common.ELocation.Local()),
ResourceDefinitionContainer{Objects: srcObjs})
for _, fileName := range fileNames {
body := NewRandomObjectContentContainer(int64(1) * common.GigaByte)
obj := ResourceDefinitionObject{
ObjectName: &fileName,
Body: body,
Size: "1.00 GiB",
}
srcObjs[fileName] = obj
CreateResource[ObjectResourceManager](svm, srcContainer, obj)
// Fill the share up
if !svm.Dryrun() {
shareClient := shareResource.(*FileShareResourceManager).internalClient
fileClient := shareClient.NewRootDirectoryClient().NewFileClient("big.txt")
_, err := fileClient.Create(ctx, 990*common.MegaByte, nil)
svm.NoError("Create large file", err)
}

srcOverflowObject := CreateResource[ObjectResourceManager](svm, GetRootResource(svm, common.ELocation.Local()),
ResourceDefinitionObject{
Body: NewRandomObjectContentContainer(common.GigaByte),
})

stdOut, _ := RunAzCopy(svm, AzCopyCommand{
Verb: AzCopyVerbCopy,
Targets: []ResourceManager{srcContainer, shareResource},
Targets: []ResourceManager{srcOverflowObject, shareResource},
Flags: CopyFlags{
CopySyncCommonFlags: CopySyncCommonFlags{
Recursive: pointerTo(true),
Expand All @@ -595,7 +589,7 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
ValidateContainsError(svm, stdOut, []string{"Increase the file share quota and call Resume command."})

fileMap := shareResource.ListObjects(svm, "", true)
svm.Assert("One file should be uploaded within the quota", Equal{}, len(fileMap)-1, 1) // -1 to Account for root dir in fileMap
svm.Assert("One file should be uploaded within the quota", Equal{}, len(fileMap), 1) // -1 to Account for root dir in fileMap

// Increase quota to fit all files
newQuota := int32(2)
Expand All @@ -609,5 +603,4 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
svm.Assert("Quota should be updated", Equal{},
DerefOrZero(shareResource.GetProperties(svm).FileContainerProperties.Quota),
newQuota)

}
5 changes: 3 additions & 2 deletions ste/mgr-JobPartTransferMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror"
"net/http"
"strings"
"sync/atomic"
Expand Down Expand Up @@ -864,8 +865,8 @@ func (jptm *jobPartTransferMgr) failActiveTransfer(typ transferErrorCode, descri
common.GetLifecycleMgr().Info(fmt.Sprintf("Authentication failed, it is either not correct, or expired, or does not have the correct permission %s", err.Error()))
}

if serviceCode == "ShareSizeLimitReached" {
common.GetLifecycleMgr().Error("Increase the file share quota and call Resume command.")
if fileerror.HasCode(err, "ShareSizeLimitReached") {
common.GetLifecycleMgr().Info("Increase the file share quota and call Resume command.")
}

// and use the normal cancelling mechanism so that we can exit in a clean and controlled way
Expand Down

0 comments on commit 7e83830

Please sign in to comment.