From 7411368867b802b89692f0ab3b5fa74f38927270 Mon Sep 17 00:00:00 2001 From: BarkovBG Date: Thu, 28 Mar 2024 13:30:55 +0000 Subject: [PATCH] log new crc32 for each block after writing --- .../disk_service_test/disk_relocation_test.go | 3 +++ .../disk_service_test/disk_service_test.go | 20 +++++++++------- .../internal/pkg/facade/testcommon/common.go | 24 ++++++++++++++++++- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_relocation_test.go b/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_relocation_test.go index 6469e11e5a4..18ff725748f 100644 --- a/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_relocation_test.go +++ b/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_relocation_test.go @@ -385,6 +385,7 @@ func migrateDiskInParallel( dstZoneNBSClient := testcommon.NewNbsClient(t, ctx, dstZoneID) err := dstZoneNBSClient.ValidateCrc32( + ctx, params.DiskID, diskSize, srcCrc32, @@ -394,6 +395,7 @@ func migrateDiskInParallel( } else { // All migrations are cancelled. Check that src disk is not affected. err := srcZoneNBSClient.ValidateCrc32( + ctx, params.DiskID, diskSize, srcCrc32, @@ -458,6 +460,7 @@ func successfullyMigrateEmptyDisk( dstZoneNBSClient := testcommon.NewNbsClient(t, ctx, params.DstZoneID) err = dstZoneNBSClient.ValidateCrc32( + ctx, params.DiskID, diskSize, srcCrc32, diff --git a/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_service_test.go b/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_service_test.go index 4925bd8b5f9..ce8ba956e4c 100644 --- a/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_service_test.go +++ b/cloud/disk_manager/internal/pkg/facade/disk_service_test/disk_service_test.go @@ -131,6 +131,7 @@ func TestDiskServiceCreateDiskFromImageWithForceNotLayered(t *testing.T) { nbsClient := testcommon.NewNbsClient(t, ctx, "zone-a") err = nbsClient.ValidateCrc32( + ctx, diskID, testcommon.GetRawImageSize(t), testcommon.GetRawImageCrc32(t), @@ -307,6 +308,7 @@ func TestDiskServiceCreateDisksFromImageWithConfiguredPool(t *testing.T) { diskID := fmt.Sprintf("%v%v", t.Name(), i) err = nbsClient.ValidateCrc32( + ctx, diskID, imageSize, imageCrc32, @@ -442,7 +444,7 @@ func testCreateDiskFromIncrementalSnapshot( crc32, blocksCrc32, err := nbsClient.CalculateCrc32(diskID1, diskSize) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID2, diskSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID2, diskSize, crc32, blocksCrc32) require.NoError(t, err) testcommon.CheckConsistency(t, ctx) @@ -540,10 +542,10 @@ func TestDiskServiceCreateDiskFromSnapshot(t *testing.T) { require.NoError(t, err) require.Equal(t, float64(1), diskMeta.Progress) - err = nbsClient.ValidateCrc32(diskID1, diskSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID1, diskSize, crc32, blocksCrc32) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID2, diskSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID2, diskSize, crc32, blocksCrc32) require.NoError(t, err) testcommon.CheckConsistency(t, ctx) @@ -622,10 +624,10 @@ func TestDiskServiceCreateDiskFromImage(t *testing.T) { err = internal_client.WaitOperation(ctx, client, operation.Id) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID1, diskSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID1, diskSize, crc32, blocksCrc32) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID2, diskSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID2, diskSize, crc32, blocksCrc32) require.NoError(t, err) testcommon.CheckConsistency(t, ctx) @@ -754,13 +756,13 @@ func TestDiskServiceCreateDiskFromSnapshotOfOverlayDisk(t *testing.T) { err = internal_client.WaitOperation(ctx, client, operation.Id) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID1, imageSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID1, imageSize, crc32, blocksCrc32) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID2, imageSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID2, imageSize, crc32, blocksCrc32) require.NoError(t, err) - err = nbsClient.ValidateCrc32(diskID3, imageSize, crc32, blocksCrc32) + err = nbsClient.ValidateCrc32(ctx, diskID3, imageSize, crc32, blocksCrc32) require.NoError(t, err) testcommon.CheckConsistency(t, ctx) @@ -1147,6 +1149,7 @@ func TestDiskServiceCreateEncryptedDiskFromSnapshot(t *testing.T) { require.ErrorContains(t, err, "encryption mode should be the same") err = nbsClient.ValidateCrc32WithEncryption( + ctx, diskID1, diskSize, encryptionDesc, @@ -1155,6 +1158,7 @@ func TestDiskServiceCreateEncryptedDiskFromSnapshot(t *testing.T) { ) require.NoError(t, err) err = nbsClient.ValidateCrc32WithEncryption( + ctx, diskID2, diskSize, encryptionDesc, diff --git a/cloud/disk_manager/internal/pkg/facade/testcommon/common.go b/cloud/disk_manager/internal/pkg/facade/testcommon/common.go index 2804f4050be..708d9f08306 100644 --- a/cloud/disk_manager/internal/pkg/facade/testcommon/common.go +++ b/cloud/disk_manager/internal/pkg/facade/testcommon/common.go @@ -433,6 +433,14 @@ func FillEncryptedDisk( if err != nil { return 0, []uint32{}, 0, err } + + logging.Debug( + ctx, + "%v block with index %v crc32 now is %v", + diskID, + startIndex+uint64(blockIndex), + blockAcc.Sum32(), + ) blocksCrc32 = append(blocksCrc32, blockAcc.Sum32()) } } @@ -476,10 +484,11 @@ func GoWriteRandomBlocksToNbsDisk( dice := rand.Intn(2) var err error + blockAcc := crc32.NewIEEE() + data := make([]byte, blockSize) switch dice { case 0: - data := make([]byte, blockSize) rand.Read(data) if bytes.Equal(data, zeroes) { logging.Debug(ctx, "rand generated all zeroes") @@ -493,6 +502,19 @@ func GoWriteRandomBlocksToNbsDisk( if err != nil { return err } + + _, err = blockAcc.Write(data) + if err != nil { + return err + } + + logging.Debug( + ctx, + "%v block with index %v crc32 now is %v", + diskID, + blockIndex, + blockAcc.Sum32(), + ) } return nil