Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Merge pull request #544 from NuGet/dev
Browse files Browse the repository at this point in the history
[ReleasePrep][2018.08.20]RI of dev into master
  • Loading branch information
loic-sharma authored Aug 20, 2018
2 parents d806e31 + aead8dc commit ec8adde
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private async Task<TimeSpan> UpdateValidationDurationAsync(PackageValidationSet
// is greater than the configured threshold. Service Bus message duplication for a single validation
// set will not cause multiple notices to be sent due to the row version on PackageValidationSet.
if (tooLongNotificationAllowed &&
validatingEntity.Status == PackageStatus.Validating &&
validationSetDuration > _validationConfiguration.ValidationSetNotificationTimeout &&
previousDuration <= _validationConfiguration.ValidationSetNotificationTimeout &&
await _validationStorageService.GetValidationSetCountAsync(validatingEntity) == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ public async Task DoesNotReEnqueueProcessingIfValidationSetTimesOut()
.Verify(x => x.DeletePackageForValidationSetAsync(It.IsAny<PackageValidationSet>()), Times.Never);
}

[Fact]
public async Task SendsValidatingTooLongMessageOnce()
[Theory]
[InlineData(PackageStatus.Available, false)]
[InlineData(PackageStatus.Deleted, false)]
[InlineData(PackageStatus.Validating, true)]
[InlineData(PackageStatus.FailedValidation, false)]
public async Task SendsValidatingTooLongMessageOnlyIfPackageIsInValidatingState(PackageStatus packageStatus, bool shouldSend)
{
const int postponeMinutes = 1;

Expand All @@ -130,6 +134,8 @@ public async Task SendsValidatingTooLongMessageOnce()
ValidationSet.Created = DateTime.UtcNow - TimeSpan.FromMinutes(21);
ValidationSet.Updated = DateTime.UtcNow - TimeSpan.FromMinutes(15);

PackageValidatingEntity.EntityRecord.PackageStatusKey = packageStatus;

ValidationStorageServiceMock
.Setup(s => s.UpdateValidationSetAsync(It.IsAny<PackageValidationSet>()))
.Callback<PackageValidationSet>(s => s.Updated = DateTime.UtcNow)
Expand All @@ -143,14 +149,28 @@ public async Task SendsValidatingTooLongMessageOnce()
var processor = CreateProcessor();
await processor.ProcessValidationOutcomeAsync(ValidationSet, PackageValidatingEntity, ProcessorStats);

TelemetryServiceMock
.Verify(t => t.TrackSentValidationTakingTooLongMessage(Package.PackageRegistration.Id, Package.NormalizedVersion, ValidationSet.ValidationTrackingId), Times.Once);
MessageServiceMock
.Verify(m => m.SendValidationTakingTooLongMessage(Package), Times.Once);
ValidationEnqueuerMock
.Verify(ve => ve.StartValidationAsync(It.IsAny<PackageValidationMessageData>(), It.IsAny<DateTimeOffset>()), Times.Once);
PackageFileServiceMock
.Verify(x => x.DeletePackageForValidationSetAsync(It.IsAny<PackageValidationSet>()), Times.Never);
if (shouldSend)
{
TelemetryServiceMock
.Verify(t => t.TrackSentValidationTakingTooLongMessage(Package.PackageRegistration.Id, Package.NormalizedVersion, ValidationSet.ValidationTrackingId), Times.Once);
MessageServiceMock
.Verify(m => m.SendValidationTakingTooLongMessage(Package), Times.Once);
ValidationEnqueuerMock
.Verify(ve => ve.StartValidationAsync(It.IsAny<PackageValidationMessageData>(), It.IsAny<DateTimeOffset>()), Times.Once);
PackageFileServiceMock
.Verify(x => x.DeletePackageForValidationSetAsync(It.IsAny<PackageValidationSet>()), Times.Never);
}
else
{
TelemetryServiceMock
.Verify(t => t.TrackSentValidationTakingTooLongMessage(Package.PackageRegistration.Id, Package.NormalizedVersion, ValidationSet.ValidationTrackingId), Times.Never);
MessageServiceMock
.Verify(m => m.SendValidationTakingTooLongMessage(Package), Times.Never);
ValidationEnqueuerMock
.Verify(ve => ve.StartValidationAsync(It.IsAny<PackageValidationMessageData>(), It.IsAny<DateTimeOffset>()), Times.Once);
PackageFileServiceMock
.Verify(x => x.DeletePackageForValidationSetAsync(It.IsAny<PackageValidationSet>()), Times.Never);
}

TelemetryServiceMock.ResetCalls();
MessageServiceMock.ResetCalls();
Expand Down

0 comments on commit ec8adde

Please sign in to comment.