From 3b5f925a9ac99477dd58386b3ea143c60221f997 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Mon, 13 Jan 2025 10:56:33 -0500 Subject: [PATCH 01/26] change tests to LiveOnly --- .../tests/PauseResumeTransferTests.cs | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 278a223cf4839..baace67b60da1 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -231,8 +231,8 @@ private async Task CreateSingleLongTransferAsync( return await manager.StartTransferAsync(sourceResource, destinationResource, transferOptions); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -285,8 +285,8 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) Assert.IsTrue(File.Exists(fileName.FullPath)); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -355,8 +355,8 @@ public void TryPauseTransferAsync_Error() Assert.CatchAsync(async () => await transferManager.PauseTransferIfRunningAsync("bad transfer Id")); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -414,8 +414,8 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer Assert.IsTrue(File.Exists(fileName.FullPath)); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -494,8 +494,8 @@ await AssertSourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -570,7 +570,6 @@ await AssertSourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] [Test] [LiveOnly] [TestCase(TransferDirection.Upload)] @@ -815,8 +814,8 @@ private async Task CreateDirectoryLongTransferAsync( return await manager.StartTransferAsync(sourceResource, destinationResource, transferOptions); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -866,8 +865,8 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT Assert.AreEqual(TransferState.Paused, transfer.Status.State); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -918,8 +917,8 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire Assert.AreEqual(TransferState.Paused, transfer.Status.State); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -976,8 +975,8 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio Assert.AreEqual(TransferState.Paused, transfer.Status.State); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -1064,8 +1063,8 @@ await AssertDirectorySourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Download)] [TestCase(TransferDirection.Copy)] @@ -1152,7 +1151,6 @@ await AssertDirectorySourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Ignore("Likely to fail in pipelines and takes a while to run.")] [Test, Pairwise] [LiveOnly] public async Task ResumeTransferAsync_Directory_Large( From 61d6cab24f4644b9399f6a45dba2e846d05c4458 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 14 Jan 2025 16:28:30 -0500 Subject: [PATCH 02/26] use OAuth for blobProvider + add more delay for pause --- .../tests/PauseResumeTransferTests.cs | 25 ++++++++++--------- .../tests/Shared/TestEventsRaised.cs | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index baace67b60da1..a85e13f5ae3cd 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -244,7 +244,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -298,7 +298,7 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -368,7 +368,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -428,7 +428,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -508,7 +508,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -582,7 +582,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) BlobServiceClient service = GetServiceClient_OAuth(); await using DisposingBlobContainer blobContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -620,6 +620,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); + await Task.Delay(150); // Act - Resume Job TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync(transfer.Id); @@ -828,7 +829,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -880,7 +881,7 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -932,7 +933,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -990,7 +991,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -1078,7 +1079,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { @@ -1172,7 +1173,7 @@ public async Task ResumeTransferAsync_Directory_Large( await using DisposingBlobContainer sourceContainer = await GetTestContainerAsync(service); await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); - BlobsStorageResourceProvider blobProvider = new(GetSharedKeyCredential()); + BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index e963783e239a3..1bf77413ef880 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -377,7 +377,7 @@ internal static List PopulateTestOptions(int transferCount, re /// private Task WaitForStatusEventsAsync() { - return Task.Delay(100); + return Task.Delay(200); } } } From 794eaf797625483266ebe72632f8679b963b3888 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 14 Jan 2025 17:26:11 -0500 Subject: [PATCH 03/26] Do not fail test if transfer Completes before Pause is issued in ResumeTransferAsync_Directory_Large --- .../tests/PauseResumeTransferTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index a85e13f5ae3cd..9832cb7d17894 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1210,6 +1210,20 @@ public async Task ResumeTransferAsync_Directory_Large( // Pause Transfer CancellationTokenSource pauseCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30)); await transferManager.PauseTransferIfRunningAsync(transfer.Id, pauseCancellation.Token); + + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Verify transfer + await AssertDirectorySourceAndDestinationAsync( + transferType: transferType, + sourceResource: sResource as StorageResourceContainer, + destinationResource: dResource as StorageResourceContainer, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Resume Transfer From a79323efd89ed01b111c62e4ab01f96ff9f07556 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 14 Jan 2025 21:32:16 -0500 Subject: [PATCH 04/26] merged main --- .../tests/PauseResumeTransferTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index c8448ab39fcd4..11eb03e57b2e1 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1209,7 +1209,7 @@ public async Task ResumeTransferAsync_Directory_Large( // Pause Transfer CancellationTokenSource pauseCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, pauseCancellation.Token); + await transferManager.PauseTransferAsync(transfer.Id, pauseCancellation.Token); // we might have already completed the transfer before we could pause it if (transfer.Status.State == TransferState.Completed) From 69870591d907730f5571a0b8ba82bca9e4532acb Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 15 Jan 2025 11:11:23 -0500 Subject: [PATCH 05/26] disable ResumeTransferAsync_Directory_Large --- .../tests/PauseResumeTransferTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 11eb03e57b2e1..2f02c08ca2465 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1152,6 +1152,7 @@ await AssertDirectorySourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } + [Ignore("Likely to fail in pipelines and takes a while to run.")] [Test, Pairwise] [LiveOnly] public async Task ResumeTransferAsync_Directory_Large( From 3cc09bf43fcc9e679091557ca056bf61097fe731 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 15 Jan 2025 14:50:58 -0500 Subject: [PATCH 06/26] extend cancellation time limit --- .../tests/PauseResumeTransferTests.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 2f02c08ca2465..2abcb815dd857 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -270,7 +270,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -324,7 +324,7 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -394,14 +394,14 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); - CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -459,7 +459,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused @@ -477,7 +477,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferId: transfer.Id, transferOptions: resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -539,7 +539,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused @@ -553,7 +553,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transfer.Id, resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -617,14 +617,14 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) TransferOperation transfer = await transferManager.StartTransferAsync(source, destination); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); await Task.Delay(150); // Act - Resume Job TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync(transfer.Id); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -858,7 +858,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -910,7 +910,7 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -962,14 +962,14 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); - CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); await testEventsRaised.AssertPausedCheck(); From e6673e345ae15894246c60c0c77a3a34b2f9e6e3 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 15 Jan 2025 18:45:02 -0500 Subject: [PATCH 07/26] add tiny delay between start transfer and pause --- .../tests/PauseResumeTransferTests.cs | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 2abcb815dd857..c129e34dae7e7 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -270,7 +270,8 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -324,7 +325,8 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -394,14 +396,15 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); - CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -459,7 +462,8 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused @@ -477,7 +481,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferId: transfer.Id, transferOptions: resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -539,7 +543,8 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused @@ -553,7 +558,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transfer.Id, resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -617,14 +622,15 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) TransferOperation transfer = await transferManager.StartTransferAsync(source, destination); // Act - Pause Job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); await Task.Delay(150); // Act - Resume Job TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync(transfer.Id); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -858,7 +864,8 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -910,7 +917,8 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -962,14 +970,15 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio localProvider: localProvider); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await Task.Delay(10); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); - CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); await testEventsRaised.AssertPausedCheck(); @@ -1029,6 +1038,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - Pause Job + await Task.Delay(10); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1117,6 +1127,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job + await Task.Delay(10); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); From c056e8dd2133aa8f9f1a3f5ece01caa55d76eb09 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 15 Jan 2025 20:35:53 -0500 Subject: [PATCH 08/26] decreased delay --- .../tests/PauseResumeTransferTests.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index c129e34dae7e7..83cf3320f5ea6 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -270,7 +270,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -325,7 +325,7 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -396,7 +396,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -462,7 +462,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -543,7 +543,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -622,7 +622,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) TransferOperation transfer = await transferManager.StartTransferAsync(source, destination); // Act - Pause Job - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -864,7 +864,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -917,7 +917,7 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -970,7 +970,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio localProvider: localProvider); // Act - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1038,7 +1038,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - Pause Job - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1127,7 +1127,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - Pause Job - await Task.Delay(10); + await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); From 38ec7f945e9a8478f1627899f7da8de96ab2305d Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 16 Jan 2025 14:30:48 -0500 Subject: [PATCH 09/26] accounted for if transfer completes before pause + lowered asserts --- .../tests/PauseResumeTransferTests.cs | 133 +++++++++++++++++- .../tests/Shared/TestEventsRaised.cs | 19 +-- 2 files changed, 137 insertions(+), 15 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 83cf3320f5ea6..5853679493925 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -275,6 +275,18 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Check if Job Plan File exists in checkpointer path. + JobPartPlanFileName name = new JobPartPlanFileName( + checkpointerPath: checkpointerDirectory.DirectoryPath, + id: transfer.Id, + jobPartNumber: 0); + Assert.IsTrue(File.Exists(name.FullPath)); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -330,6 +342,18 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Check if Job Plan File exists in checkpointer path. + JobPartPlanFileName name = new JobPartPlanFileName( + checkpointerPath: checkpointerDirectory.DirectoryPath, + id: transfer.Id, + jobPartNumber: 0); + Assert.IsTrue(File.Exists(name.FullPath)); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -401,6 +425,18 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Check if Job Plan File exists in checkpointer path. + JobPartPlanFileName name = new JobPartPlanFileName( + checkpointerPath: checkpointerDirectory.DirectoryPath, + id: transfer.Id, + jobPartNumber: 0); + Assert.IsTrue(File.Exists(name.FullPath)); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -466,7 +502,20 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - Confirm we've paused + // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Verify transfer + await AssertDirectorySourceAndDestinationAsync( + transferType: transferType, + sourceResource: sResource as StorageResourceContainer, + destinationResource: dResource as StorageResourceContainer, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); await testEventsRaised.AssertPausedCheck(); @@ -481,11 +530,11 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferId: transfer.Id, transferOptions: resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertSingleCompletedCheck(); + await testEventRaised2.AssertTransferCompleted(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -547,7 +596,20 @@ public async Task ResumeTransferAsync(TransferDirection transferType) CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - Confirm we've paused + // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Verify transfer + await AssertDirectorySourceAndDestinationAsync( + transferType: transferType, + sourceResource: sResource as StorageResourceContainer, + destinationResource: dResource as StorageResourceContainer, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); await testEventsRaised.AssertPausedCheck(); @@ -562,7 +624,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertSingleCompletedCheck(); + await testEventRaised2.AssertTransferCompleted(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -625,6 +687,19 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) await Task.Delay(5); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + BlobUriBuilder builder1 = new BlobUriBuilder(destination.Uri); + BlockBlobClient blob1 = blobContainer.Container.GetBlockBlobClient(builder1.BlobName); + BlobProperties props1 = (await blob1.GetPropertiesAsync()).Value; + Assert.That(props1.Metadata, Is.EqualTo(metadata)); + Assert.AreEqual(testOptions.AccessTier.Value, new AccessTier(props1.AccessTier)); + Assert.AreEqual(testOptions.ContentLanguage.Value, props1.ContentLanguage); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); await Task.Delay(150); @@ -869,6 +944,12 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); } @@ -922,6 +1003,12 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); } @@ -975,6 +1062,12 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + Assert.Pass(); + } await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -1043,6 +1136,19 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Verify transfer + await AssertDirectorySourceAndDestinationAsync( + transferType: transferType, + sourceResource: sResource as StorageResourceContainer, + destinationResource: dResource as StorageResourceContainer, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); await testEventsRaised.AssertPausedCheck(); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; @@ -1061,7 +1167,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertContainerCompletedCheck(partCount - completedBeforePause); + await testEventRaised2.AssertTransferCompleted(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -1132,6 +1238,19 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused + // we might have already completed the transfer before we could pause it + if (transfer.Status.State == TransferState.Completed) + { + Assert.IsTrue(transfer.HasCompleted); + // Verify transfer + await AssertDirectorySourceAndDestinationAsync( + transferType: transferType, + sourceResource: sResource as StorageResourceContainer, + destinationResource: dResource as StorageResourceContainer, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container); + Assert.Pass(); + } Assert.AreEqual(TransferState.Paused, transfer.Status.State); await testEventsRaised.AssertPausedCheck(); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; @@ -1150,7 +1269,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventsRaised2.AssertContainerCompletedCheck(partCount - completedBeforePause); + await testEventsRaised2.AssertTransferCompleted(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index 4b0581cbb7255..6df38e6dc3644 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -161,6 +161,16 @@ public async Task AssertSingleCompletedCheck() StatusEvents.Select(e => e.TransferStatus).ToArray()); } + /// + /// This asserts that the transfer has reached completion. + /// + public async Task AssertTransferCompleted() + { + await WaitForStatusEventsAsync().ConfigureAwait(false); + Assert.IsEmpty(SkippedEvents); + Assert.AreEqual(TransferState.Completed, StatusEvents.Last().TransferStatus.State); + } + /// /// This asserts that the expected events occurred during a single transfer that is expected /// to have a at the end without any @@ -324,15 +334,8 @@ public async Task AssertContainerCompletedWithSkippedCheck(int expectedSkipCount public async Task AssertPausedCheck() { await WaitForStatusEventsAsync().ConfigureAwait(false); - - AssertUnexpectedFailureCheck(); Assert.IsEmpty(SkippedEvents); - - AssertTransferStatusCollection( - new TransferStatus[] { - InProgressStatus, - new TransferStatusInternal(TransferState.Paused, false, false) }, - StatusEvents.Select(e => e.TransferStatus).ToArray()); + Assert.AreEqual(TransferState.Paused, StatusEvents.Last().TransferStatus.State); } /// From d2ef55ce547ee67e998bf92105992d091abbea45 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 16 Jan 2025 14:41:38 -0500 Subject: [PATCH 10/26] small --- .../tests/PauseResumeTransferTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 5853679493925..09087193a14b3 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -530,7 +530,7 @@ await AssertDirectorySourceAndDestinationAsync( transferId: transfer.Id, transferOptions: resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(25)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert From 4235a28a9952fdb5865bc7fe85519de8df0bd37f Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 16 Jan 2025 15:36:28 -0500 Subject: [PATCH 11/26] adjust cancel time --- .../tests/PauseResumeTransferTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 09087193a14b3..42906db903c84 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -271,7 +271,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) // Act await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -530,7 +530,7 @@ await AssertDirectorySourceAndDestinationAsync( transferId: transfer.Id, transferOptions: resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(25)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert From 9e1bcc2a0f7b36af2de6d8bc45c379656fb6974c Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Fri, 17 Jan 2025 17:34:42 -0500 Subject: [PATCH 12/26] added AssertContainerCompleted --- .../tests/PauseResumeTransferTests.cs | 6 ++++-- .../tests/Shared/TestEventsRaised.cs | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 42906db903c84..4472d4ecb1d26 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1140,6 +1140,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans if (transfer.Status.State == TransferState.Completed) { Assert.IsTrue(transfer.HasCompleted); + await testEventsRaised.AssertTransferCompleted(); // Verify transfer await AssertDirectorySourceAndDestinationAsync( transferType: transferType, @@ -1167,7 +1168,7 @@ await AssertDirectorySourceAndDestinationAsync( await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertTransferCompleted(); + await testEventRaised2.AssertContainerCompleted(partCount - completedBeforePause); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -1242,6 +1243,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) if (transfer.Status.State == TransferState.Completed) { Assert.IsTrue(transfer.HasCompleted); + await testEventsRaised.AssertTransferCompleted(); // Verify transfer await AssertDirectorySourceAndDestinationAsync( transferType: transferType, @@ -1269,7 +1271,7 @@ await AssertDirectorySourceAndDestinationAsync( await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventsRaised2.AssertTransferCompleted(); + await testEventsRaised2.AssertContainerCompleted(partCount - completedBeforePause); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index 6df38e6dc3644..97633cb8c492c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -244,6 +244,14 @@ public async Task AssertContainerCompletedCheck(int transferCount) StatusEvents.Select(e => e.TransferStatus).ToArray()); } + public async Task AssertContainerCompleted(int transferCount) + { + await WaitForStatusEventsAsync().ConfigureAwait(false); + Assert.IsEmpty(SkippedEvents); + Assert.AreEqual(transferCount, SingleCompletedEvents.Count); + Assert.AreEqual(TransferState.Completed, StatusEvents.Last().TransferStatus.State); + } + /// /// This asserts that the expected events occurred during a container transfer that is expected /// to have a at the end without any skips. From 30f6467b0b29110907e723d30ab7aa65ebf4eac8 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Fri, 17 Jan 2025 23:48:06 -0500 Subject: [PATCH 13/26] small complete assert --- .../tests/PauseResumeTransferTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 4472d4ecb1d26..9cfd68d889ebc 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -507,6 +507,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) if (transfer.Status.State == TransferState.Completed) { Assert.IsTrue(transfer.HasCompleted); + await testEventsRaised.AssertTransferCompleted(); // Verify transfer await AssertDirectorySourceAndDestinationAsync( transferType: transferType, @@ -601,6 +602,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) if (transfer.Status.State == TransferState.Completed) { Assert.IsTrue(transfer.HasCompleted); + await testEventsRaised.AssertTransferCompleted(); // Verify transfer await AssertDirectorySourceAndDestinationAsync( transferType: transferType, From e0b36445704c5ee340a66087aa09686721b2eb85 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 21 Jan 2025 12:40:45 -0500 Subject: [PATCH 14/26] Added retry --- .../tests/PauseResumeTransferTests.cs | 601 ++++++++---------- 1 file changed, 272 insertions(+), 329 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 9cfd68d889ebc..78f47bfec7e95 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -231,6 +231,32 @@ private async Task CreateSingleLongTransferAsync( return await manager.StartTransferAsync(sourceResource, destinationResource, transferOptions); } + public static async Task Retry(int attempts, Func> action) + { + if (attempts <= 0) + { + throw new ArgumentException("Attempts must be greater than zero.", nameof(attempts)); + } + + Exception lastException = null; + + for (int i = 0; i < attempts; i++) + { + try + { + return await action(); + } + catch (Exception ex) + { + lastException = ex; + Console.WriteLine($"Attempt {i + 1} failed: {ex.Message}"); + } + } + + // If all attempts fail, throw the last exception + throw lastException; + } + [Test] [LiveOnly] [TestCase(TransferDirection.Upload)] @@ -256,39 +282,32 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - // Check if Job Plan File exists in checkpointer path. - JobPartPlanFileName name = new JobPartPlanFileName( - checkpointerPath: checkpointerDirectory.DirectoryPath, - id: transfer.Id, - jobPartNumber: 0); - Assert.IsTrue(File.Exists(name.FullPath)); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -323,39 +342,32 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - // Check if Job Plan File exists in checkpointer path. - JobPartPlanFileName name = new JobPartPlanFileName( - checkpointerPath: checkpointerDirectory.DirectoryPath, - id: transfer.Id, - jobPartNumber: 0); - Assert.IsTrue(File.Exists(name.FullPath)); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -406,44 +418,32 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); - - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => { - Assert.IsTrue(transfer.HasCompleted); - // Check if Job Plan File exists in checkpointer path. - JobPartPlanFileName name = new JobPartPlanFileName( - checkpointerPath: checkpointerDirectory.DirectoryPath, - id: transfer.Id, - jobPartNumber: 0); - Assert.IsTrue(File.Exists(name.FullPath)); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -489,36 +489,27 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) blobProvider: blobProvider, localProvider: localProvider); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - Pause Job - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => { - Assert.IsTrue(transfer.HasCompleted); - await testEventsRaised.AssertTransferCompleted(); - // Verify transfer - await AssertDirectorySourceAndDestinationAsync( - transferType: transferType, - sourceResource: sResource as StorageResourceContainer, - destinationResource: dResource as StorageResourceContainer, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container); - Assert.Pass(); - } - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - await testEventsRaised.AssertPausedCheck(); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); // Act - Resume Job TransferOptions resumeOptions = new TransferOptions() @@ -584,36 +575,27 @@ public async Task ResumeTransferAsync(TransferDirection transferType) blobProvider: blobProvider, localProvider: localProvider); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - Pause Job - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => { - Assert.IsTrue(transfer.HasCompleted); - await testEventsRaised.AssertTransferCompleted(); - // Verify transfer - await AssertDirectorySourceAndDestinationAsync( - transferType: transferType, - sourceResource: sResource as StorageResourceContainer, - destinationResource: dResource as StorageResourceContainer, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container); - Assert.Pass(); - } - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - await testEventsRaised.AssertPausedCheck(); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); // Act - Resume Job TransferOptions resumeOptions = new(); @@ -683,26 +665,20 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) destination = CreateBlobDestinationResource(blobContainer.Container, blobProvider, options: testOptions); } - TransferOperation transfer = await transferManager.StartTransferAsync(source, destination); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + transfer = await transferManager.StartTransferAsync(source, destination); - // Act - Pause Job - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - BlobUriBuilder builder1 = new BlobUriBuilder(destination.Uri); - BlockBlobClient blob1 = blobContainer.Container.GetBlockBlobClient(builder1.BlobName); - BlobProperties props1 = (await blob1.GetPropertiesAsync()).Value; - Assert.That(props1.Metadata, Is.EqualTo(metadata)); - Assert.AreEqual(testOptions.AccessTier.Value, new AccessTier(props1.AccessTier)); - Assert.AreEqual(testOptions.ContentLanguage.Value, props1.ContentLanguage); - Assert.Pass(); - } - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); await Task.Delay(150); // Act - Resume Job @@ -924,36 +900,35 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 4; - TransferOperation transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 4; + transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); } [Test] @@ -983,36 +958,35 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 10; - TransferOperation transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 10; + transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); } [Test] @@ -1042,36 +1016,35 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 4; - TransferOperation transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // In case we Complete the transfer first, keep retrying until we can Pause + TransferOperation transfer = await Retry(6, async () => + { + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 4; + transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - Assert.Pass(); - } - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return transfer; + }); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); @@ -1123,37 +1096,29 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans destinationContainer: destinationContainer.Container, blobProvider: blobProvider, localProvider: localProvider); + TransferOperation transfer = new(); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - Pause Job - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - Confirm we've paused - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) + // In case we Complete the transfer first, keep retrying until we can Pause + (transfer, testEventsRaised) = await Retry(6, async () => { - Assert.IsTrue(transfer.HasCompleted); - await testEventsRaised.AssertTransferCompleted(); - // Verify transfer - await AssertDirectorySourceAndDestinationAsync( - transferType: transferType, - sourceResource: sResource as StorageResourceContainer, - destinationResource: dResource as StorageResourceContainer, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container); - Assert.Pass(); - } - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - await testEventsRaised.AssertPausedCheck(); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return (transfer, testEventsRaised); + }); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; // Act - Resume Job @@ -1226,37 +1191,29 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) destinationContainer: destinationContainer.Container, blobProvider: blobProvider, localProvider: localProvider); + TransferOperation transfer = new(); - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - TransferOperation transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - Pause Job - await Task.Delay(5); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - Confirm we've paused - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) + // In case we Complete the transfer first, keep retrying until we can Pause + (transfer, testEventsRaised) = await Retry(6, async () => { - Assert.IsTrue(transfer.HasCompleted); - await testEventsRaised.AssertTransferCompleted(); - // Verify transfer - await AssertDirectorySourceAndDestinationAsync( - transferType: transferType, - sourceResource: sResource as StorageResourceContainer, - destinationResource: dResource as StorageResourceContainer, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container); - Assert.Pass(); - } - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - await testEventsRaised.AssertPausedCheck(); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + await Task.Delay(5); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + return (transfer, testEventsRaised); + }); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; // Act - Resume Job @@ -1345,20 +1302,6 @@ public async Task ResumeTransferAsync_Directory_Large( // Pause Transfer CancellationTokenSource pauseCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30)); await transferManager.PauseTransferAsync(transfer.Id, pauseCancellation.Token); - - // we might have already completed the transfer before we could pause it - if (transfer.Status.State == TransferState.Completed) - { - Assert.IsTrue(transfer.HasCompleted); - // Verify transfer - await AssertDirectorySourceAndDestinationAsync( - transferType: transferType, - sourceResource: sResource as StorageResourceContainer, - destinationResource: dResource as StorageResourceContainer, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container); - Assert.Pass(); - } Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Resume Transfer From aea32e047cf432c1cadfdcdd1a46bf03b4e5a36a Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 21 Jan 2025 16:29:51 -0500 Subject: [PATCH 15/26] More chunks = hopefully slower transfer --- .../tests/PauseResumeTransferTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 78f47bfec7e95..ee981a79f68cd 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1080,7 +1080,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans TransferOptions transferOptions = new TransferOptions() { InitialTransferSize = Constants.KB, - MaximumTransferChunkSize = Constants.KB + MaximumTransferChunkSize = Constants.KB / 2 }; TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; @@ -1175,7 +1175,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) TransferOptions transferOptions = new TransferOptions() { InitialTransferSize = Constants.KB, - MaximumTransferChunkSize = Constants.KB + MaximumTransferChunkSize = Constants.KB / 2 }; TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; From e5e782e4b7ab440cd99b8f15ec2f97c3c91cedf0 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Tue, 21 Jan 2025 17:08:26 -0500 Subject: [PATCH 16/26] reduced delay --- .../tests/PauseResumeTransferTests.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index ee981a79f68cd..a7670725dcfd6 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -299,7 +299,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -359,7 +359,7 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -435,7 +435,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -501,7 +501,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -587,7 +587,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transferOptions: transferOptions); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -671,7 +671,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) transfer = await transferManager.StartTransferAsync(source, destination); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -920,7 +920,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -978,7 +978,7 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1036,7 +1036,7 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio localProvider: localProvider); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1110,7 +1110,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); @@ -1205,7 +1205,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - await Task.Delay(5); + await Task.Delay(1); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); From 74df2b5ce54ec5db52b825b20e1d7297e602f397 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 22 Jan 2025 14:30:31 -0500 Subject: [PATCH 17/26] pause hang fix --- .../tests/PauseResumeTransferTests.cs | 460 +++++++----------- .../src/TransferJobInternal.cs | 2 +- 2 files changed, 184 insertions(+), 278 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index a7670725dcfd6..bc439ad49efdb 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -231,32 +231,6 @@ private async Task CreateSingleLongTransferAsync( return await manager.StartTransferAsync(sourceResource, destinationResource, transferOptions); } - public static async Task Retry(int attempts, Func> action) - { - if (attempts <= 0) - { - throw new ArgumentException("Attempts must be greater than zero.", nameof(attempts)); - } - - Exception lastException = null; - - for (int i = 0; i < attempts; i++) - { - try - { - return await action(); - } - catch (Exception ex) - { - lastException = ex; - Console.WriteLine($"Attempt {i + 1} failed: {ex.Message}"); - } - } - - // If all attempts fail, throw the last exception - throw lastException; - } - [Test] [LiveOnly] [TestCase(TransferDirection.Upload)] @@ -282,32 +256,26 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -342,32 +310,26 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -418,32 +380,26 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - transferType: transferType, - localDirectory: localDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 100, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + transferType: transferType, + localDirectory: localDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 100, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -489,27 +445,21 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) blobProvider: blobProvider, localProvider: localProvider); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Act - Resume Job TransferOptions resumeOptions = new TransferOptions() @@ -575,27 +525,21 @@ public async Task ResumeTransferAsync(TransferDirection transferType) blobProvider: blobProvider, localProvider: localProvider); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateSingleLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateSingleLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Act - Resume Job TransferOptions resumeOptions = new(); @@ -665,20 +609,14 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) destination = CreateBlobDestinationResource(blobContainer.Container, blobProvider, options: testOptions); } - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - transfer = await transferManager.StartTransferAsync(source, destination); + TransferOperation transfer = await transferManager.StartTransferAsync(source, destination); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + Assert.AreEqual(TransferState.Paused, transfer.Status.State); await Task.Delay(150); // Act - Resume Job @@ -900,35 +838,29 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 4; - transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 4; + TransferOperation transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); } [Test] @@ -958,35 +890,29 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 10; - transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 10; + TransferOperation transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); } [Test] @@ -1016,35 +942,29 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio TransferOptions transferOptions = new TransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); - // In case we Complete the transfer first, keep retrying until we can Pause - TransferOperation transfer = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - int partCount = 4; - transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - transferType: transferType, - sourceDirectory: sourceDirectory.DirectoryPath, - destinationDirectory: destinationDirectory.DirectoryPath, - sourceContainer: sourceContainer.Container, - destinationContainer: destinationContainer.Container, - size: Constants.KB * 4, - transferCount: partCount, - transferOptions: transferOptions, - blobProvider: blobProvider, - localProvider: localProvider); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + int partCount = 4; + TransferOperation transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + transferType: transferType, + sourceDirectory: sourceDirectory.DirectoryPath, + destinationDirectory: destinationDirectory.DirectoryPath, + sourceContainer: sourceContainer.Container, + destinationContainer: destinationContainer.Container, + size: Constants.KB * 4, + transferCount: partCount, + transferOptions: transferOptions, + blobProvider: blobProvider, + localProvider: localProvider); - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return transfer; - }); + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); @@ -1096,29 +1016,22 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans destinationContainer: destinationContainer.Container, blobProvider: blobProvider, localProvider: localProvider); - TransferOperation transfer = new(); - // In case we Complete the transfer first, keep retrying until we can Pause - (transfer, testEventsRaised) = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return (transfer, testEventsRaised); - }); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; // Act - Resume Job @@ -1191,29 +1104,22 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) destinationContainer: destinationContainer.Container, blobProvider: blobProvider, localProvider: localProvider); - TransferOperation transfer = new(); - // In case we Complete the transfer first, keep retrying until we can Pause - (transfer, testEventsRaised) = await Retry(6, async () => - { - // Add long-running job to pause, if the job is not big enough - // then the job might finish before we can pause it. - transfer = await CreateDirectoryLongTransferAsync( - manager: transferManager, - sourceResource: sResource, - destinationResource: dResource, - transferOptions: transferOptions); - - // Act - await Task.Delay(1); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); - await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(TransferState.Paused, transfer.Status.State); - return (transfer, testEventsRaised); - }); + // Add long-running job to pause, if the job is not big enough + // then the job might finish before we can pause it. + TransferOperation transfer = await CreateDirectoryLongTransferAsync( + manager: transferManager, + sourceResource: sResource, + destinationResource: dResource, + transferOptions: transferOptions); + + // Act + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); + + // Assert + await testEventsRaised.AssertPausedCheck(); + Assert.AreEqual(TransferState.Paused, transfer.Status.State); int completedBeforePause = testEventsRaised.SingleCompletedEvents.Count; // Act - Resume Job diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs index 152ebf4b79c0a..a14a23f368345 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs @@ -300,7 +300,6 @@ public virtual async IAsyncEnumerable ProcessJobToJobPartAsync( { // Single resource transfer, we can skip to chunking the job. part = await _createJobPartSingleAsync(this, partNumber).ConfigureAwait(false); - AppendJobPart(part); await OnAllResourcesEnumeratedAsync().ConfigureAwait(false); } catch (Exception ex) @@ -308,6 +307,7 @@ public virtual async IAsyncEnumerable ProcessJobToJobPartAsync( await InvokeFailedArgAsync(ex).ConfigureAwait(false); yield break; } + AppendJobPart(part); yield return part; } else From 04aa106457bf8f3eb04709238699beba7f45cc98 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 22 Jan 2025 14:33:25 -0500 Subject: [PATCH 18/26] revert --- .../tests/PauseResumeTransferTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index bc439ad49efdb..1ae65e6469abb 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -1000,7 +1000,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans TransferOptions transferOptions = new TransferOptions() { InitialTransferSize = Constants.KB, - MaximumTransferChunkSize = Constants.KB / 2 + MaximumTransferChunkSize = Constants.KB }; TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; @@ -1026,7 +1026,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -1088,7 +1088,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) TransferOptions transferOptions = new TransferOptions() { InitialTransferSize = Constants.KB, - MaximumTransferChunkSize = Constants.KB / 2 + MaximumTransferChunkSize = Constants.KB }; TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; @@ -1114,7 +1114,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert From f285d1c1833abf92af33b80c9da1f6a6310a0d58 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 22 Jan 2025 17:47:36 -0500 Subject: [PATCH 19/26] Resolved bug where resumed single resource transfer can be enumerated --- .../Azure.Storage.DataMovement/src/TransferJobInternal.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs index a14a23f368345..4b3818a5b1dba 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs @@ -299,8 +299,8 @@ public virtual async IAsyncEnumerable ProcessJobToJobPartAsync( try { // Single resource transfer, we can skip to chunking the job. - part = await _createJobPartSingleAsync(this, partNumber).ConfigureAwait(false); await OnAllResourcesEnumeratedAsync().ConfigureAwait(false); + part = await _createJobPartSingleAsync(this, partNumber).ConfigureAwait(false); } catch (Exception ex) { From 1cb57fa2312e158b98dc4d17aba53c63bd0436f9 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Wed, 22 Jan 2025 18:08:57 -0500 Subject: [PATCH 20/26] minor test changes --- .../tests/PauseResumeTransferTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 1ae65e6469abb..707f78113138f 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -476,7 +476,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertTransferCompleted(); + await testEventRaised2.AssertSingleCompletedCheck(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -552,7 +552,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertTransferCompleted(); + await testEventRaised2.AssertSingleCompletedCheck(); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -1026,7 +1026,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -1048,7 +1048,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventRaised2.AssertContainerCompleted(partCount - completedBeforePause); + await testEventRaised2.AssertContainerCompletedCheck(partCount - completedBeforePause); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); @@ -1114,7 +1114,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -1136,7 +1136,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert - await testEventsRaised2.AssertContainerCompleted(partCount - completedBeforePause); + await testEventsRaised2.AssertContainerCompletedCheck(partCount - completedBeforePause); Assert.AreEqual(TransferState.Completed, resumeTransfer.Status.State); Assert.IsTrue(resumeTransfer.HasCompleted); From 260bc991e2a6542e231c6cb56074e0330021200b Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 23 Jan 2025 11:44:12 -0500 Subject: [PATCH 21/26] do not allow single resource transfers to be enumerated --- .../Azure.Storage.DataMovement/src/TransferJobInternal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs index 4b3818a5b1dba..068d29f8cc7d4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs @@ -299,8 +299,8 @@ public virtual async IAsyncEnumerable ProcessJobToJobPartAsync( try { // Single resource transfer, we can skip to chunking the job. - await OnAllResourcesEnumeratedAsync().ConfigureAwait(false); part = await _createJobPartSingleAsync(this, partNumber).ConfigureAwait(false); + await OnAllResourcesEnumeratedAsync().ConfigureAwait(false); } catch (Exception ex) { @@ -342,7 +342,7 @@ public virtual async IAsyncEnumerable ProcessJobToJobPartAsync( yield break; } - if (!isEnumerationComplete) + if (!isEnumerationComplete && !_isSingleResource) { await foreach (JobPartInternal jobPartInternal in EnumerateAndCreateJobPartsAsync().ConfigureAwait(false)) { From 93c2f4691579757995c9ef3d6b0306975b210edd Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 23 Jan 2025 12:08:25 -0500 Subject: [PATCH 22/26] revert --- .../tests/PauseResumeTransferTests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 707f78113138f..432f44b3710ee 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -401,6 +401,11 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); + CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); + + Assert.AreEqual(TransferState.Paused, transfer.Status.State); + // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( checkpointerPath: checkpointerDirectory.DirectoryPath, @@ -1026,7 +1031,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert @@ -1114,7 +1119,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) transferOptions: transferOptions); // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert From 8206970de520fa605a42e98739e95dbd66972feb Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 23 Jan 2025 12:50:28 -0500 Subject: [PATCH 23/26] merge conflict resolution --- .../tests/PauseResumeTransferTests.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 4bb92ce6eb5e7..ab42186ff9dbb 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -236,7 +236,6 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -288,7 +287,6 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -356,7 +354,6 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -414,7 +411,6 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -492,7 +488,6 @@ public async Task ResumeTransferAsync(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -564,7 +559,6 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) await using DisposingBlobContainer blobContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -802,7 +796,6 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -852,7 +845,6 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -902,7 +894,6 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -958,7 +949,6 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -1044,7 +1034,6 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), @@ -1137,7 +1126,6 @@ public async Task ResumeTransferAsync_Directory_Large( await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(service); BlobsStorageResourceProvider blobProvider = new(TestEnvironment.Credential); - LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), From 8e2c825ebef6efc057ba184a7e8ad37b45ee0d6c Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Thu, 23 Jan 2025 16:01:36 -0500 Subject: [PATCH 24/26] temp disable ResumeTransferAsync_Options --- .../tests/PauseResumeTransferTests.cs | 4 ++-- .../tests/Shared/TestEventsRaised.cs | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index ab42186ff9dbb..8b65428354ff2 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -546,8 +546,8 @@ await AssertSourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Test] - [LiveOnly] + [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] + [RecordedTest] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Copy)] public async Task ResumeTransferAsync_Options(TransferDirection transferType) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index 97633cb8c492c..afbd9232a23a2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -161,16 +161,6 @@ public async Task AssertSingleCompletedCheck() StatusEvents.Select(e => e.TransferStatus).ToArray()); } - /// - /// This asserts that the transfer has reached completion. - /// - public async Task AssertTransferCompleted() - { - await WaitForStatusEventsAsync().ConfigureAwait(false); - Assert.IsEmpty(SkippedEvents); - Assert.AreEqual(TransferState.Completed, StatusEvents.Last().TransferStatus.State); - } - /// /// This asserts that the expected events occurred during a single transfer that is expected /// to have a at the end without any @@ -244,14 +234,6 @@ public async Task AssertContainerCompletedCheck(int transferCount) StatusEvents.Select(e => e.TransferStatus).ToArray()); } - public async Task AssertContainerCompleted(int transferCount) - { - await WaitForStatusEventsAsync().ConfigureAwait(false); - Assert.IsEmpty(SkippedEvents); - Assert.AreEqual(transferCount, SingleCompletedEvents.Count); - Assert.AreEqual(TransferState.Completed, StatusEvents.Last().TransferStatus.State); - } - /// /// This asserts that the expected events occurred during a container transfer that is expected /// to have a at the end without any skips. From f1972dd023f320f22c3886a1cf29d33dabb59229 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Fri, 24 Jan 2025 13:36:41 -0500 Subject: [PATCH 25/26] Fix for jobPlanFile length bug --- .../src/BlobDestinationCheckpointDetails.cs | 14 +++++++------- .../tests/PauseResumeTransferTests.cs | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobDestinationCheckpointDetails.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobDestinationCheckpointDetails.cs index 28277106bd0d8..ebcbb0d05af08 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobDestinationCheckpointDetails.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobDestinationCheckpointDetails.cs @@ -127,7 +127,7 @@ public BlobDestinationCheckpointDetails( ContentEncoding = contentEncoding; IsContentEncodingSet = isContentEncodingSet; - ContentEncodingBytes = contentEncoding!= default ? Encoding.UTF8.GetBytes(contentEncoding) : Array.Empty(); + ContentEncodingBytes = contentEncoding != default ? Encoding.UTF8.GetBytes(contentEncoding) : Array.Empty(); ContentLanguage = contentLanguage; IsContentLanguageSet = isContentLanguageSet; @@ -434,27 +434,27 @@ private int CalculateLength() // Length is calculated based on whether the property is preserved. // If the property is preserved, the property's length is added to the total length. int length = DataMovementBlobConstants.DestinationCheckpointDetails.VariableLengthStartIndex; - if (!IsContentTypeSet) + if (IsContentTypeSet) { length += ContentTypeBytes.Length; } - if (!IsContentEncodingSet) + if (IsContentEncodingSet) { length += ContentEncodingBytes.Length; } - if (!IsContentLanguageSet) + if (IsContentLanguageSet) { length += ContentLanguageBytes.Length; } - if (!IsContentDispositionSet) + if (IsContentDispositionSet) { length += ContentDispositionBytes.Length; } - if (!IsCacheControlSet) + if (IsCacheControlSet) { length += CacheControlBytes.Length; } - if (!IsMetadataSet) + if (IsMetadataSet) { length += MetadataBytes.Length; } diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 8b65428354ff2..1bc5779bb0b10 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -529,7 +529,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) transfer.Id, resumeOptions); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert @@ -546,8 +546,8 @@ await AssertSourceAndDestinationAsync( destinationContainer: destinationContainer.Container); } - [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] - [RecordedTest] + [Test] + [LiveOnly] [TestCase(TransferDirection.Upload)] [TestCase(TransferDirection.Copy)] public async Task ResumeTransferAsync_Options(TransferDirection transferType) @@ -570,7 +570,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) Metadata metadata = DataProvider.BuildMetadata(); BlockBlobStorageResourceOptions testOptions = new() { - Metadata = DataProvider.BuildMetadata(), + Metadata = metadata, AccessTier = AccessTier.Cool, ContentLanguage = "en-US", }; @@ -601,7 +601,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) // Act - Resume Job TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync(transfer.Id); - CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + CancellationTokenSource waitTransferCompletion = new CancellationTokenSource(TimeSpan.FromSeconds(20)); await resumeTransfer.WaitForCompletionAsync(waitTransferCompletion.Token); // Assert From de37e57787ed28578d2e05657fae439142adaf67 Mon Sep 17 00:00:00 2001 From: nickliu-msft Date: Fri, 24 Jan 2025 15:45:48 -0500 Subject: [PATCH 26/26] lowered the cancellation time to 150ms --- .../Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index afbd9232a23a2..f00c3cc8e9ceb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -370,7 +370,7 @@ internal static List PopulateTestOptions(int transferCount, re /// private Task WaitForStatusEventsAsync() { - return Task.Delay(200); + return Task.Delay(150); } } }