Skip to content

Commit 7429bf0

Browse files
adding resumJob_e2e_test (#2592)
1 parent 7226414 commit 7429bf0

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

e2etest/zt_resume_test.go

+53-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package e2etest
22

33
import (
4+
"os"
5+
"strings"
6+
"testing"
7+
48
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
59
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
6-
"testing"
710

811
"github.com/Azure/azure-storage-azcopy/v10/common"
912
"github.com/google/uuid"
@@ -125,3 +128,52 @@ func TestResume_PublicSource_ContainerTarget(t *testing.T) {
125128
EAccountType.Standard(), EAccountType.Standard(), "",
126129
)
127130
}
131+
132+
// TestResume_ConsistentLogs_PublicSource_BlobTarget validates log file consistency for a job initially initiated as a copy operation and later resumed.
133+
// During the copy operation, a jobId is created and associated with its log file. If a resume operation follows, the same jobId from the copy is used for the log file, and the resumed logs are appended to it.
134+
// The test ensures that at most two log files are generated: one for scanning logs and one for normal logs.
135+
136+
func TestResume_ConsistentLogs_PublicSource_BlobTarget(t *testing.T) {
137+
RunScenarios(
138+
t,
139+
eOperation.Copy()|eOperation.Resume(),
140+
eTestFromTo.Other(common.EFromTo.BlobBlob(), common.EFromTo.BlobLocal()),
141+
eValidate.Auto(),
142+
anonymousAuthOnly,
143+
anonymousAuthOnly,
144+
params{
145+
recursive: true,
146+
debugSkipFiles: []string{";"}, // skip the only file is ;
147+
},
148+
&hooks{
149+
afterValidation: func(h hookHelper) {
150+
a := h.GetAsserter()
151+
logDir := os.Getenv("AZCOPY_E2E_LOG_OUTPUT")
152+
dir, err := os.Open(logDir)
153+
a.Assert(err, equals(), nil)
154+
defer dir.Close()
155+
156+
entries, err := dir.Readdir(-1)
157+
a.Assert(err, equals(), nil)
158+
var logFiles int
159+
for _, entry := range entries {
160+
if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".log") {
161+
logFiles++
162+
}
163+
}
164+
a.Assert(logFiles <= 2, equals(), true)
165+
166+
},
167+
},
168+
testFiles{
169+
defaultSize: "1K",
170+
sourcePublic: to.Ptr(container.PublicAccessTypeBlob),
171+
objectTarget: objectTarget{objectName: "xyz.txt"},
172+
173+
shouldTransfer: []interface{}{
174+
f("xyz.txt"),
175+
},
176+
},
177+
EAccountType.Standard(), EAccountType.Standard(), "",
178+
)
179+
}

0 commit comments

Comments
 (0)