public void CreateFromValidationRequestValidRequest() { // Arrange var request = new NuGetValidationRequest(Guid.NewGuid(), PackageKey, PackageId, PackageVersion, ""); var requestName = "DummyRequestName"; // Act var result = SymbolsValidationEntitiesService.CreateFromValidationRequest(request, SymbolsPackageIngestRequestStatus.FailedIngestion, requestName); // Assert Assert.Equal(PackageKey, result.SymbolsKey); Assert.Equal(requestName, result.RequestName); Assert.Equal(SymbolsPackageIngestRequestStatus.FailedIngestion, result.RequestStatusKey); }
/// <summary> /// The pattern used for the StartAsync: /// 1. Check if an ingestion for the specific symbols package key was already started /// 2. Only if a ingestion was not started queue the message to be processed. /// 3. After the message is queued, update the SymbolServerRequests table. /// </summary> /// <param name="request">The request to be sent to the ingester job queue.</param> /// <returns>The operation status as <see cref="INuGetValidationResponse"/>.</returns> public async Task <INuGetValidationResponse> StartAsync(INuGetValidationRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var symbolsRequest = await _symbolsValidationEntitiesService.GetSymbolsServerRequestAsync(request); var response = SymbolsValidationEntitiesService.ToValidationResponse(symbolsRequest); if (response.Status != ValidationStatus.NotStarted) { _logger.LogWarning( "Symbol ingestion for {PackageId} {PackageNormalizedVersion} {SymbolsPackageKey} has already started.", request.PackageId, request.PackageVersion, request.PackageKey); return(response); } _telemetryService.TrackSymbolsMessageEnqueued(request.PackageId, request.PackageVersion, ValidatorName.SymbolsIngester, request.ValidationId); var message = await _symbolMessageEnqueuer.EnqueueSymbolsIngestionMessageAsync(request); var newSymbolsRequest = SymbolsValidationEntitiesService.CreateFromValidationRequest(request, SymbolsPackageIngestRequestStatus.Ingesting, message.RequestName); var savedSymbolRequest = await _symbolsValidationEntitiesService.AddSymbolsServerRequestAsync(newSymbolsRequest); if (savedSymbolRequest.RequestStatusKey != SymbolsPackageIngestRequestStatus.Ingesting) { _logger.LogWarning( "The symbols ingestion request already in the database. RequestStatus:{Status} for {PackageId} {PackageNormalizedVersion} {SymbolsPackageKey}.", newSymbolsRequest.RequestStatusKey, request.PackageId, request.PackageVersion, request.PackageKey); } else { _logger.LogInformation( "The symbols ingestion request added to the database. RequestStatus:{Status} for {PackageId} {PackageNormalizedVersion} {SymbolsPackageKey}.", newSymbolsRequest.RequestStatusKey, request.PackageId, request.PackageVersion, request.PackageKey); } return(SymbolsValidationEntitiesService.ToValidationResponse(savedSymbolRequest)); }