From b7975e79d8c75899961e5946d8ad0356065f20c5 Mon Sep 17 00:00:00 2001 From: "chen, suyue" Date: Tue, 23 Jul 2024 10:17:24 +0800 Subject: [PATCH] refactor translation ci test (#438) Signed-off-by: chensuyue --- Translation/docker/gaudi/README.md | 4 +- .../{docker_compose.yaml => compose.yaml} | 0 Translation/docker/xeon/README.md | 4 +- .../{docker_compose.yaml => compose.yaml} | 0 .../tests/test_translation_on_gaudi.sh | 21 ++++++---- Translation/tests/test_translation_on_xeon.sh | 38 +++++++++++++------ 6 files changed, 43 insertions(+), 24 deletions(-) rename Translation/docker/gaudi/{docker_compose.yaml => compose.yaml} (100%) rename Translation/docker/xeon/{docker_compose.yaml => compose.yaml} (100%) diff --git a/Translation/docker/gaudi/README.md b/Translation/docker/gaudi/README.md index 001fcdc50..e1546fa3f 100644 --- a/Translation/docker/gaudi/README.md +++ b/Translation/docker/gaudi/README.md @@ -47,7 +47,7 @@ Then run the command `docker images`, you will have the following four Docker Im ### Setup Environment Variables -Since the `docker_compose.yaml` will consume some environment variables, you need to setup them in advance as below. +Since the `compose.yaml` will consume some environment variables, you need to setup them in advance as below. ```bash export http_proxy=${your_http_proxy} @@ -65,7 +65,7 @@ Note: Please replace with `host_ip` with you external IP address, do not use loc ### Start Microservice Docker Containers ```bash -docker compose -f docker_compose.yaml up -d +docker compose up -d ``` ### Validate Microservices diff --git a/Translation/docker/gaudi/docker_compose.yaml b/Translation/docker/gaudi/compose.yaml similarity index 100% rename from Translation/docker/gaudi/docker_compose.yaml rename to Translation/docker/gaudi/compose.yaml diff --git a/Translation/docker/xeon/README.md b/Translation/docker/xeon/README.md index ee01e9079..f6b065630 100644 --- a/Translation/docker/xeon/README.md +++ b/Translation/docker/xeon/README.md @@ -54,7 +54,7 @@ Then run the command `docker images`, you will have the following Docker Images: ### Setup Environment Variables -Since the `docker_compose.yaml` will consume some environment variables, you need to setup them in advance as below. +Since the `compose.yaml` will consume some environment variables, you need to set up them in advance as below. ```bash export http_proxy=${your_http_proxy} @@ -72,7 +72,7 @@ Note: Please replace with `host_ip` with you external IP address, do not use loc ### Start Microservice Docker Containers ```bash -docker compose -f docker_compose.yaml up -d +docker compose up -d ``` ### Validate Microservices diff --git a/Translation/docker/xeon/docker_compose.yaml b/Translation/docker/xeon/compose.yaml similarity index 100% rename from Translation/docker/xeon/docker_compose.yaml rename to Translation/docker/xeon/compose.yaml diff --git a/Translation/tests/test_translation_on_gaudi.sh b/Translation/tests/test_translation_on_gaudi.sh index b76bf7ba4..672c75067 100644 --- a/Translation/tests/test_translation_on_gaudi.sh +++ b/Translation/tests/test_translation_on_gaudi.sh @@ -35,9 +35,18 @@ function start_services() { export LLM_SERVICE_HOST_IP=${ip_address} export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/translation" + if [[ "$IMAGE_REPO" != "" ]]; then + # Replace the container name with a test-specific name + echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" + sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" compose.yaml + sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" compose.yaml + sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml + echo "cat compose.yaml" + cat compose.yaml + fi + # Start Docker Containers - # TODO: Replace the container name with a test-specific name - docker compose -f docker_compose.yaml up -d + docker compose up -d sleep 2m # Waits 2 minutes } @@ -130,18 +139,14 @@ function validate_frontend() { function stop_docker() { cd $WORKPATH/docker/gaudi - container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2) - for container_name in $container_list; do - cid=$(docker ps -aq --filter "name=$container_name") - if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi - done + docker compose down } function main() { stop_docker - build_docker_images + if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi start_services validate_microservices diff --git a/Translation/tests/test_translation_on_xeon.sh b/Translation/tests/test_translation_on_xeon.sh index a8cfeef69..0173ded8a 100644 --- a/Translation/tests/test_translation_on_xeon.sh +++ b/Translation/tests/test_translation_on_xeon.sh @@ -8,6 +8,20 @@ WORKPATH=$(dirname "$PWD") LOG_PATH="$WORKPATH/tests" ip_address=$(hostname -I | awk '{print $1}') +function build_docker_images() { + cd $WORKPATH + git clone https://github.com/opea-project/GenAIComps.git + cd GenAIComps + docker build --no-cache -t opea/llm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/tgi/Dockerfile . + + cd $WORKPATH/docker + docker build --no-cache -t opea/translation:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . + + cd $WORKPATH/docker/ui + docker build --no-cache -t opea/translation-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f docker/Dockerfile . + docker images +} + function start_services() { cd $WORKPATH/docker/xeon @@ -18,15 +32,18 @@ function start_services() { export LLM_SERVICE_HOST_IP=${ip_address} export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/translation" - # Replace the container name with a test-specific name - echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" - sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml + if [[ "$IMAGE_REPO" != "" ]]; then + # Replace the container name with a test-specific name + echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" + sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" compose.yaml + sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" compose.yaml + sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml + echo "cat compose.yaml" + cat compose.yaml + fi # Start Docker Containers - # TODO: Replace the container name with a test-specific name - docker compose -f docker_compose.yaml up -d + docker compose up -d sleep 2m # Waits 2 minutes } @@ -117,17 +134,14 @@ function validate_frontend() { function stop_docker() { cd $WORKPATH/docker/xeon - container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2) - for container_name in $container_list; do - cid=$(docker ps -aq --filter "name=$container_name") - if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi - done + docker compose down } function main() { stop_docker + if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi start_services validate_microservices