Skip to content

Commit 63a37cb

Browse files
[Storage][DataMovement] Remove the sync WaitForCompletion for now (Azure#47774)
1 parent eb5a12d commit 63a37cb

File tree

13 files changed

+10
-515
lines changed

13 files changed

+10
-515
lines changed

sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Blobs",
5-
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_acf7c63811"
5+
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_3132ba5d1c"
66
}

sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_6238d37ed0"
5+
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_91bd99f1ca"
66
}

sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ internal TransferOperation() { }
194194
public Azure.Storage.DataMovement.TransferStatus Status { get { throw null; } }
195195
public Azure.Storage.DataMovement.TransferManager TransferManager { get { throw null; } }
196196
public virtual System.Threading.Tasks.Task PauseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
197-
public void WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
198197
public System.Threading.Tasks.Task WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
199198
}
200199
public partial class TransferOptions : System.IEquatable<Azure.Storage.DataMovement.TransferOptions>

sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net8.0.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ internal TransferOperation() { }
194194
public Azure.Storage.DataMovement.TransferStatus Status { get { throw null; } }
195195
public Azure.Storage.DataMovement.TransferManager TransferManager { get { throw null; } }
196196
public virtual System.Threading.Tasks.Task PauseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
197-
public void WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
198197
public System.Threading.Tasks.Task WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
199198
}
200199
public partial class TransferOptions : System.IEquatable<Azure.Storage.DataMovement.TransferOptions>

sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ internal TransferOperation() { }
194194
public Azure.Storage.DataMovement.TransferStatus Status { get { throw null; } }
195195
public Azure.Storage.DataMovement.TransferManager TransferManager { get { throw null; } }
196196
public virtual System.Threading.Tasks.Task PauseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
197-
public void WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
198197
public System.Threading.Tasks.Task WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
199198
}
200199
public partial class TransferOptions : System.IEquatable<Azure.Storage.DataMovement.TransferOptions>

sdk/storage/Azure.Storage.DataMovement/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement",
5-
"Tag": "net/storage/Azure.Storage.DataMovement_03db2933f4"
5+
"Tag": "net/storage/Azure.Storage.DataMovement_80d90a8906"
66
}

sdk/storage/Azure.Storage.DataMovement/src/TransferOperation.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,7 @@ internal TransferOperation(
6161
}
6262

6363
/// <summary>
64-
/// Ensures completion of the TransferOperation and attempts to get result
65-
/// </summary>
66-
public void WaitForCompletion(CancellationToken cancellationToken = default)
67-
{
68-
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
69-
WaitForCompletionAsync(cancellationToken).GetAwaiter().GetResult();
70-
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
71-
}
72-
73-
/// <summary>
74-
/// Waits until the data transfer itself has completed
64+
/// Waits until the transfer has completed.
7565
/// </summary>
7666
/// <param name="cancellationToken"></param>
7767
public async Task WaitForCompletionAsync(CancellationToken cancellationToken = default)
@@ -80,11 +70,11 @@ public async Task WaitForCompletionAsync(CancellationToken cancellationToken = d
8070
}
8171

8272
/// <summary>
83-
/// Attempts to pause the current Data Transfer.
73+
/// Attempts to pause the current transfer.
8474
/// </summary>
8575
/// <param name="cancellationToken"></param>
8676
/// <returns>
87-
/// Will return false if the data transfer has already been completed.
77+
/// Will return false if the transfer has already been completed.
8878
///
8979
/// Will return true if the pause has taken place.
9080
/// </returns>

sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -832,119 +832,6 @@ await TestTransferWithTimeout.WaitForCompletionAsync(
832832
Assert.AreEqual(true, transfer.Status.HasSkippedItems);
833833
}
834834

835-
[RecordedTest]
836-
public async Task StartTransfer_EnsureCompleted()
837-
{
838-
// Arrange
839-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
840-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
841-
842-
TransferOptions options = new TransferOptions();
843-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
844-
845-
// Create transfer to do a EnsureCompleted
846-
TransferOperation transfer = await CreateStartTransfer(
847-
source.Container,
848-
destination.Container,
849-
concurrency: 1,
850-
options: options);
851-
852-
// Act
853-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
854-
TestTransferWithTimeout.WaitForCompletion(
855-
transfer,
856-
testEventsRaised,
857-
cancellationTokenSource.Token);
858-
859-
// Assert
860-
await testEventsRaised.AssertSingleCompletedCheck();
861-
Assert.NotNull(transfer);
862-
Assert.IsTrue(transfer.HasCompleted);
863-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
864-
}
865-
866-
[RecordedTest]
867-
public async Task StartTransfer_EnsureCompleted_Failed()
868-
{
869-
// Arrange
870-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
871-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
872-
873-
TransferOptions options = new TransferOptions()
874-
{
875-
CreationPreference = StorageResourceCreationPreference.FailIfExists
876-
};
877-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
878-
879-
// Create transfer to do a AwaitCompletion
880-
TransferOperation transfer = await CreateStartTransfer(
881-
source.Container,
882-
destination.Container,
883-
concurrency: 1,
884-
createFailedCondition: true,
885-
options: options);
886-
887-
// Act
888-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
889-
TestTransferWithTimeout.WaitForCompletion(
890-
transfer,
891-
testEventsRaised,
892-
cancellationTokenSource.Token);
893-
894-
// Assert
895-
await testEventsRaised.AssertSingleFailedCheck(1);
896-
Assert.NotNull(transfer);
897-
Assert.IsTrue(transfer.HasCompleted);
898-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
899-
Assert.AreEqual(true, transfer.Status.HasFailedItems);
900-
var testException = testEventsRaised.FailedEvents.First().Exception;
901-
if (testException is RequestFailedException rfe)
902-
{
903-
Assert.That(rfe.ErrorCode, Does.Contain(_expectedOverwriteExceptionMessage));
904-
}
905-
else
906-
{
907-
Assert.IsTrue(testException.Message.Contains(_expectedOverwriteExceptionMessage));
908-
}
909-
}
910-
911-
[RecordedTest]
912-
public async Task StartTransfer_EnsureCompleted_Skipped()
913-
{
914-
// Arrange
915-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
916-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
917-
918-
// Create transfer options with Skipping available
919-
TransferOptions options = new TransferOptions()
920-
{
921-
CreationPreference = StorageResourceCreationPreference.SkipIfExists
922-
};
923-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
924-
925-
// Create transfer to do a EnsureCompleted
926-
TransferOperation transfer = await CreateStartTransfer(
927-
source.Container,
928-
destination.Container,
929-
concurrency: 1,
930-
createFailedCondition: true,
931-
options: options);
932-
933-
// Act
934-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
935-
TestTransferWithTimeout.WaitForCompletion(
936-
transfer,
937-
testEventsRaised,
938-
cancellationTokenSource.Token);
939-
940-
// Assert
941-
await testEventsRaised.AssertSingleSkippedCheck();
942-
Assert.NotNull(transfer);
943-
Assert.IsTrue(transfer.HasCompleted);
944-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
945-
Assert.AreEqual(true, transfer.Status.HasSkippedItems);
946-
}
947-
948835
private async Task CopyRemoteObjects_VerifyProperties(
949836
TSourceContainerClient sourceContainer,
950837
TDestinationContainerClient destinationContainer,

sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -793,115 +793,9 @@ await TestTransferWithTimeout.WaitForCompletionAsync(
793793
await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1);
794794
}
795795

