|
1 | 1 | package e2etest
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "os" |
| 5 | + "strings" |
| 6 | + "testing" |
| 7 | + |
4 | 8 | "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
5 | 9 | "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
|
6 |
| - "testing" |
7 | 10 |
|
8 | 11 | "github.com/Azure/azure-storage-azcopy/v10/common"
|
9 | 12 | "github.com/google/uuid"
|
@@ -125,3 +128,52 @@ func TestResume_PublicSource_ContainerTarget(t *testing.T) {
|
125 | 128 | EAccountType.Standard(), EAccountType.Standard(), "",
|
126 | 129 | )
|
127 | 130 | }
|
| 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