Search in sources :

Example 81 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class OTelTraceSource method createAuthenticationProvider.

private GrpcAuthenticationProvider createAuthenticationProvider(final PluginFactory pluginFactory) {
    final PluginModel authenticationConfiguration = oTelTraceSourceConfig.getAuthentication();
    if (authenticationConfiguration == null || authenticationConfiguration.getPluginName().equals(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME)) {
        LOG.warn("Creating otel-trace-source without authentication. This is not secure.");
        LOG.warn("In order to set up Http Basic authentication for the otel-trace-source, go here: https://github.com/opensearch-project/data-prepper/tree/main/data-prepper-plugins/otel-trace-source#authentication-configurations");
    }
    final PluginSetting authenticationPluginSetting;
    if (authenticationConfiguration != null) {
        authenticationPluginSetting = new PluginSetting(authenticationConfiguration.getPluginName(), authenticationConfiguration.getPluginSettings());
    } else {
        authenticationPluginSetting = new PluginSetting(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME, Collections.emptyMap());
    }
    return pluginFactory.loadPlugin(GrpcAuthenticationProvider.class, authenticationPluginSetting);
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 82 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class AbstractBufferTest method setUp.

@BeforeEach
public void setUp() {
    MetricsTestUtil.initMetrics();
    testPluginSetting = new PluginSetting(BUFFER_NAME, Collections.emptyMap());
    testPluginSetting.setPipelineName(PIPELINE_NAME);
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 83 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class AbstractProcessorTest method testMetricsWithPluginSettingsConstructor.

@Test
public void testMetricsWithPluginSettingsConstructor() {
    final String processorName = "testProcessor";
    final String pipelineName = "testPipeline";
    MetricsTestUtil.initMetrics();
    PluginSetting pluginSetting = new PluginSetting(processorName, Collections.emptyMap());
    pluginSetting.setPipelineName(pipelineName);
    AbstractProcessor<Record<String>, Record<String>> processor = new ProcessorImpl(pluginSetting);
    processor.execute(Arrays.asList(new Record<>("Value1"), new Record<>("Value2"), new Record<>("Value3")));
    final List<Measurement> recordsInMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(pipelineName).add(processorName).add(MetricNames.RECORDS_IN).toString());
    final List<Measurement> recordsOutMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(pipelineName).add(processorName).add(MetricNames.RECORDS_OUT).toString());
    final List<Measurement> elapsedTimeMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(pipelineName).add(processorName).add(MetricNames.TIME_ELAPSED).toString());
    Assertions.assertEquals(1, recordsInMeasurements.size());
    Assertions.assertEquals(3.0, recordsInMeasurements.get(0).getValue(), 0);
    Assertions.assertEquals(1, recordsOutMeasurements.size());
    Assertions.assertEquals(6.0, recordsOutMeasurements.get(0).getValue(), 0);
    Assertions.assertEquals(3, elapsedTimeMeasurements.size());
    Assertions.assertEquals(1.0, MetricsTestUtil.getMeasurementFromList(elapsedTimeMeasurements, Statistic.COUNT).getValue(), 0);
    Assertions.assertTrue(MetricsTestUtil.isBetween(MetricsTestUtil.getMeasurementFromList(elapsedTimeMeasurements, Statistic.TOTAL_TIME).getValue(), 0.1, 0.2));
}
Also used : Measurement(io.micrometer.core.instrument.Measurement) Record(com.amazon.dataprepper.model.record.Record) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) StringJoiner(java.util.StringJoiner) Test(org.junit.jupiter.api.Test)

Example 84 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class AbstractSinkTest method testMetrics.

@Test
public void testMetrics() {
    final String sinkName = "testSink";
    final String pipelineName = "pipelineName";
    MetricsTestUtil.initMetrics();
    PluginSetting pluginSetting = new PluginSetting(sinkName, Collections.emptyMap());
    pluginSetting.setPipelineName(pipelineName);
    AbstractSink<Record<String>> abstractSink = new AbstractSinkImpl(pluginSetting);
    abstractSink.output(Arrays.asList(new Record<>(UUID.randomUUID().toString()), new Record<>(UUID.randomUUID().toString()), new Record<>(UUID.randomUUID().toString()), new Record<>(UUID.randomUUID().toString()), new Record<>(UUID.randomUUID().toString())));
    final List<Measurement> recordsInMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(pipelineName).add(sinkName).add(MetricNames.RECORDS_IN).toString());
    final List<Measurement> elapsedTimeMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(pipelineName).add(sinkName).add(MetricNames.TIME_ELAPSED).toString());
    Assert.assertEquals(1, recordsInMeasurements.size());
    Assert.assertEquals(5.0, recordsInMeasurements.get(0).getValue(), 0);
    Assert.assertEquals(3, elapsedTimeMeasurements.size());
    Assert.assertEquals(1.0, MetricsTestUtil.getMeasurementFromList(elapsedTimeMeasurements, Statistic.COUNT).getValue(), 0);
    Assert.assertTrue(MetricsTestUtil.isBetween(MetricsTestUtil.getMeasurementFromList(elapsedTimeMeasurements, Statistic.TOTAL_TIME).getValue(), 0.5, 0.6));
}
Also used : Measurement(io.micrometer.core.instrument.Measurement) Record(com.amazon.dataprepper.model.record.Record) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) StringJoiner(java.util.StringJoiner) Test(org.junit.Test)

Example 85 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class ServiceMapStatefulPrepperBenchmarks method setupServiceMapStatefulPrepper.

@Setup(Level.Trial)
public void setupServiceMapStatefulPrepper() {
    final PluginSetting pluginSetting = new PluginSetting("plugin", Collections.singletonMap("window_duration", windowDurationSeconds * 1000));
    serviceMapStatefulPrepper = new ServiceMapStatefulPrepper(pluginSetting);
}
Also used : ServiceMapStatefulPrepper(com.amazon.dataprepper.plugins.prepper.ServiceMapStatefulPrepper) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)150 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Test (org.junit.Test)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Record (com.amazon.dataprepper.model.record.Record)22 AsciiString (io.netty.util.AsciiString)16 Measurement (io.micrometer.core.instrument.Measurement)12 StringJoiner (java.util.StringJoiner)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 Map (java.util.Map)11 Path (java.nio.file.Path)9 Server (com.linecorp.armeria.server.Server)8 Before (org.junit.Before)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BlockingBuffer (com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer)7 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)7 PluginMetrics (com.amazon.dataprepper.metrics.PluginMetrics)6 CertificateProvider (com.amazon.dataprepper.plugins.certificate.CertificateProvider)6 ACMCertificateProvider (com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider)6