Skip to content

Commit 7e83830

Browse files
committed
Backport sharequota test change
1 parent 83fe460 commit 7e83830

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

e2etest/zt_newe2e_file_test.go

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -561,28 +561,22 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
561561
svm.Assert("Quota is 1GB", Equal{Deep: true},
562562
DerefOrZero(shareResource.GetProperties(svm).FileContainerProperties.Quota), int32(1))
563563

564-
fileNames := []string{"file_1.txt", "file_2.txt"}
565-
566-
// Create src obj mapping
567-
srcObjs := make(ObjectResourceMappingFlat)
568-
569-
// Create source files
570-
srcContainer := CreateResource[ContainerResourceManager](svm, GetRootResource(svm, common.ELocation.Local()),
571-
ResourceDefinitionContainer{Objects: srcObjs})
572-
for _, fileName := range fileNames {
573-
body := NewRandomObjectContentContainer(int64(1) * common.GigaByte)
574-
obj := ResourceDefinitionObject{
575-
ObjectName: &fileName,
576-
Body: body,
577-
Size: "1.00 GiB",
578-
}
579-
srcObjs[fileName] = obj
580-
CreateResource[ObjectResourceManager](svm, srcContainer, obj)
564+
// Fill the share up
565+
if !svm.Dryrun() {
566+
shareClient := shareResource.(*FileShareResourceManager).internalClient
567+
fileClient := shareClient.NewRootDirectoryClient().NewFileClient("big.txt")
568+
_, err := fileClient.Create(ctx, 990*common.MegaByte, nil)
569+
svm.NoError("Create large file", err)
581570
}
582571

572+
srcOverflowObject := CreateResource[ObjectResourceManager](svm, GetRootResource(svm, common.ELocation.Local()),
573+
ResourceDefinitionObject{
574+
Body: NewRandomObjectContentContainer(common.GigaByte),
575+
})
576+
583577
stdOut, _ := RunAzCopy(svm, AzCopyCommand{
584578
Verb: AzCopyVerbCopy,
585-
Targets: []ResourceManager{srcContainer, shareResource},
579+
Targets: []ResourceManager{srcOverflowObject, shareResource},
586580
Flags: CopyFlags{
587581
CopySyncCommonFlags: CopySyncCommonFlags{
588582
Recursive: pointerTo(true),
@@ -595,7 +589,7 @@ func (s *FileTestSuite) Scenario_UploadFilesWithQuota(svm *ScenarioVariationMana
595589
ValidateContainsError(svm, stdOut, []string{"Increase the file share quota and call Resume command."})
596590

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

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

ste/mgr-JobPartTransferMgr.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror"
78
"net/http"
89
"strings"
910
"sync/atomic"
@@ -864,8 +865,8 @@ func (jptm *jobPartTransferMgr) failActiveTransfer(typ transferErrorCode, descri
864865
common.GetLifecycleMgr().Info(fmt.Sprintf("Authentication failed, it is either not correct, or expired, or does not have the correct permission %s", err.Error()))
865866
}
866867

867-
if serviceCode == "ShareSizeLimitReached" {
868-
common.GetLifecycleMgr().Error("Increase the file share quota and call Resume command.")
868+
if fileerror.HasCode(err, "ShareSizeLimitReached") {
869+
common.GetLifecycleMgr().Info("Increase the file share quota and call Resume command.")
869870
}
870871

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

0 commit comments

Comments
 (0)