Skip to content

Commit

Permalink
Added integration test for Elasticsearch HTTP wait strategy with self…
Browse files Browse the repository at this point in the history
…-signed certs

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed May 16, 2022
1 parent 42506d1 commit 9e63b74
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.junit.After;
import org.junit.Test;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.RemoteDockerImage;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
Expand Down Expand Up @@ -282,6 +284,27 @@ public void testElasticsearch8SecureByDefaultCustomCaCertFails() throws Exceptio
}
}

@Test
public void testElasticsearch8SecureByDefaultHttpWaitStrategy() throws Exception {
final HttpWaitStrategy httpsWaitStrategy = Wait.forHttps("/")
.forPort(9200)
.forStatusCode(200)
.withBasicCredentials(ELASTICSEARCH_USERNAME, ELASTICSEARCH_PASSWORD)
// trusting self-signed certificate
.allowInsecure();

try (ElasticsearchContainer container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:8.1.2")
.waitingFor(httpsWaitStrategy)) {

// Start the container. This step might take some time...
container.start();

Response response = getClusterHealth(container);
assertThat(response.getStatusLine().getStatusCode(), is(200));
assertThat(EntityUtils.toString(response.getEntity()), containsString("cluster_name"));
}
}

@Test
public void testElasticsearch8SecureByDefaultFailsSilentlyOnLatestImages() throws Exception {
// this test exists for custom images by users that use the `latest` tag
Expand Down

0 comments on commit 9e63b74

Please sign in to comment.