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 a96c20d6005..76eec9384e6 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 @@ -610,20 +610,11 @@ func TestDiskServiceMigrateDisk(t *testing.T) { successfullyMigrateDisk(t, ctx, client, params) - reqCtx := testcommon.GetRequestContext(t, ctx) - operation, err := client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) + testcommon.DeleteDisk(t, ctx, client, diskID) // Check that disk is deleted. srcZoneNBSClient := testcommon.NewNbsClient(t, ctx, params.SrcZoneID) - _, err = srcZoneNBSClient.Describe(ctx, params.DiskID) + _, err := srcZoneNBSClient.Describe(ctx, params.DiskID) require.Error(t, err) require.ErrorContains(t, err, "Path not found") 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 41bf834942d..10fe1ff890e 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 @@ -228,16 +228,7 @@ func TestDiskServiceDeleteDiskWhenCreationIsInFlight(t *testing.T) { <-time.After(time.Second) - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err := client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) + testcommon.DeleteDisk(t, ctx, client, diskID) _ = internal_client.WaitOperation(ctx, client, createOp.Id) @@ -448,27 +439,8 @@ func testCreateDiskFromIncrementalSnapshot( err = nbsClient.ValidateCrc32(ctx, diskID2, diskContentInfo) require.NoError(t, err) - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err = client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID1, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) - - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err = client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID2, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) + testcommon.DeleteDisk(t, ctx, client, diskID1) + testcommon.DeleteDisk(t, ctx, client, diskID2) testcommon.CheckConsistency(t, ctx) } diff --git a/cloud/disk_manager/internal/pkg/facade/private_service_test/private_service_test.go b/cloud/disk_manager/internal/pkg/facade/private_service_test/private_service_test.go index a6d9355ddba..4aa0420b5c3 100644 --- a/cloud/disk_manager/internal/pkg/facade/private_service_test/private_service_test.go +++ b/cloud/disk_manager/internal/pkg/facade/private_service_test/private_service_test.go @@ -228,16 +228,7 @@ func TestPrivateServiceRetireBaseDisksUsingBaseDiskAsSrc(t *testing.T) { err = nbsClient.ValidateCrc32(ctx, diskID, diskContentInfo) require.NoError(t, err) - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err = client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) + testcommon.DeleteDisk(t, ctx, client, diskID) testcommon.CheckConsistency(t, ctx) } @@ -492,27 +483,8 @@ func TestPrivateServiceDeletePool(t *testing.T) { err = internal_client.WaitOperation(ctx, client, operation.Id) require.NoError(t, err) - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err = client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID1, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) - - reqCtx = testcommon.GetRequestContext(t, ctx) - operation, err = client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ - DiskId: &disk_manager.DiskId{ - DiskId: diskID2, - }, - }) - require.NoError(t, err) - require.NotEmpty(t, operation) - err = internal_client.WaitOperation(ctx, client, operation.Id) - require.NoError(t, err) + testcommon.DeleteDisk(t, ctx, client, diskID1) + testcommon.DeleteDisk(t, ctx, client, diskID2) testcommon.CheckConsistency(t, ctx) } diff --git a/cloud/disk_manager/internal/pkg/facade/testcommon/common.go b/cloud/disk_manager/internal/pkg/facade/testcommon/common.go index 765a4f936cb..eb519cfca74 100644 --- a/cloud/disk_manager/internal/pkg/facade/testcommon/common.go +++ b/cloud/disk_manager/internal/pkg/facade/testcommon/common.go @@ -412,6 +412,26 @@ func CreateImage( return diskContentInfo } +func DeleteDisk( + t *testing.T, + ctx context.Context, + client sdk_client.Client, + diskID string, +) { + + reqCtx := GetRequestContext(t, ctx) + operation, err := client.DeleteDisk(reqCtx, &disk_manager.DeleteDiskRequest{ + DiskId: &disk_manager.DiskId{ + DiskId: diskID, + }, + }) + require.NoError(t, err) + require.NotEmpty(t, operation) + + err = internal_client.WaitOperation(ctx, client, operation.Id) + require.NoError(t, err) +} + //////////////////////////////////////////////////////////////////////////////// func newYDB(ctx context.Context) (*persistence.YDBClient, error) {