Search in sources :

Example 71 with PluginSetting

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

the class OtelMetricsSourceConfigTests method testValidConfigWithS3CertAndKey.

@Test
public void testValidConfigWithS3CertAndKey() {
    // Prepare
    final PluginSetting validPluginSettingWithS3CertAndKey = completePluginSettingForOtelMetricsSource(TEST_REQUEST_TIMEOUT_MS, TEST_PORT, false, false, false, true, TEST_KEY_CERT_S3, TEST_KEY_S3, TEST_THREAD_COUNT, TEST_MAX_CONNECTION_COUNT);
    validPluginSettingWithS3CertAndKey.getSettings().put(OTelMetricsSourceConfig.AWS_REGION, TEST_REGION);
    final OTelMetricsSourceConfig otelMetricsSourceConfig = OBJECT_MAPPER.convertValue(validPluginSettingWithS3CertAndKey.getSettings(), OTelMetricsSourceConfig.class);
    otelMetricsSourceConfig.validateAndInitializeCertAndKeyFileInS3();
    // Then
    assertEquals(TEST_REQUEST_TIMEOUT_MS, otelMetricsSourceConfig.getRequestTimeoutInMillis());
    assertEquals(TEST_PORT, otelMetricsSourceConfig.getPort());
    assertEquals(TEST_THREAD_COUNT, otelMetricsSourceConfig.getThreadCount());
    assertEquals(TEST_MAX_CONNECTION_COUNT, otelMetricsSourceConfig.getMaxConnectionCount());
    assertFalse(otelMetricsSourceConfig.hasHealthCheck());
    assertFalse(otelMetricsSourceConfig.hasProtoReflectionService());
    assertTrue(otelMetricsSourceConfig.isSsl());
    assertTrue(otelMetricsSourceConfig.isSslCertAndKeyFileInS3());
    assertEquals(TEST_KEY_CERT_S3, otelMetricsSourceConfig.getSslKeyCertChainFile());
    assertEquals(TEST_KEY_S3, otelMetricsSourceConfig.getSslKeyFile());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 72 with PluginSetting

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

the class OtelMetricsSourceConfigTests method testInvalidConfigWithEmptyKeyCert.

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

Example 73 with PluginSetting

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

the class CertificateProviderFactoryTest method getCertificateProviderS3ProviderSuccess.

@Test
public void getCertificateProviderS3ProviderSuccess() {
    final Map<String, Object> settingsMap = new HashMap<>();
    settingsMap.put("ssl", true);
    settingsMap.put("awsRegion", "us-east-1");
    settingsMap.put("sslKeyCertChainFile", "s3://data/certificate/test_cert.crt");
    settingsMap.put("sslKeyFile", "s3://data/certificate/test_decrypted_key.key");
    final PluginSetting pluginSetting = new PluginSetting(null, settingsMap);
    pluginSetting.setPipelineName("pipeline");
    oTelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelMetricsSourceConfig.class);
    oTelTraceSourceConfig.validateAndInitializeCertAndKeyFileInS3();
    certificateProviderFactory = new CertificateProviderFactory(oTelTraceSourceConfig);
    final CertificateProvider certificateProvider = certificateProviderFactory.getCertificateProvider();
    assertThat(certificateProvider, IsInstanceOf.instanceOf(S3CertificateProvider.class));
}
Also used : HashMap(java.util.HashMap) CertificateProvider(com.amazon.dataprepper.plugins.certificate.CertificateProvider) ACMCertificateProvider(com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider) FileCertificateProvider(com.amazon.dataprepper.plugins.certificate.file.FileCertificateProvider) S3CertificateProvider(com.amazon.dataprepper.plugins.certificate.s3.S3CertificateProvider) OTelMetricsSourceConfig(com.amazon.dataprepper.plugins.source.otelmetrics.OTelMetricsSourceConfig) S3CertificateProvider(com.amazon.dataprepper.plugins.certificate.s3.S3CertificateProvider) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 74 with PluginSetting

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

the class MetricsPluginGaugeTest method init.

@Before
public void init() {
    PluginSetting testsettings = new PluginSetting("testsettings", Collections.emptyMap());
    testsettings.setPipelineName("testpipeline");
    rawProcessor = new OTelMetricsRawProcessor(testsettings);
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Before(org.junit.Before)

Example 75 with PluginSetting

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

the class MetricsPluginSumTest method init.

@Before
public void init() {
    PluginSetting testsettings = new PluginSetting("testsettings", Collections.emptyMap());
    testsettings.setPipelineName("testpipeline");
    rawProcessor = new OTelMetricsRawProcessor(testsettings);
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Before(org.junit.Before)

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