Search in sources :

Example 76 with PluginSetting

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

the class OTelTraceGroupProcessorConfigTests method testInitialize.

@Test
public void testInitialize() {
    try (MockedStatic<ConnectionConfiguration> connectionConfigurationMockedStatic = Mockito.mockStatic(ConnectionConfiguration.class)) {
        connectionConfigurationMockedStatic.when(() -> ConnectionConfiguration.readConnectionConfiguration(any(PluginSetting.class))).thenReturn(connectionConfigurationMock);
        PluginSetting testPluginSetting = new PluginSetting("otel_trace_group", new HashMap<>());
        OTelTraceGroupProcessorConfig otelTraceGroupProcessorConfig = OTelTraceGroupProcessorConfig.buildConfig(testPluginSetting);
        assertEquals(connectionConfigurationMock, otelTraceGroupProcessorConfig.getEsConnectionConfig());
    }
}
Also used : ConnectionConfiguration(com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 77 with PluginSetting

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

the class IndexConfigurationTests method testReadIndexConfig_ServiceMapFlag.

@Test
public void testReadIndexConfig_ServiceMapFlag() {
    final PluginSetting pluginSetting = generatePluginSetting(null, true, null, null, null, null);
    final IndexConfiguration indexConfiguration = IndexConfiguration.readIndexConfig(pluginSetting);
    final URL expTemplateFile = indexConfiguration.getClass().getClassLoader().getResource(SERVICE_MAP_DEFAULT_TEMPLATE_FILE);
    assertEquals(IndexType.TRACE_ANALYTICS_SERVICE_MAP, indexConfiguration.getIndexType());
    assertEquals(TYPE_TO_DEFAULT_ALIAS.get(IndexType.TRACE_ANALYTICS_SERVICE_MAP), indexConfiguration.getIndexAlias());
    assertFalse(indexConfiguration.getIndexTemplate().isEmpty());
    assertEquals(5, indexConfiguration.getBulkSize());
    assertEquals("hashId", indexConfiguration.getDocumentIdField());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) URL(java.net.URL) Test(org.junit.Test)

Example 78 with PluginSetting

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

the class IndexConfigurationTests method testReadIndexConfig_InvalidIndexTypeValueString.

@Test
public void testReadIndexConfig_InvalidIndexTypeValueString() {
    final Map<String, Object> metadata = initializeConfigMetaData(null, null, null, null, null, null);
    metadata.put(INDEX_TYPE, "i-am-an-illegitimate-index-type");
    final PluginSetting pluginSetting = getPluginSetting(metadata);
    assertThrows(IllegalArgumentException.class, () -> IndexConfiguration.readIndexConfig(pluginSetting));
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 79 with PluginSetting

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

the class IndexConfigurationTests method testReadIndexConfigCustom.

@Test
public void testReadIndexConfigCustom() throws MalformedURLException {
    final String defaultTemplateFilePath = Objects.requireNonNull(getClass().getClassLoader().getResource(DEFAULT_TEMPLATE_FILE)).getFile();
    final String testIndexAlias = "foo";
    final long testBulkSize = 10L;
    final String testIdField = "someId";
    final PluginSetting pluginSetting = generatePluginSetting(false, false, testIndexAlias, defaultTemplateFilePath, testBulkSize, testIdField);
    final IndexConfiguration indexConfiguration = IndexConfiguration.readIndexConfig(pluginSetting);
    assertEquals(IndexType.CUSTOM, indexConfiguration.getIndexType());
    assertEquals(testIndexAlias, indexConfiguration.getIndexAlias());
    assertFalse(indexConfiguration.getIndexTemplate().isEmpty());
    assertEquals(testBulkSize, indexConfiguration.getBulkSize());
    assertEquals(testIdField, indexConfiguration.getDocumentIdField());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 80 with PluginSetting

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

the class IndexConfigurationTests method testReadIndexConfig_RawIndexType.

@Test
public void testReadIndexConfig_RawIndexType() {
    final Map<String, Object> metadata = initializeConfigMetaData(null, null, null, null, null, null);
    metadata.put(INDEX_TYPE, IndexType.TRACE_ANALYTICS_RAW.getValue());
    final PluginSetting pluginSetting = getPluginSetting(metadata);
    final IndexConfiguration indexConfiguration = IndexConfiguration.readIndexConfig(pluginSetting);
    final URL expTemplateFile = indexConfiguration.getClass().getClassLoader().getResource(RAW_DEFAULT_TEMPLATE_FILE);
    assertEquals(IndexType.TRACE_ANALYTICS_RAW, indexConfiguration.getIndexType());
    assertEquals(TYPE_TO_DEFAULT_ALIAS.get(IndexType.TRACE_ANALYTICS_RAW), indexConfiguration.getIndexAlias());
    assertFalse(indexConfiguration.getIndexTemplate().isEmpty());
    assertEquals(5, indexConfiguration.getBulkSize());
    assertEquals("spanId", indexConfiguration.getDocumentIdField());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) URL(java.net.URL) Test(org.junit.Test)

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