Search in sources :

Example 56 with PluginSetting

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

the class ConnectionConfigurationTests method testCreateClient_WithValidHttpProxy_HostName.

@Test
public void testCreateClient_WithValidHttpProxy_HostName() throws IOException {
    final Map<String, Object> metadata = generateConfigurationMetadata(TEST_HOSTS, TEST_USERNAME, TEST_PASSWORD, TEST_CONNECT_TIMEOUT, TEST_SOCKET_TIMEOUT, false, null, null, TEST_CERT_PATH, false);
    final String testHttpProxy = "example.com:80";
    metadata.put(PROXY_PARAMETER, testHttpProxy);
    final PluginSetting pluginSetting = getPluginSettingByConfigurationMetadata(metadata);
    final ConnectionConfiguration connectionConfiguration = ConnectionConfiguration.readConnectionConfiguration(pluginSetting);
    assertEquals(connectionConfiguration.getProxy().get(), testHttpProxy);
    final RestHighLevelClient client = connectionConfiguration.createClient();
    assertNotNull(client);
    client.close();
}
Also used : RestHighLevelClient(org.opensearch.client.RestHighLevelClient) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 57 with PluginSetting

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

the class ConnectionConfigurationTests method testCreateClient_WithValidHttpProxy_SchemeProvided.

@Test
public void testCreateClient_WithValidHttpProxy_SchemeProvided() throws IOException {
    final Map<String, Object> metadata = generateConfigurationMetadata(TEST_HOSTS, TEST_USERNAME, TEST_PASSWORD, TEST_CONNECT_TIMEOUT, TEST_SOCKET_TIMEOUT, false, null, null, TEST_CERT_PATH, false);
    final String testHttpProxy = "http://example.com:4350";
    metadata.put(PROXY_PARAMETER, testHttpProxy);
    final PluginSetting pluginSetting = getPluginSettingByConfigurationMetadata(metadata);
    final ConnectionConfiguration connectionConfiguration = ConnectionConfiguration.readConnectionConfiguration(pluginSetting);
    assertEquals(connectionConfiguration.getProxy().get(), testHttpProxy);
    final RestHighLevelClient client = connectionConfiguration.createClient();
    assertNotNull(client);
    client.close();
}
Also used : RestHighLevelClient(org.opensearch.client.RestHighLevelClient) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 58 with PluginSetting

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

the class ConnectionConfigurationTests method testCreateClientWithAWSSigV4AndCertPath.

@Test
public void testCreateClientWithAWSSigV4AndCertPath() throws IOException {
    final PluginSetting pluginSetting = generatePluginSetting(TEST_HOSTS, null, null, null, null, true, null, null, TEST_CERT_PATH, false);
    final ConnectionConfiguration connectionConfiguration = ConnectionConfiguration.readConnectionConfiguration(pluginSetting);
    assertEquals("us-east-1", connectionConfiguration.getAwsRegion());
    assertTrue(connectionConfiguration.isAwsSigv4());
    assertEquals(TEST_PIPELINE_NAME, connectionConfiguration.getPipelineName());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 59 with PluginSetting

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

the class ConnectionConfigurationTests method testCreateClientWithAWSSigV4AndSTSRole.

@Test
public void testCreateClientWithAWSSigV4AndSTSRole() throws IOException {
    final PluginSetting pluginSetting = generatePluginSetting(TEST_HOSTS, null, null, null, null, true, null, "arn:aws:iam::123456789012:iam-role", TEST_CERT_PATH, false);
    final ConnectionConfiguration connectionConfiguration = ConnectionConfiguration.readConnectionConfiguration(pluginSetting);
    assertEquals("us-east-1", connectionConfiguration.getAwsRegion());
    assertTrue(connectionConfiguration.isAwsSigv4());
    assertEquals("arn:aws:iam::123456789012:iam-role", connectionConfiguration.getAwsStsRoleArn());
    assertEquals(TEST_PIPELINE_NAME, connectionConfiguration.getPipelineName());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 60 with PluginSetting

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

the class ConnectionConfigurationTests method testCreateClientWithCertPath.

@Test
public void testCreateClientWithCertPath() throws IOException {
    final PluginSetting pluginSetting = generatePluginSetting(TEST_HOSTS, TEST_USERNAME, TEST_PASSWORD, TEST_CONNECT_TIMEOUT, TEST_SOCKET_TIMEOUT, false, null, null, TEST_CERT_PATH, false);
    final ConnectionConfiguration connectionConfiguration = ConnectionConfiguration.readConnectionConfiguration(pluginSetting);
    final RestHighLevelClient client = connectionConfiguration.createClient();
    assertNotNull(client);
    client.close();
}
Also used : RestHighLevelClient(org.opensearch.client.RestHighLevelClient) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) 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