public void ConvertToIValidationResultNull()
            {
                // Act
                var result = SymbolsValidationEntitiesService.ConvertToIValidationResult(null);

                // Assert
                Assert.Equal(ValidationStatus.NotStarted, result.Status);
            }
            public void ConvertToIValidationResultIngesting()
            {
                // Arrange
                SymbolsServerRequest request = new SymbolsServerRequest()
                {
                    RequestStatusKey = SymbolsPackageIngestRequestStatus.Ingesting
                };


                // Act
                var result = SymbolsValidationEntitiesService.ConvertToIValidationResult(request);

                // Assert
                Assert.Equal(ValidationStatus.Incomplete, result.Status);
            }
Ejemplo n.º 3
0
        /// <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="IValidationResult"/>.</returns>
        public async Task <IValidationResult> StartAsync(IValidationRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var result = SymbolsValidationEntitiesService.ConvertToIValidationResult(await _symbolsValidationEntitiesService.GetSymbolsServerRequestAsync(request));

            if (result.Status != ValidationStatus.NotStarted)
            {
                _logger.LogWarning(
                    "Symbol ingestion for {PackageId} {PackageNormalizedVersion} {SymbolsPackageKey} has already started.",
                    request.PackageId,
                    request.PackageVersion,
                    request.PackageKey);

                return(result);
            }

            _telemetryService.TrackSymbolsMessageEnqueued(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.ConvertToIValidationResult(savedSymbolRequest));
        }
Ejemplo n.º 4
0
        public async Task <IValidationResult> GetResultAsync(IValidationRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var result = SymbolsValidationEntitiesService.ConvertToIValidationResult(await _symbolsValidationEntitiesService.GetSymbolsServerRequestAsync(request));

            _logger.LogInformation(
                "Symbols status {Status} for PackageId: {PackageId}, PackageNormalizedVersion {PackageNormalizedVersion}, SymbolsPackageKey {SymbolsPackageKey} ValidationId {ValidationId}",
                result.Status,
                request.PackageId,
                request.PackageVersion,
                request.PackageKey,
                request.ValidationId);

            return(result);
        }