Search in sources :

Example 36 with PluginSetting

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

the class OTelTraceSourceTest method configureObjectUnderTest.

private void configureObjectUnderTest(final String recordType) {
    final Map<String, Object> settingsMap = new HashMap<>();
    settingsMap.put("record_type", recordType);
    settingsMap.put("request_timeout", 5);
    settingsMap.put(SSL, false);
    pluginSetting = new PluginSetting("otel_trace", settingsMap);
    pluginSetting.setPipelineName("pipeline");
    pluginMetrics = PluginMetrics.fromNames("otel_trace", "pipeline");
    oTelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class);
    SOURCE = new OTelTraceSource(oTelTraceSourceConfig, pluginMetrics, pluginFactory);
}
Also used : HashMap(java.util.HashMap) AsciiString(io.netty.util.AsciiString) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 37 with PluginSetting

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

the class OTelTraceSourceTest method getBuffer.

private BlockingBuffer<Record<Object>> getBuffer() {
    final HashMap<String, Object> integerHashMap = new HashMap<>();
    integerHashMap.put("buffer_size", 1);
    integerHashMap.put("batch_size", 1);
    return new BlockingBuffer<>(new PluginSetting("blocking_buffer", integerHashMap));
}
Also used : HashMap(java.util.HashMap) BlockingBuffer(com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer) AsciiString(io.netty.util.AsciiString) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 38 with PluginSetting

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

the class OtelTraceSourceConfigTests method testConfigWithValidRecordType.

@ParameterizedTest
@ValueSource(strings = { "otlp", "event" })
public void testConfigWithValidRecordType(final String recordType) {
    final PluginSetting pluginSetting = completePluginSettingForOtelTraceSource(TEST_REQUEST_TIMEOUT_MS, TEST_PORT, false, false, false, false, null, null, recordType, TEST_THREAD_COUNT, TEST_MAX_CONNECTION_COUNT);
    final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class);
    assertEquals(recordType, otelTraceSourceConfig.getRecordType().toString());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 39 with PluginSetting

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

the class OtelTraceSourceConfigTests method testValidConfigWithoutS3CertAndKey.

@Test
public void testValidConfigWithoutS3CertAndKey() {
    // Prepare
    final PluginSetting validPluginSetting = completePluginSettingForOtelTraceSource(TEST_REQUEST_TIMEOUT_MS, TEST_PORT, true, true, false, true, TEST_KEY_CERT, TEST_KEY, RecordType.OTLP.toString(), TEST_THREAD_COUNT, TEST_MAX_CONNECTION_COUNT);
    // When
    final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(validPluginSetting.getSettings(), OTelTraceSourceConfig.class);
    otelTraceSourceConfig.validateAndInitializeCertAndKeyFileInS3();
    // Then
    assertEquals(TEST_REQUEST_TIMEOUT_MS, otelTraceSourceConfig.getRequestTimeoutInMillis());
    assertEquals(TEST_PORT, otelTraceSourceConfig.getPort());
    assertEquals(TEST_THREAD_COUNT, otelTraceSourceConfig.getThreadCount());
    assertEquals(TEST_MAX_CONNECTION_COUNT, otelTraceSourceConfig.getMaxConnectionCount());
    assertTrue(otelTraceSourceConfig.hasHealthCheck());
    assertTrue(otelTraceSourceConfig.hasProtoReflectionService());
    assertTrue(otelTraceSourceConfig.isSsl());
    assertFalse(otelTraceSourceConfig.isSslCertAndKeyFileInS3());
    assertEquals(TEST_KEY_CERT, otelTraceSourceConfig.getSslKeyCertChainFile());
    assertEquals(TEST_KEY, otelTraceSourceConfig.getSslKeyFile());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with PluginSetting

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

the class OtelTraceSourceConfigTests method testInvalidConfigWithEmptyKeyCert.

@Test
public void testInvalidConfigWithEmptyKeyCert() {
    // Prepare
    final PluginSetting sslEmptyKeyCertPluginSetting = completePluginSettingForOtelTraceSource(DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_PORT, false, false, false, true, "", TEST_KEY, RecordType.OTLP.toString(), DEFAULT_THREAD_COUNT, DEFAULT_MAX_CONNECTION_COUNT);
    final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(sslEmptyKeyCertPluginSetting.getSettings(), OTelTraceSourceConfig.class);
    // When/Then
    assertThrows(IllegalArgumentException.class, otelTraceSourceConfig::validateAndInitializeCertAndKeyFileInS3);
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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