Skip to content

Commit 6acacc8

Browse files
Support health check in dataprep component (#1546)
* Support health check in dataprep component. Modify all related test scripts. Issue: opea-project/GenAIExamples#1699 Signed-off-by: letonghan <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: letonghan <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 62aa2cd commit 6acacc8

16 files changed

+140
-14
lines changed

comps/dataprep/deployment/docker_compose/compose.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ services:
3131
INDEX_NAME: ${INDEX_NAME}
3232
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
3333
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
34+
healthcheck:
35+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
36+
interval: 10s
37+
timeout: 5s
38+
retries: 10
3439
restart: unless-stopped
3540
depends_on:
3641
elasticsearch-vector-db:
@@ -51,6 +56,11 @@ services:
5156
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
5257
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
5358
LOGFLAG: ${LOGFLAG}
59+
healthcheck:
60+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
61+
interval: 10s
62+
timeout: 5s
63+
retries: 10
5464
restart: unless-stopped
5565
depends_on:
5666
tei-embedding-serving:
@@ -84,6 +94,11 @@ services:
8494
MILVUS_HOST: ${MILVUS_HOST}
8595
LVM_ENDPOINT: ${LVM_ENDPOINT}
8696
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
97+
healthcheck:
98+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
99+
interval: 10s
100+
timeout: 5s
101+
retries: 10
87102
restart: unless-stopped
88103

89104
dataprep-neo4j-llamaindex:
@@ -119,6 +134,11 @@ services:
119134
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
120135
HF_TOKEN: ${HF_TOKEN}
121136
MAX_INPUT_TOKENS: ${MAX_INPUT_TOKENS:-4096}
137+
healthcheck:
138+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
139+
interval: 10s
140+
timeout: 5s
141+
retries: 10
122142
restart: unless-stopped
123143

124144
dataprep-opensearch:
@@ -139,6 +159,11 @@ services:
139159
OPENSEARCH_URL: ${OPENSEARCH_URL}
140160
INDEX_NAME: ${INDEX_NAME}
141161
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
162+
healthcheck:
163+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
164+
interval: 10s
165+
timeout: 5s
166+
retries: 10
142167
restart: unless-stopped
143168
security_opt:
144169
- no-new-privileges:true
@@ -158,6 +183,11 @@ services:
158183
https_proxy: ${https_proxy}
159184
DATAPREP_COMPONENT_NAME: "OPEA_DATAPREP_PGVECTOR"
160185
PG_CONNECTION_STRING: ${PG_CONNECTION_STRING}
186+
healthcheck:
187+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
188+
interval: 10s
189+
timeout: 5s
190+
retries: 10
161191
restart: unless-stopped
162192

163193
dataprep-pinecone:
@@ -174,6 +204,11 @@ services:
174204
PINECONE_API_KEY: ${PINECONE_API_KEY}
175205
PINECONE_INDEX_NAME: ${PINECONE_INDEX_NAME}
176206
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
207+
healthcheck:
208+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
209+
interval: 10s
210+
timeout: 5s
211+
retries: 10
177212
restart: unless-stopped
178213

179214
dataprep-qdrant:
@@ -197,6 +232,11 @@ services:
197232
COLLECTION_NAME: ${COLLECTION_NAME}
198233
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
199234
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
235+
healthcheck:
236+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
237+
interval: 10s
238+
timeout: 5s
239+
retries: 10
200240
restart: unless-stopped
201241

202242
dataprep-redis:
@@ -221,6 +261,11 @@ services:
221261
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
222262
INDEX_NAME: ${INDEX_NAME}
223263
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
264+
healthcheck:
265+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
266+
interval: 10s
267+
timeout: 5s
268+
retries: 10
224269
restart: unless-stopped
225270

226271
dataprep-multimodal-redis:
@@ -244,6 +289,11 @@ services:
244289
INDEX_NAME: ${INDEX_NAME}
245290
LVM_ENDPOINT: ${LVM_ENDPOINT}
246291
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
292+
healthcheck:
293+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
294+
interval: 10s
295+
timeout: 5s
296+
retries: 10
247297
restart: unless-stopped
248298

249299
dataprep-vdms:
@@ -264,6 +314,11 @@ services:
264314
VDMS_PORT: ${VDMS_PORT}
265315
COLLECTION_NAME: ${COLLECTION_NAME}
266316
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
317+
healthcheck:
318+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
319+
interval: 10s
320+
timeout: 5s
321+
retries: 10
267322
restart: unless-stopped
268323

269324
dataprep-vdms-multimodal:
@@ -284,6 +339,11 @@ services:
284339
VDMS_HOST: ${VDMS_HOST}
285340
VDMS_PORT: ${VDMS_PORT}
286341
COLLECTION_NAME: ${INDEX_NAME}
342+
healthcheck:
343+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
344+
interval: 10s
345+
timeout: 5s
346+
retries: 10
287347
restart: unless-stopped
288348

289349
dataprep-redis-finance:
@@ -311,6 +371,12 @@ services:
311371
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
312372
HF_TOKEN: ${HF_TOKEN}
313373
LOGFLAG: true
374+
healthcheck:
375+
test: ["CMD-SHELL", "curl -f http://localhost:5000/v1/health_check || exit 1"]
376+
interval: 10s
377+
timeout: 5s
378+
retries: 10
379+
restart: unless-stopped
314380

315381
networks:
316382
default:

comps/dataprep/src/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missin
1717
libreoffice \
1818
poppler-utils \
1919
tesseract-ocr \
20-
wget
20+
wget curl
2121

2222
# Install ffmpeg static build
2323
RUN cd /root && wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz && \

tests/dataprep/dataprep_utils.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,25 @@ function check_result() {
156156
echo "[ $service_name ] Content is as expected."
157157
fi
158158
}
159+
160+
function check_healthy() {
161+
local container_name=$1
162+
local retries=30
163+
local count=0
164+
165+
echo "Waiting for $container_name to become healthy..."
166+
167+
while [ $count -lt $retries ]; do
168+
status=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null)
169+
if [ "$status" == "healthy" ]; then
170+
echo "$container_name is healthy!"
171+
return 0
172+
fi
173+
echo "$container_name status: $status ($count/$retries)"
174+
sleep 5
175+
((count++))
176+
done
177+
178+
echo "$container_name did not become healthy in time."
179+
return 1
180+
}

