Search in sources :

Example 46 with PluginSetting

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

the class CertificateProviderFactoryTest method getCertificateProviderAcmProviderSuccess.

@Test
public void getCertificateProviderAcmProviderSuccess() {
    final Map<String, Object> settingsMap = new HashMap<>();
    settingsMap.put("useAcmCertForSSL", true);
    settingsMap.put("awsRegion", "us-east-1");
    settingsMap.put("acmCertificateArn", "arn:aws:acm:us-east-1:account:certificate/1234-567-856456");
    settingsMap.put("sslKeyCertChainFile", "data/certificate/test_cert.crt");
    settingsMap.put("sslKeyFile", "data/certificate/test_decrypted_key.key");
    final PluginSetting pluginSetting = new PluginSetting(null, settingsMap);
    pluginSetting.setPipelineName("pipeline");
    oTelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class);
    certificateProviderFactory = new CertificateProviderFactory(oTelTraceSourceConfig);
    final CertificateProvider certificateProvider = certificateProviderFactory.getCertificateProvider();
    assertThat(certificateProvider, IsInstanceOf.instanceOf(ACMCertificateProvider.class));
}
Also used : OTelTraceSourceConfig(com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSourceConfig) 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) ACMCertificateProvider(com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 47 with PluginSetting

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

the class MetricsPluginSummaryTest 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 48 with PluginSetting

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

the class OTelMetricsSource method createAuthenticationProvider.

private GrpcAuthenticationProvider createAuthenticationProvider(final PluginFactory pluginFactory) {
    final PluginModel authenticationConfiguration = oTelMetricsSourceConfig.getAuthentication();
    if (authenticationConfiguration == null || authenticationConfiguration.getPluginName().equals(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME)) {
        LOG.warn("Creating otel-metrics-source without authentication. This is not secure.");
        LOG.warn("In order to set up Http Basic authentication for the otel-metrics-source, go here: https://github.com/opensearch-project/data-prepper/tree/main/data-prepper-plugins/otel-metrics-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 49 with PluginSetting

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

the class OTelMetricsGrpcServiceTest method setup.

@BeforeEach
public void setup() {
    pluginSetting = new PluginSetting("OTelMetricsGrpcService", Collections.EMPTY_MAP);
    pluginSetting.setPipelineName("pipeline");
    PluginMetrics mockPluginMetrics = mock(PluginMetrics.class);
    when(mockPluginMetrics.counter(OTelMetricsGrpcService.REQUESTS_RECEIVED)).thenReturn(requestsReceivedCounter);
    when(mockPluginMetrics.counter(OTelMetricsGrpcService.REQUEST_TIMEOUTS)).thenReturn(timeoutCounter);
    sut = new OTelMetricsGrpcService(bufferWriteTimeoutInMillis, buffer, mockPluginMetrics);
}
Also used : PluginMetrics(com.amazon.dataprepper.metrics.PluginMetrics) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 50 with PluginSetting

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

the class OTelMetricsSourceTest method start_without_Health_configured_does_not_include_HealthCheck_service.

@Test
void start_without_Health_configured_does_not_include_HealthCheck_service() throws IOException {
    try (MockedStatic<Server> armeriaServerMock = Mockito.mockStatic(Server.class);
        MockedStatic<GrpcService> grpcServerMock = Mockito.mockStatic(GrpcService.class)) {
        armeriaServerMock.when(Server::builder).thenReturn(serverBuilder);
        grpcServerMock.when(GrpcService::builder).thenReturn(grpcServiceBuilder);
        when(grpcServiceBuilder.addService(any(ServerServiceDefinition.class))).thenReturn(grpcServiceBuilder);
        when(grpcServiceBuilder.useClientTimeoutHeader(anyBoolean())).thenReturn(grpcServiceBuilder);
        when(server.stop()).thenReturn(completableFuture);
        final Path certFilePath = Path.of("data/certificate/test_cert.crt");
        final Path keyFilePath = Path.of("data/certificate/test_decrypted_key.key");
        final String certAsString = Files.readString(certFilePath);
        final String keyAsString = Files.readString(keyFilePath);
        when(certificate.getCertificate()).thenReturn(certAsString);
        when(certificate.getPrivateKey()).thenReturn(keyAsString);
        when(certificateProvider.getCertificate()).thenReturn(certificate);
        when(certificateProviderFactory.getCertificateProvider()).thenReturn(certificateProvider);
        final Map<String, Object> settingsMap = new HashMap<>();
        settingsMap.put(SSL, true);
        settingsMap.put("useAcmCertForSSL", true);
        settingsMap.put("awsRegion", "us-east-1");
        settingsMap.put("acmCertificateArn", "arn:aws:acm:us-east-1:account:certificate/1234-567-856456");
        settingsMap.put("sslKeyCertChainFile", "data/certificate/test_cert.crt");
        settingsMap.put("sslKeyFile", "data/certificate/test_decrypted_key.key");
        settingsMap.put("health_check_service", "false");
        testPluginSetting = new PluginSetting(null, settingsMap);
        testPluginSetting.setPipelineName("pipeline");
        oTelMetricsSourceConfig = OBJECT_MAPPER.convertValue(testPluginSetting.getSettings(), OTelMetricsSourceConfig.class);
        final OTelMetricsSource source = new OTelMetricsSource(oTelMetricsSourceConfig, pluginMetrics, pluginFactory, certificateProviderFactory);
        source.start(buffer);
        source.stop();
    }
    verify(grpcServiceBuilder, times(1)).useClientTimeoutHeader(false);
    verify(grpcServiceBuilder, times(1)).useBlockingTaskExecutor(true);
    verify(grpcServiceBuilder, never()).addService(isA(HealthGrpcService.class));
}
Also used : Path(java.nio.file.Path) Server(com.linecorp.armeria.server.Server) HashMap(java.util.HashMap) AsciiString(io.netty.util.AsciiString) HealthGrpcService(com.amazon.dataprepper.plugins.health.HealthGrpcService) GrpcService(com.linecorp.armeria.server.grpc.GrpcService) HealthGrpcService(com.amazon.dataprepper.plugins.health.HealthGrpcService) ServerServiceDefinition(io.grpc.ServerServiceDefinition) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.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