Search in sources :

Example 6 with ElasticsearchContainer

use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.

the class AuthElasticSourcesTest method given_clientWithWrongPassword_whenReadFromElasticSource_thenFailWithAuthenticationException.

@Test
public void given_clientWithWrongPassword_whenReadFromElasticSource_thenFailWithAuthenticationException() {
    ElasticsearchContainer container = ElasticSupport.secureElastic.get();
    String containerIp = container.getContainerIpAddress();
    Integer port = container.getMappedPort(PORT);
    Pipeline p = Pipeline.create();
    p.readFrom(elasticSource(() -> client("elastic", "WrongPassword", containerIp, port))).writeTo(Sinks.list(results));
    assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ResponseException.class).hasStackTraceContaining("unable to authenticate user [elastic]");
}
Also used : ResponseException(org.elasticsearch.client.ResponseException) ElasticsearchContainer(org.testcontainers.elasticsearch.ElasticsearchContainer) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Test(org.junit.Test)

Example 7 with ElasticsearchContainer

use of org.testcontainers.elasticsearch.ElasticsearchContainer in project beam by apache.

the class HadoopFormatIOElasticIT method setElasticsearchContainer.

private static void setElasticsearchContainer() throws IOException {
    elasticsearch = new ElasticsearchContainer(DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag("7.9.2"));
    elasticsearch.start();
    options.setElasticUserName("");
    options.setElasticPassword("");
    options.setElasticServerIp(elasticsearch.getContainerIpAddress());
    options.setElasticServerPort(elasticsearch.getMappedPort(9200));
    prepareElasticIndex();
}
Also used : ElasticsearchContainer(org.testcontainers.elasticsearch.ElasticsearchContainer)

Example 8 with ElasticsearchContainer

use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.

the class AuthElasticSinksTest method given_clientWithoutAuthentication_whenWriteToElasticSink_thenFailWithAuthenticationException.

@Test
public void given_clientWithoutAuthentication_whenWriteToElasticSink_thenFailWithAuthenticationException() {
    ElasticsearchContainer container = ElasticSupport.secureElastic.get();
    String containerIp = container.getContainerIpAddress();
    Integer port = container.getMappedPort(PORT);
    Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(() -> client(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("missing authentication credentials");
}
Also used : BulkRequest(org.elasticsearch.action.bulk.BulkRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) ElasticsearchStatusException(org.elasticsearch.ElasticsearchStatusException) ElasticsearchContainer(org.testcontainers.elasticsearch.ElasticsearchContainer) TestItem(com.hazelcast.jet.elastic.CommonElasticSinksTest.TestItem) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Test(org.junit.Test)

Aggregations

ElasticsearchContainer (org.testcontainers.elasticsearch.ElasticsearchContainer)8 Pipeline (com.hazelcast.jet.pipeline.Pipeline)5 Test (org.junit.Test)5 TestItem (com.hazelcast.jet.elastic.CommonElasticSinksTest.TestItem)2 ElasticsearchStatusException (org.elasticsearch.ElasticsearchStatusException)2 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)2 IndexRequest (org.elasticsearch.action.index.IndexRequest)2 ResponseException (org.elasticsearch.client.ResponseException)2 SearchHit (org.elasticsearch.search.SearchHit)1