tests/dataprep/test_dataprep_elasticsearch.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ ip_address=$(hostname -I | awk '{print $1}')
1010
export DATAPREP_PORT=11100
1111
export TAG="comps"
1212

13+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
14+
source ${SCRIPT_DIR}/dataprep_utils.sh
15+
1316
function build_docker_images() {
1417
cd $WORKPATH
1518
echo $WORKPATH
@@ -35,7 +38,8 @@ function start_service() {
3538
cd $WORKPATH
3639
cd comps/dataprep/deployment/docker_compose/
3740
docker compose up ${service_name} -d
38-
sleep 1m
41+
42+
check_healthy "dataprep-elasticsearch" || exit 1
3943
echo "Microservice started"
4044
}
4145

tests/dataprep/test_dataprep_milvus.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function start_service() {
3838
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
3939
docker compose up ${service_name} -d > ${LOG_PATH}/start_services_with_compose.log
4040

41-
sleep 1m
41+
check_healthy "dataprep-milvus-server" || exit 1
4242
}
4343

4444
function validate_microservice() {

tests/dataprep/test_dataprep_milvus_multimodal.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pdf_name="nke-10k-2023"
2424
pdf_fn="${tmp_dir}/${pdf_name}.pdf"
2525
export DATAPREP_PORT="11102"
2626

27+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
28+
source ${SCRIPT_DIR}/dataprep_utils.sh
29+
2730
function build_docker_images() {
2831
cd $WORKPATH
2932
echo $(pwd)
@@ -84,7 +87,8 @@ function start_service() {
8487
service_name="etcd minio standalone dataprep-multimodal-milvus"
8588
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
8689
docker compose up ${service_name} -d
87-
sleep 1m
90+
91+
check_healthy "dataprep-multimodal-milvus-server" || exit 1
8892
}
8993

9094
function prepare_data() {

tests/dataprep/test_dataprep_neo4j_on_intel_hpu.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ LLM_ENDPOINT_PORT=10510
1212
export TAG="comps"
1313
export DATA_PATH=${model_cache}
1414

15+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
16+
source ${SCRIPT_DIR}/dataprep_utils.sh
17+
1518
function build_docker_images() {
1619
cd $WORKPATH
1720
echo $(pwd)
@@ -50,7 +53,8 @@ function start_service() {
5053

5154
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
5255
docker compose up ${service_name} -d
53-
sleep 1m
56+
57+
check_healthy "dataprep-neo4j-llamaindex" || exit 1
5458
}
5559

5660
function validate_service() {

tests/dataprep/test_dataprep_opensearch.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export DATAPREP_PORT="11104"
1111
OPENSEARCH_INITIAL_ADMIN_PASSWORD="StRoNgOpEa0)"
1212
export TAG="comps"
1313

14+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
15+
source ${SCRIPT_DIR}/dataprep_utils.sh
16+
1417
function build_docker_images() {
1518
cd $WORKPATH
1619
echo $(pwd)
@@ -32,9 +35,11 @@ function start_service() {
3235
export INDEX_NAME="file-index"
3336
service_name="opensearch-vector-db dataprep-opensearch"
3437
export host_ip=${ip_address}
38+
3539
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
3640
docker compose up ${service_name} -d
37-
sleep 1m
41+
42+
check_healthy "dataprep-opensearch-server" || exit 1
3843
}
3944

4045
function validate_microservice() {

tests/dataprep/test_dataprep_pgvector.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ function start_service() {
3838

3939
service_name="pgvector-db dataprep-pgvector"
4040
export host_ip=${ip_address}
41+
4142
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
4243
docker compose up ${service_name} -d
43-
sleep 1m
44+
45+
check_healthy "dataprep-pgvector-server" || exit 1
4446
}
4547

4648
function validate_microservice() {

tests/dataprep/test_dataprep_pinecone.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ ip_address=$(hostname -I | awk '{print $1}')
99
export DATAPREP_PORT="11106"
1010
export TAG="comps"
1111

12+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
source ${SCRIPT_DIR}/dataprep_utils.sh
14+
1215
function build_docker_images() {
1316
cd $WORKPATH
1417

@@ -30,7 +33,8 @@ function start_service() {
3033
service_name="dataprep-pinecone"
3134
cd $WORKPATH/comps/dataprep/deployment/docker_compose/
3235
docker compose up ${service_name} -d
33-
sleep 1m
36+
37+
check_healthy "dataprep-pinecone-server" || exit 1
3438
}
3539

3640
function validate_microservice() {

0 commit comments

Comments
 (0)