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));
}
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);
}
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);
}
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);
}
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));
}
Aggregations