Skip to content

Commit

Permalink
Update RetryFact (#207)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <vicchang@nvidia.com>
  • Loading branch information
mocsharp authored Oct 13, 2022
1 parent 71c7e56 commit 9068fc7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void GivenAPayloadAssembler_WhenInitialized_ExpectParametersToBeValidated
Assert.Throws<ArgumentNullException>(() => new PayloadAssembler(_options, _logger.Object, null));
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAFileStorageMetadata_WhenQueueingWihtoutSpecifyingATimeout_ExpectDefaultTimeoutToBeUsed()
{
var payloadAssembler = new PayloadAssembler(_options, _logger.Object, _serviceScopeFactory.Object);
Expand All @@ -88,7 +88,7 @@ public async Task GivenAFileStorageMetadata_WhenQueueingWihtoutSpecifyingATimeou
_cancellationTokenSource.Cancel();
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenFileStorageMetadataInTheDatabase_AtServiceStartup_ExpectPayloadsInCreatedStateToBeRemoved()
{
var dataset = new List<Payload>
Expand All @@ -110,7 +110,7 @@ public async Task GivenFileStorageMetadataInTheDatabase_AtServiceStartup_ExpectP
_repository.Verify(p => p.Remove(It.IsAny<Payload>()), Times.Exactly(2));
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayloadAssembler_WhenDisposed_ExpectResourceToBeCleanedUp()
{
var payloadAssembler = new PayloadAssembler(_options, _logger.Object, _serviceScopeFactory.Object);
Expand All @@ -126,7 +126,7 @@ public async Task GivenAPayloadAssembler_WhenDisposed_ExpectResourceToBeCleanedU
_logger.VerifyLoggingMessageBeginsWith($"Number of collections in queue", LogLevel.Trace, Times.Never());
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenFileStorageMetadata_WhenQueueingWithDatabaseError_ExpectToRetryXTimes()
{
int callCount = 0;
Expand All @@ -152,7 +152,7 @@ public async Task GivenFileStorageMetadata_WhenQueueingWithDatabaseError_ExpectT
_logger.VerifyLoggingMessageBeginsWith($"Number of buckets active: 1.", LogLevel.Trace, Times.AtLeastOnce());
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayloadThatHasNotCompleteUploads_WhenProcessedByTimedEvent_ExpectToBeAddedToQueue()
{
_repository.Setup(p => p.SaveChangesAsync(It.IsAny<CancellationToken>())).Callback(() =>
Expand All @@ -171,7 +171,7 @@ public async Task GivenAPayloadThatHasNotCompleteUploads_WhenProcessedByTimedEve
_logger.VerifyLoggingMessageBeginsWith($"Bucket A sent to processing queue", LogLevel.Information, Times.Never());
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayloadThatHasCompletedUploads_WhenProcessedByTimedEvent_ExpectToBeAddedToQueue()
{
var payloadAssembler = new PayloadAssembler(_options, _logger.Object, _serviceScopeFactory.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public PayloadMoveActionHandlerTest()
_options.Value.Storage.StorageServiceBucketName = "bucket";
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAPayloadMoveActionHandler_WhenInitialized_ExpectParametersToBeValidated()
{
Assert.Throws<ArgumentNullException>(() => new PayloadMoveActionHandler(null, null, null));
Expand All @@ -80,7 +80,7 @@ public void GivenAPayloadMoveActionHandler_WhenInitialized_ExpectParametersToBeV
_ = new PayloadMoveActionHandler(_serviceScopeFactory.Object, _logger.Object, _options);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayloadInIncorrectState_WhenHandlerIsCalled_ExpectExceptionToBeThrown()
{
var resetEvent = new ManualResetEventSlim();
Expand Down Expand Up @@ -144,7 +144,7 @@ public async Task GivenAPayload_WhenHandlerFailedToCopyFiles_ExpectToBePutBackIn
Assert.Equal(retryCount + 1, payload.RetryCount);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayloadThatHasReachedMaximumRetries_WhenHandlerFailedToCopyFiles_ExpectPayloadToBeDeleted()
{
var moveAction = new ActionBlock<Payload>(payload =>
Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task GivenAPayloadThatHasReachedMaximumRetries_WhenHandlerFailedToC
_repository.Verify(p => p.Remove(payload), Times.Once());
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAPayload_WhenAllFilesAreMove_ExpectPayloadToBeAddedToNotificationQueue()
{
var notifyEvent = new ManualResetEventSlim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ public PayloadNotificationServiceTest()
_logger.Setup(p => p.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAPayloadNotificationService_AtInitialization_ExpectParametersToBeValidated()
{
Assert.Throws<ArgumentNullException>(() => new PayloadNotificationService(null, null, null));
Assert.Throws<ArgumentNullException>(() => new PayloadNotificationService(_serviceScopeFactory.Object, null, null));
Assert.Throws<ArgumentNullException>(() => new PayloadNotificationService(_serviceScopeFactory.Object, _logger.Object, null));
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenThePayloadNotificationService_WhenStopAsyncIsCalled_ExpectServiceToStopAnyProcessing()
{
var payload = new Payload("test", Guid.NewGuid().ToString(), 100) { State = Payload.PayloadState.Move };
Expand All @@ -116,7 +116,7 @@ public async Task GivenThePayloadNotificationService_WhenStopAsyncIsCalled_Expec
_logger.VerifyLogging($"Uploading payload {payload.Id} to storage service at {_options.Value.Storage.StorageServiceBucketName}.", LogLevel.Information, Times.Never());
}

[RetryFact]
[RetryFact(10,200)]
public void GivenPayloadsStoredInTheDatabase_WhenServiceStarts_ExpectThePayloadsToBeRestored()
{
var testData = new List<Payload>
Expand All @@ -139,7 +139,7 @@ public void GivenPayloadsStoredInTheDatabase_WhenServiceStarts_ExpectThePayloads
_payloadNotificationActionHandler.Verify(p => p.NotifyAsync(It.IsAny<Payload>(), It.IsAny<ActionBlock<Payload>>(), It.IsAny<CancellationToken>()), Times.AtLeastOnce());
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAPayload_WhenDequedFromPayloadAssemblerAndFailedToBeProcessByTheMoveActionHandler()
{
var resetEvent = new ManualResetEventSlim();
Expand All @@ -157,7 +157,7 @@ public void GivenAPayload_WhenDequedFromPayloadAssemblerAndFailedToBeProcessByTh
resetEvent.Wait();
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAPayload_WhenDequedFromPayloadAssembler_ExpectThePayloadBeProcessedByTheMoveActionHandler()
{
var payload = new Payload("test", Guid.NewGuid().ToString(), 100) { State = Payload.PayloadState.Move };
Expand Down
4 changes: 2 additions & 2 deletions src/InformaticsGateway/Test/Services/Fhir/FhirServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public FhirServiceTest()
_options.Value.Storage.TemporaryDataStorage = TemporaryDataStorageLocation.Memory;
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAFhirService_WhenInitialized_ExpectParametersToBeValidated()
{
Assert.Throws<ArgumentNullException>(() => new FhirService(null, null));
Expand All @@ -94,7 +94,7 @@ public void GivenAFhirService_WhenInitialized_ExpectParametersToBeValidated()
new FhirService(_serviceScopeFactory.Object, _options);
}

[RetryFact]
[RetryFact(10,200)]
public async Task StoreAsync_WhenCalled_ShallValidateParametersAsync()
{
var correlationId = Guid.NewGuid().ToString();
Expand Down
12 changes: 6 additions & 6 deletions src/InformaticsGateway/Test/Services/Scu/ScuServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ScuServiceTest(DicomScpFixture dicomScp)
_dicomScp.Start(_port);
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAScuService_WhenInitialized_ExpectParametersToBeValidated()
{
Assert.Throws<ArgumentNullException>(() => new ScuService(null, null, null));
Expand All @@ -80,7 +80,7 @@ public void GivenAScuService_WhenInitialized_ExpectParametersToBeValidated()
_ = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
}

[RetryFact]
[RetryFact(10,200)]
public void GivenAScuService_WhenStartAsyncIsCalled_ExpectServiceStatusToBeSet()
{
var svc = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
Expand All @@ -89,7 +89,7 @@ public void GivenAScuService_WhenStartAsyncIsCalled_ExpectServiceStatusToBeSet()
Assert.Equal(ServiceStatus.Running, svc.Status);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenAValidDicomEntity_WhenRequestToCEcho_ExpectToReturnSucess()
{
var svc = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
Expand All @@ -106,7 +106,7 @@ public async Task GivenAValidDicomEntity_WhenRequestToCEcho_ExpectToReturnSucess
Assert.Empty(response.Message);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenACEchoRequest_WhenRejected_ReturnStatusAssociationRejected()
{
var svc = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
Expand All @@ -123,7 +123,7 @@ public async Task GivenACEchoRequest_WhenRejected_ReturnStatusAssociationRejecte
Assert.StartsWith("Association rejected", response.Message);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenACEchoRequest_WhenAborted_ReturnStatusAssociationAborted()
{
var svc = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
Expand All @@ -140,7 +140,7 @@ public async Task GivenACEchoRequest_WhenAborted_ReturnStatusAssociationAborted(
Assert.StartsWith("Association Abort", response.Message);
}

[RetryFact]
[RetryFact(10,200)]
public async Task GivenACEchoRequest_WhenRemoteServerIsUnreachable_ReturnStatusAssociationRejected()
{
var svc = new ScuService(_serviceScopeFactory.Object, _logger.Object, _options);
Expand Down

0 comments on commit 9068fc7

Please sign in to comment.