Search in sources :

Example 1 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class DataPrepperAppConfigurationTest method testGivenPipelineConfigArgThenResultOfObjectMapperReadValueIsReturned.

@Test
public void testGivenPipelineConfigArgThenResultOfObjectMapperReadValueIsReturned() throws IOException {
    final DataPrepperArgs dataPrepperArgs = mock(DataPrepperArgs.class);
    final ObjectMapper objectMapper = mock(ObjectMapper.class);
    final DataPrepperConfiguration expected = mock(DataPrepperConfiguration.class);
    when(dataPrepperArgs.getDataPrepperConfigFileLocation()).thenReturn(TestDataProvider.VALID_SINGLE_PIPELINE_EMPTY_SOURCE_PLUGIN_FILE);
    when(objectMapper.readValue(any(File.class), eq(DataPrepperConfiguration.class))).thenReturn(expected);
    final DataPrepperConfiguration configuration = appConfiguration.dataPrepperConfiguration(dataPrepperArgs, objectMapper);
    assertThat(configuration, is(expected));
}
Also used : DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 2 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class DataPrepperAppConfigurationTest method testGivenNoPipelineConfigArgThenResultOfObjectMapperReadValueIsReturned.

@Test
public void testGivenNoPipelineConfigArgThenResultOfObjectMapperReadValueIsReturned() {
    final DataPrepperArgs dataPrepperArgs = mock(DataPrepperArgs.class);
    final ObjectMapper objectMapper = mock(ObjectMapper.class);
    final DataPrepperConfiguration configuration = appConfiguration.dataPrepperConfiguration(dataPrepperArgs, objectMapper);
    verify(dataPrepperArgs).getDataPrepperConfigFileLocation();
    assertThat(configuration, notNullValue());
}
Also used : DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 3 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenConfigWithNoCloudWatchMeterRegistryThenNoMeterRegistryCreated.

@Test
public void testGivenConfigWithNoCloudWatchMeterRegistryThenNoMeterRegistryCreated() {
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(MetricRegistryType.Prometheus));
    final MeterRegistry meterRegistry = metricsConfig.cloudWatchMeterRegistry(dataPrepperConfiguration, null);
    assertThat(meterRegistry, is(nullValue()));
}
Also used : DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenConfigWithEMFLoggingMeterRegistryThenMeterRegistryCreated.

@Test
public void testGivenConfigWithEMFLoggingMeterRegistryThenMeterRegistryCreated() {
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(MetricRegistryType.EmbeddedMetricsFormat));
    final MeterRegistry meterRegistry = metricsConfig.emfLoggingMeterRegistry(dataPrepperConfiguration);
    final Counter counter = meterRegistry.counter("counter");
    final List<Tag> commonTags = counter.getId().getConventionTags(meterRegistry.config().namingConvention());
    assertThat(meterRegistry, isA(EMFLoggingMeterRegistry.class));
    assertThat(commonTags.size(), equalTo(1));
    final Tag commonTag = commonTags.get(0);
    assertThat(commonTag.getKey(), equalTo(MetricNames.SERVICE_NAME));
    assertThat(commonTag.getValue(), equalTo(DataPrepper.getServiceNameForMetrics()));
}
Also used : Counter(io.micrometer.core.instrument.Counter) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) Tag(io.micrometer.core.instrument.Tag) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenConfigWithPrometheusMeterRegistryThenMeterRegistryCreated.

@Test
public void testGivenConfigWithPrometheusMeterRegistryThenMeterRegistryCreated() {
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(MetricRegistryType.Prometheus));
    final MeterRegistry meterRegistry = metricsConfig.prometheusMeterRegistry(dataPrepperConfiguration);
    assertThat(meterRegistry, isA(PrometheusMeterRegistry.class));
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DataPrepperConfiguration (com.amazon.dataprepper.parser.model.DataPrepperConfiguration)10 Test (org.junit.jupiter.api.Test)9 EMFLoggingMeterRegistry (com.amazon.dataprepper.meter.EMFLoggingMeterRegistry)6 CloudWatchMeterRegistry (io.micrometer.cloudwatch2.CloudWatchMeterRegistry)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)6 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)6 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 PluginModel (com.amazon.dataprepper.model.configuration.PluginModel)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Counter (io.micrometer.core.instrument.Counter)2 Tag (io.micrometer.core.instrument.Tag)2 CloudWatchMeterRegistryProvider (com.amazon.dataprepper.pipeline.server.CloudWatchMeterRegistryProvider)1 File (java.io.File)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1