Exemple #1
0
        public void MetricsDeclaration_DeclarationWithMetadataThatDoesNotHaveTenantId_Fails()
        {
            // Arrange
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata(string.Empty)
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider, NullLogger <MetricsDeclarationValidationStep> .Instance);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            PromitorAssert.ValidationFailed(validationResult);
        }
        public void MetricsDeclaration_DeclarationWithMetadataThatDoesNotHaveSubscriptionId_Fails()
        {
            // Arrange
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata(subscriptionId: string.Empty)
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider, NullLogger <MetricsDeclarationValidationStep> .Instance);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            Assert.False(validationResult.IsSuccessful, "Validation is successful");
        }
        public void MetricsDeclaration_DeclarationWithMetadataThatDoesNotHaveResourceGroupName_Fails()
        {
            // Arrange
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata(resourceGroupName: string.Empty)
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            Assert.False(validationResult.IsSuccessful, "Validation is successful");
        }
Exemple #4
0
        public void MetricsDeclaration_WithoutDefaultScrapingSchedule_Fails()
        {
            // Arrange
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata()
                                 .WithDefaults(new MetricDefaultsV1())
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider, NullLogger <MetricsDeclarationValidationStep> .Instance);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            PromitorAssert.ValidationFailed(validationResult);
        }
        public void MetricsDeclaration_WithoutDefaultScrapingSchedule_Fails()
        {
            // Arrange
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata()
                                 .WithDefaults(new MetricDefaultsV1())
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            Assert.False(validationResult.IsSuccessful, "Validation is successful");
        }
Exemple #6
0
        public void MetricsDeclaration_DeclarationWithDuplicateMetricNames_Fails()
        {
            // Arrange
            const string metricName     = "my_metric";
            var          rawDeclaration = MetricsDeclarationBuilder.WithMetadata()
                                          .WithServiceBusMetric(metricName)
                                          .WithServiceBusMetric(metricName)
                                          .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider, NullLogger <MetricsDeclarationValidationStep> .Instance);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            PromitorAssert.ValidationFailed(validationResult);
        }
        public void MetricsDeclaration_DeclarationWithDuplicateMetricNames_Fails()
        {
            // Arrange
            const string metricName     = "my_metric";
            var          rawDeclaration = MetricsDeclarationBuilder.WithMetadata()
                                          .WithServiceBusMetric(metricName)
                                          .WithServiceBusMetric(metricName)
                                          .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            Assert.False(validationResult.IsSuccessful, "Validation is successful");
        }
Exemple #8
0
        public void MetricsDeclaration_WithInvalidDefaultMetricLimit_Fails(int metricLimit)
        {
            // Arrange
            var metricDefaults = new MetricDefaultsV1
            {
                Scraping = new ScrapingV1
                {
                    Schedule = @"0 * * ? * *"
                },
                Limit = metricLimit
            };
            var rawDeclaration = MetricsDeclarationBuilder.WithMetadata()
                                 .WithDefaults(metricDefaults)
                                 .Build(_mapper);
            var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, _mapper);

            // Act
            var scrapingScheduleValidationStep = new MetricsDeclarationValidationStep(metricsDeclarationProvider, NullLogger <MetricsDeclarationValidationStep> .Instance);
            var validationResult = scrapingScheduleValidationStep.Run();

            // Assert
            PromitorAssert.ValidationFailed(validationResult);
        }