Skip to content

Commit 701654e

Browse files
Cleanup integration test setup (#3835)
Use env vars in docker compose as the only source for passing config to elasticsearch containers Use docker compose healthchecks with the --wait option to start elasticsearch containers
1 parent fd3d75f commit 701654e

File tree

5 files changed

+40
-88
lines changed

5 files changed

+40
-88
lines changed

Makefile

+1-13
Original file line numberDiff line numberDiff line change
@@ -296,22 +296,10 @@ get-version:
296296
include ./dev-tools/integration/.env
297297
export $(shell sed 's/=.*//' ./dev-tools/integration/.env)
298298

299-
# Start ES with docker without waiting
300-
.PHONY: int-docker-start-async
301-
int-docker-start-async:
302-
@docker compose -f ./dev-tools/integration/docker-compose.yml --env-file ./dev-tools/integration/.env up -d --remove-orphans elasticsearch elasticsearch-remote
303-
304-
# Wait for ES to be ready
305-
.PHONY: int-docker-wait
306-
int-docker-wait:
307-
@./dev-tools/integration/wait-for-elasticsearch.sh ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@${TEST_ELASTICSEARCH_HOSTS}
308-
@./dev-tools/integration/wait-for-elasticsearch.sh https://${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@${TEST_REMOTE_ELASTICSEARCH_HOST}
309-
310299
# Start integration docker setup with wait for when the ES is ready
311300
.PHONY: int-docker-start
312301
int-docker-start: ## - Start docker envronment for integration tests and wait until it's ready
313-
@$(MAKE) int-docker-start-async
314-
@$(MAKE) int-docker-wait
302+
docker compose -f ./dev-tools/integration/docker-compose.yml --env-file ./dev-tools/integration/.env up -d --wait --remove-orphans elasticsearch elasticsearch-remote
315303

316304
# Stop integration docker setup
317305
.PHONY: int-docker-stop

dev-tools/e2e/docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '2.3'
21
services:
32
kibana:
43
image: "docker.elastic.co/kibana/kibana:${ELASTICSEARCH_VERSION}-amd64"

dev-tools/integration/docker-compose.yml

+39-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
2-
version: '2.3'
31
volumes:
42
certs:
53
driver: local
6-
74
services:
85
setup:
96
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}-amd64
@@ -38,12 +35,6 @@ services:
3835
" - localhost\n"\
3936
" ip:\n"\
4037
" - 127.0.0.1\n"\
41-
" - name: es03\n"\
42-
" dns:\n"\
43-
" - es03\n"\
44-
" - localhost\n"\
45-
" ip:\n"\
46-
" - 127.0.0.1\n"\
4738
> config/certs/instances.yml;
4839
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
4940
unzip config/certs/certs.zip -d config/certs;
@@ -59,23 +50,41 @@ services:
5950
environment:
6051
- node.name=es01
6152
- cluster.name=es-docker-cluster
62-
- discovery.seed_hosts=elasticsearch
53+
- network.host="0.0.0.0"
54+
- discovery.type=single-node
55+
- xpack.license.self_generated.type=trial
56+
- xpack.security.enabled=true
57+
- xpack.security.authc.api_key.enabled=true
58+
- xpack.security.authc.token.enabled=true
59+
- xpack.security.http.ssl.enabled=false
60+
#- xpack.security.http.ssl.enabled=true
61+
#- xpack.security.http.ssl.key=certs/es01/es01.key
62+
#- xpack.security.http.ssl.certificate=certs/es01/es01.crt
63+
#- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
64+
#- xpack.security.transport.ssl.enabled=true
65+
#- xpack.security.transport.ssl.key=certs/es01/es01.key
66+
#- xpack.security.transport.ssl.certificate=certs/es01/es01.crt
67+
#- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
68+
#- xpack.security.transport.ssl.verification_mode=certificate
6369
- bootstrap.memory_lock=true
64-
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
6570
- "ELASTIC_USERNAME=${ELASTICSEARCH_USERNAME}"
6671
- "ELASTIC_PASSWORD=${ELASTICSEARCH_PASSWORD}"
72+
mem_limit: 4294967296 # 4g
73+
healthcheck:
74+
test: ["CMD-SHELL", "curl -s ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"]
75+
start_period: 10s
76+
interval: 10s
77+
timeout: 10s
78+
retries: 120
6779
ulimits:
6880
memlock:
6981
soft: -1
7082
hard: -1
71-
nofile:
72-
soft: 65536
73-
hard: 65536
7483
volumes:
75-
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
84+
- certs:/usr/share/elasticsearch/config/certs
7685
ports:
7786
- 127.0.0.1:9200:9200
78-
87+
7988
elasticsearch-remote:
8089
depends_on:
8190
setup:
@@ -85,9 +94,12 @@ services:
8594
environment:
8695
- node.name=es02
8796
- cluster.name=es-docker-cluster2
88-
- discovery.seed_hosts=elasticsearch
89-
- bootstrap.memory_lock=true
97+
- network.host="0.0.0.0"
98+
- discovery.type=single-node
99+
- xpack.license.self_generated.type=trial
90100
- xpack.security.enabled=true
101+
- xpack.security.authc.api_key.enabled=true
102+
- xpack.security.authc.token.enabled=true
91103
- xpack.security.http.ssl.enabled=true
92104
- xpack.security.http.ssl.key=certs/es02/es02.key
93105
- xpack.security.http.ssl.certificate=certs/es02/es02.crt
@@ -97,23 +109,22 @@ services:
97109
- xpack.security.transport.ssl.certificate=certs/es02/es02.crt
98110
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
99111
- xpack.security.transport.ssl.verification_mode=certificate
100-
- cluster.name="docker-cluster"
101-
- network.host="0.0.0.0"
102-
- xpack.security.authc.api_key.enabled="true"
103-
- xpack.license.self_generated.type="trial"
104-
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
112+
- bootstrap.memory_lock=true
105113
- "ELASTIC_USERNAME=${ELASTICSEARCH_USERNAME}"
106114
- "ELASTIC_PASSWORD=${ELASTICSEARCH_PASSWORD}"
115+
mem_limit: 4294967296 # 4g
116+
healthcheck:
117+
test: ["CMD-SHELL", "curl -s --cacert config/certs/ca/ca.crt https://${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}@localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"]
118+
start_period: 10s
119+
interval: 10s
120+
timeout: 10s
121+
retries: 120
107122
ulimits:
108123
memlock:
109124
soft: -1
110125
hard: -1
111-
nofile:
112-
soft: 65536
113-
hard: 65536
114126
volumes:
115127
- certs:/usr/share/elasticsearch/config/certs
116-
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
117128
ports:
118129
- 127.0.0.1:9201:9200
119-
130+

dev-tools/integration/elasticsearch.yml

-8
This file was deleted.

dev-tools/integration/wait-for-elasticsearch.sh

-38
This file was deleted.

0 commit comments

Comments
 (0)