|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2025 Huawei Technologies Co., Ltd. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +set -e |
| 6 | +IMAGE_REPO=${IMAGE_REPO:-"opea"} |
| 7 | +IMAGE_TAG=${IMAGE_TAG:-"latest"} |
| 8 | +echo "REGISTRY=IMAGE_REPO=${IMAGE_REPO}" |
| 9 | +echo "TAG=IMAGE_TAG=${IMAGE_TAG}" |
| 10 | +export REGISTRY=${IMAGE_REPO} |
| 11 | +export TAG=${IMAGE_TAG} |
| 12 | +export MODEL_CACHE=${model_cache:-"./data"} |
| 13 | + |
| 14 | +WORKPATH=$(dirname "$PWD") |
| 15 | +LOG_PATH="$WORKPATH/tests" |
| 16 | +ip_address=$(hostname -I | awk '{print $1}') |
| 17 | + |
| 18 | +function build_docker_images() { |
| 19 | + opea_branch=${opea_branch:-"main"} |
| 20 | + |
| 21 | + cd $WORKPATH/docker_image_build |
| 22 | + git clone --depth 1 --branch ${opea_branch} https://github.com/opea-project/GenAIComps.git |
| 23 | + pushd GenAIComps |
| 24 | + echo "GenAIComps test commit is $(git rev-parse HEAD)" |
| 25 | + docker build --no-cache -t ${REGISTRY}/comps-base:${TAG}-openeuler --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile.openEuler . |
| 26 | + popd && sleep 1s |
| 27 | + |
| 28 | + echo "Build all the images with --no-cache, check docker_image_build.log for details..." |
| 29 | + service_list="audioqna-openeuler audioqna-ui-openeuler whisper-openeuler speecht5-openeuler" |
| 30 | + docker compose -f build.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log |
| 31 | + |
| 32 | + docker images && sleep 1s |
| 33 | +} |
| 34 | + |
| 35 | +function start_services() { |
| 36 | + cd $WORKPATH/docker_compose/intel/cpu/xeon/ |
| 37 | + export host_ip=${ip_address} |
| 38 | + source set_env.sh |
| 39 | + # sed -i "s/backend_address/$ip_address/g" $WORKPATH/ui/svelte/.env |
| 40 | + |
| 41 | + # Start Docker Containers |
| 42 | + docker compose -f compose_openeuler.yaml up -d > ${LOG_PATH}/start_services_with_compose.log |
| 43 | + n=0 |
| 44 | + until [[ "$n" -ge 200 ]]; do |
| 45 | + docker logs vllm-service > $LOG_PATH/vllm_service_start.log 2>&1 |
| 46 | + if grep -q complete $LOG_PATH/vllm_service_start.log; then |
| 47 | + break |
| 48 | + fi |
| 49 | + sleep 5s |
| 50 | + n=$((n+1)) |
| 51 | + done |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +function validate_megaservice() { |
| 56 | + response=$(http_proxy="" curl http://${ip_address}:3008/v1/audioqna -XPOST -d '{"audio": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", "max_tokens":64}' -H 'Content-Type: application/json') |
| 57 | + # always print the log |
| 58 | + docker logs whisper-service > $LOG_PATH/whisper-service.log |
| 59 | + docker logs speecht5-service > $LOG_PATH/tts-service.log |
| 60 | + docker logs vllm-service > $LOG_PATH/vllm-service.log |
| 61 | + docker logs audioqna-xeon-backend-server > $LOG_PATH/audioqna-xeon-backend-server.log |
| 62 | + echo "$response" | sed 's/^"//;s/"$//' | base64 -d > speech.mp3 |
| 63 | + |
| 64 | + if [[ $(file speech.mp3) == *"RIFF"* ]]; then |
| 65 | + echo "Result correct." |
| 66 | + else |
| 67 | + echo "Result wrong." |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + |
| 71 | +} |
| 72 | + |
| 73 | +function stop_docker() { |
| 74 | + cd $WORKPATH/docker_compose/intel/cpu/xeon/ |
| 75 | + docker compose -f compose_openeuler.yaml stop && docker compose rm -f |
| 76 | +} |
| 77 | + |
| 78 | +function main() { |
| 79 | + |
| 80 | + echo "::group::stop_docker" |
| 81 | + stop_docker |
| 82 | + echo "::endgroup::" |
| 83 | + |
| 84 | + echo "::group::build_docker_images" |
| 85 | + if [[ "$IMAGE_REPO" == "opea" ]]; then build_docker_images; fi |
| 86 | + echo "::endgroup::" |
| 87 | + |
| 88 | + echo "::group::start_services" |
| 89 | + start_services |
| 90 | + echo "::endgroup::" |
| 91 | + |
| 92 | + echo "::group::validate_megaservice" |
| 93 | + validate_megaservice |
| 94 | + echo "::endgroup::" |
| 95 | + |
| 96 | + echo "::group::stop_docker" |
| 97 | + stop_docker |
| 98 | + docker system prune -f |
| 99 | + echo "::endgroup::" |
| 100 | + |
| 101 | +} |
| 102 | + |
| 103 | +main |
0 commit comments