796-
[RecordedTest]
797-
public async Task StartTransfer_EnsureCompleted()
798-
{
799-
// Arrange
800-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
801-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
802-
803-
// Create transfer to do a EnsureCompleted
804-
TransferOptions options = new TransferOptions();
805-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
806-
807-
TransferOperation transfer = await CreateStartTransfer(
808-
source.Container,
809-
destination.Container,
810-
1,
811-
options: options);
812-
813-
// Act
814-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
815-
TestTransferWithTimeout.WaitForCompletion(
816-
transfer,
817-
testEventsRaised,
818-
cancellationTokenSource.Token);
819-
820-
// Assert
821-
testEventsRaised.AssertUnexpectedFailureCheck();
822-
Assert.NotNull(transfer);
823-
Assert.IsTrue(transfer.HasCompleted);
824-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
825-
}
826-
827796
[Test]
828797
[LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717
829-
public async Task StartTransfer_EnsureCompleted_Failed()
830-
{
831-
// Arrange
832-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
833-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
834-
835-
TransferOptions options = new TransferOptions()
836-
{
837-
CreationPreference = StorageResourceCreationPreference.FailIfExists
838-
};
839-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
840-
841-
// Create transfer to do a AwaitCompletion
842-
TransferOperation transfer = await CreateStartTransfer(
843-
source.Container,
844-
destination.Container,
845-
1,
846-
createFailedCondition: true,
847-
options: options);
848-
849-
// Act
850-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
851-
TestTransferWithTimeout.WaitForCompletion(
852-
transfer,
853-
testEventsRaised,
854-
cancellationTokenSource.Token);
855-
856-
// Assert
857-
Assert.NotNull(transfer);
858-
Assert.IsTrue(transfer.HasCompleted);
859-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
860-
Assert.AreEqual(true, transfer.Status.HasFailedItems);
861-
await testEventsRaised.AssertContainerCompletedWithFailedCheck(1);
862-
Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains(_expectedOverwriteExceptionMessage));
863-
}
864-
865-
[RecordedTest]
866-
public async Task StartTransfer_EnsureCompleted_Skipped()
867-
{
868-
// Arrange
869-
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
870-
await using IDisposingContainer<TDestinationContainerClient> destination = await GetDestinationDisposingContainerAsync();
871-
872-
// Create transfer options with Skipping available
873-
TransferOptions options = new TransferOptions()
874-
{
875-
CreationPreference = StorageResourceCreationPreference.SkipIfExists
876-
};
877-
TestEventsRaised testEventsRaised = new TestEventsRaised(options);
878-
879-
// Create transfer to do a EnsureCompleted
880-
TransferOperation transfer = await CreateStartTransfer(
881-
source.Container,
882-
destination.Container,
883-
1,
884-
createFailedCondition: true,
885-
options: options);
886-
887-
// Act
888-
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
889-
TestTransferWithTimeout.WaitForCompletion(
890-
transfer,
891-
testEventsRaised,
892-
cancellationTokenSource.Token);
893-
894-
// Assert
895-
testEventsRaised.AssertUnexpectedFailureCheck();
896-
Assert.NotNull(transfer);
897-
Assert.IsTrue(transfer.HasCompleted);
898-
Assert.AreEqual(TransferState.Completed, transfer.Status.State);
899-
Assert.AreEqual(true, transfer.Status.HasSkippedItems);
900-
}
901-
902-
[Test]
903-
[LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717
904-
public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks()
798+
public async Task StartTransfer_AwaitCompletion_Failed_SmallChunks()
905799
{
906800
// Arrange
907801
await using IDisposingContainer<TSourceContainerClient> source = await GetSourceDisposingContainerAsync();
@@ -926,7 +820,7 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks()
926820

927821
// Act
928822
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
929-
TestTransferWithTimeout.WaitForCompletion(
823+
await TestTransferWithTimeout.WaitForCompletionAsync(
930824
transfer,
931825
testEventsRaised,
932826
cancellationTokenSource.Token);

0 commit comments

Comments
 (0)