Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,22 @@ jobs:
READ_ONLY_REMOTE_GRADLE_CACHE: true
run: |
set -o pipefail
TASKS=$(./gradlew --no-daemon --parallel -q testMatrix | jq 'del(.[] | select(. == ":testcontainers:check" or startswith(":docs:")))' --compact-output)
# Keep Elasticsearch checks and its two slow test classes in separate matrix jobs.
TASKS=$(./gradlew --no-daemon --parallel -q testMatrix | jq '
del(.[] | select(. == ":testcontainers:check" or startswith(":docs:")))
| map(
if . == ":testcontainers-elasticsearch:check" then
[
":testcontainers-elasticsearch:check -x :testcontainers-elasticsearch:test",
":testcontainers-elasticsearch:test --tests org.testcontainers.elasticsearch.ElasticsearchContainerTest",
":testcontainers-elasticsearch:test --tests org.testcontainers.elasticsearch.KibanaContainerTest"
]
else
[.]
end
)
| flatten
' --compact-output)
echo $TASKS
echo "matrix={\"gradle_args\":$TASKS}" >> $GITHUB_OUTPUT
check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void stopRestClient() throws IOException {
// Latest (default coverage)

@Test
void latestStartsWithTlsAndPassword() throws IOException {
void latestStartsWithTlsAndPassword() throws Exception {
// httpClientLatest {
// Create the elasticsearch container.
try (ElasticsearchContainer container = new ElasticsearchContainer(ELASTICSEARCH_IMAGE_LATEST)) {
Expand Down Expand Up @@ -134,7 +134,14 @@ void latestStartsWithTlsAndPassword() throws IOException {
Response response = client.performRequest(new Request("GET", "/_cluster/health"));
// }}
assertThat(response.getStatusLine().getStatusCode()).as("cluster health is available").isEqualTo(200);
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name");
String clusterHealth = EntityUtils.toString(response.getEntity());
assertThat(clusterHealth).contains("cluster_name");
assertThat(clusterHealth)
.as("Cluster health status should be at least yellow after container start")
.satisfiesAnyOf(
body -> assertThat(body).contains("\"status\":\"yellow\""),
body -> assertThat(body).contains("\"status\":\"green\"")
);
assertThat(container.getHttpScheme()).as("HTTP API uses HTTPS by default").isEqualTo("https");

response = client.performRequest(new Request("GET", "/"));
Expand All @@ -149,6 +156,9 @@ void latestStartsWithTlsAndPassword() throws IOException {
.as("Elastic licensed features are available")
.contains("monitoring");

// Default is 2g, see https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
assertElasticsearchContainerHasHeapSize(container, 2_147_483_648L);

assertThat(catchThrowable(() -> getAnonymousClient(container).performRequest(new Request("GET", "/"))))
.as("anonymous requests are rejected")
.isInstanceOf(ResponseException.class);
Expand Down Expand Up @@ -232,23 +242,6 @@ void latestHonorsCustomHttpsWaitStrategy() throws Exception {
}
}

@Test
void clusterHealthIsAtLeastYellowAfterStart() throws IOException {
try (ElasticsearchContainer container = new ElasticsearchContainer(ELASTICSEARCH_IMAGE_LATEST)) {
container.start();

Response response = getClient(container).performRequest(new Request("GET", "/_cluster/health"));
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
String body = EntityUtils.toString(response.getEntity());
assertThat(body)
.as("Cluster health status should be at least yellow after container start")
.satisfiesAnyOf(
b -> assertThat(b).contains("\"status\":\"yellow\""),
b -> assertThat(b).contains("\"status\":\"green\"")
);
}
}

@Test
void latestWorksWithDockerHubImage() throws Exception {
try (
Expand All @@ -262,17 +255,6 @@ void latestWorksWithDockerHubImage() throws Exception {
}
}

@Test
void latestDefaultHeapIsTwoGb() throws Exception {
// Default is 2g, see https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
long defaultHeapSize = 2_147_483_648L;

try (ElasticsearchContainer container = new ElasticsearchContainer(ELASTICSEARCH_IMAGE_LATEST)) {
container.start();
assertElasticsearchContainerHasHeapSize(container, defaultHeapSize);
}
}

@Test
void latestHeapCanBeSetViaEnv() throws Exception {
String customHeapSize = "1500m";
Expand Down
Loading