Skip to content

Commit f2efdd1

Browse files
Merge pull request #1028 from Seagate/bugfix/fix-failing-azure-tests-with-new-azurite-version
Fix failing azurite tests
2 parents 2458029 + 317d6a5 commit f2efdd1

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/unit-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ jobs:
6161

6262
azurite:
6363
image: mcr.microsoft.com/azure-storage/azurite:latest
64+
env:
65+
AZURITE_SKIP_API_VERSION_CHECK: "true"
6466
ports:
6567
- 10000:10000
6668
- 10001:10001

component/azstorage/block_blob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,13 +1271,13 @@ func (bb *BlockBlob) WriteFromFile(
12711271
// Compute md5 of this file is requested by user
12721272
// If file is uploaded in one shot (no blocks created) then server is populating md5 on upload automatically.
12731273
// hence we take cost of calculating md5 only for files which are bigger in size and which will be converted to blocks.
1274-
md5sum := []byte{}
1274+
var md5sum []byte
12751275
if bb.Config.updateMD5 && stat.Size() >= blockblob.MaxUploadBlobBytes {
12761276
md5sum, err = common.GetMD5(fi)
12771277
if err != nil {
12781278
// Md5 sum generation failed so set nil while uploading
12791279
log.Warn("BlockBlob::WriteFromFile : Failed to generate md5 of %s", name)
1280-
md5sum = []byte{0}
1280+
md5sum = nil
12811281
}
12821282
}
12831283

component/azstorage/block_blob_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,11 +3892,14 @@ func (s *blockBlobTestSuite) TestInvalidateMD5PostUpload() {
38923892
s.assert.NoError(err)
38933893

38943894
blobClient := s.containerClient.NewBlobClient(name)
3895-
_, _ = blobClient.SetHTTPHeaders(
3895+
_, err = blobClient.SetHTTPHeaders(
38963896
context.Background(),
3897-
blob.HTTPHeaders{BlobContentMD5: []byte("cloudfuse")},
3897+
blob.HTTPHeaders{
3898+
BlobContentMD5: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
3899+
},
38983900
nil,
38993901
)
3902+
s.assert.NoError(err)
39003903

39013904
prop, err := s.az.storage.GetAttr(ctx, name)
39023905
s.assert.NoError(err)
@@ -4096,11 +4099,14 @@ func (s *blockBlobTestSuite) TestInvalidMD5OnRead() {
40964099
_ = os.Remove(name)
40974100

40984101
blobClient := s.containerClient.NewBlobClient(name)
4099-
_, _ = blobClient.SetHTTPHeaders(
4102+
_, err = blobClient.SetHTTPHeaders(
41004103
context.Background(),
4101-
blob.HTTPHeaders{BlobContentMD5: []byte("cloudfuse")},
4104+
blob.HTTPHeaders{
4105+
BlobContentMD5: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
4106+
},
41024107
nil,
41034108
)
4109+
s.assert.NoError(err)
41044110

41054111
prop, err := s.az.storage.GetAttr(ctx, name)
41064112
s.assert.NoError(err)
@@ -4170,11 +4176,14 @@ func (s *blockBlobTestSuite) TestInvalidMD5OnReadNoVaildate() {
41704176
_ = os.Remove(name)
41714177

41724178
blobClient := s.containerClient.NewBlobClient(name)
4173-
_, _ = blobClient.SetHTTPHeaders(
4179+
_, err = blobClient.SetHTTPHeaders(
41744180
context.Background(),
4175-
blob.HTTPHeaders{BlobContentMD5: []byte("cloudfuse")},
4181+
blob.HTTPHeaders{
4182+
BlobContentMD5: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
4183+
},
41764184
nil,
41774185
)
4186+
s.assert.NoError(err)
41784187

41794188
prop, err := s.az.storage.GetAttr(ctx, name)
41804189
s.assert.NoError(err)

0 commit comments

Comments
 (0)