use of org.testcontainers.elasticsearch.ElasticsearchContainer in project beam by apache.
the class ElasticsearchIOTestUtils method createTestContainer.
static ElasticsearchContainer createTestContainer(String imageTag) {
ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag(imageTag)).withEnv("xpack.security.enabled", "false");
container.withStartupTimeout(Duration.ofMinutes(3));
return container;
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException.
@Test
public void given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(() -> client("elastic", "WrongPassword", containerIp, port)).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).retries(0).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ElasticsearchStatusException.class).hasStackTraceContaining("unable to authenticate user [elastic]");
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.
the class ElasticClientsTest method given_clientAsString_whenReadFromElasticSource_thenFinishSuccessfully.
@Test
public void given_clientAsString_whenReadFromElasticSource_thenFinishSuccessfully() {
ElasticsearchContainer container = ElasticSupport.elastic.get();
String httpHostAddress = container.getHttpHostAddress();
indexDocument("my-index", ImmutableMap.of("name", "Frantisek"));
Pipeline p = Pipeline.create();
p.readFrom(ElasticSources.elastic(() -> ElasticClients.client(httpHostAddress), SearchHit::getSourceAsString)).writeTo(Sinks.list(results));
submitJob(p);
assertThat(results).hasSize(1);
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.
the class ElasticSupport method secureElasticClientSupplier.
public static SupplierEx<RestClientBuilder> secureElasticClientSupplier() {
ElasticsearchContainer container = elastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
return () -> client("elastic", "SuperSecret", containerIp, port);
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.
the class AuthElasticSourcesTest method given_clientWithoutAuthentication_whenReadFromElasticSource_then_failWithAuthenticationException.
@Test
public void given_clientWithoutAuthentication_whenReadFromElasticSource_then_failWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Pipeline p = Pipeline.create();
p.readFrom(elasticSource(() -> client(containerIp, port))).writeTo(Sinks.list(results));
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ResponseException.class).hasStackTraceContaining("missing authentication credentials");
}
Aggregations