Skip to content

Commit

Permalink
add local_build in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Chendi.Xue <[email protected]>
  • Loading branch information
xuechendi committed Jul 16, 2024
1 parent 3a1e208 commit eb91097
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
27 changes: 15 additions & 12 deletions DocIndexRetriever/tests/test_docindexretriever_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ function start_services() {
export RERANK_SERVICE_HOST_IP=${ip_address}
export LLM_SERVICE_HOST_IP=${ip_address}

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/doc-index-retriever:latest#image: opea/doc-index-retriever:${IMAGE_TAG}#g" docker_compose.yaml
cat docker_compose.yaml
fi

# Start Docker Containers
docker compose -f docker_compose.yaml up -d
sleep 20
Expand All @@ -63,13 +56,11 @@ function validate() {
local CONTENT="$1"
local EXPECTED_RESULT="$2"
local SERVICE_NAME="$3"
local DOCKER_NAME="$4"

if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then
echo "[ $SERVICE_NAME ] Content is as expected."
else
echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT"
docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
exit 1
fi
}
Expand All @@ -79,14 +70,26 @@ function validate_megaservice() {
local CONTENT=$(curl -X POST "http://${ip_address}:6007/v1/dataprep" \
-H "Content-Type: multipart/form-data" \
-F 'link_list=["https://opea.dev"]' | tee ${LOG_PATH}/dataprep-redis-service-gaudi.log)
validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-gaudi" "dataprep-redis-server"
validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-gaudi" || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 1 ]; then
docker logs dataprep-redis-server | tee -a ${LOG_PATH}/dataprep-redis-service-gaudi.log
return 1
fi
return 0

# Curl the Mega Service
echo "Testing retriever service"
local CONTENT=$(curl http://${ip_address}:8889/v1/retrievaltool -X POST -H "Content-Type: application/json" -d '{
"text": "Explain the OPEA project?"
}' | tee ${LOG_PATH}/doc-index-retriever-service-gaudi.log)
validate "$CONTENT" "Enterprise AI (OPEA)" "doc-index-retriever-service-gaudi" "doc-index-retriever-server"
validate "$CONTENT" "Enterprise AI (OPEA)" "doc-index-retriever-service-gaudi" || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 1 ]; then
docker logs tei-embedding-gaudi-server | tee -a ${LOG_PATH}/doc-index-retriever-service-gaudi.log
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-gaudi.log
docker logs reranking-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-gaudi.log
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-gaudi.log
exit 1
fi
}

function stop_docker() {
Expand All @@ -102,7 +105,7 @@ function stop_docker() {
function main() {

stop_docker
if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
build_docker_images
start_time=$(date +%s)
start_services
end_time=$(date +%s)
Expand Down
28 changes: 15 additions & 13 deletions DocIndexRetriever/tests/test_docindexretriever_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function build_docker_images() {
cd $WORKPATH/../../
if [ ! -d "GenAIComps" ] ; then
git clone https://github.com/opea-project/GenAIComps.git
cd GenAIComps; git fetch origin pull/314/head:PR314; git checkout PR314
fi
cd GenAIComps

Expand Down Expand Up @@ -45,13 +44,6 @@ function start_services() {
export RERANK_SERVICE_HOST_IP=${ip_address}
export LLM_SERVICE_HOST_IP=${ip_address}

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/doc-index-retriever:latest#image: opea/doc-index-retriever:${IMAGE_TAG}#g" docker_compose.yaml
cat docker_compose.yaml
fi

# Start Docker Containers
docker compose -f docker_compose.yaml up -d
sleep 20
Expand All @@ -62,13 +54,11 @@ function validate() {
local CONTENT="$1"
local EXPECTED_RESULT="$2"
local SERVICE_NAME="$3"
local DOCKER_NAME="$4"

if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then
echo "[ $SERVICE_NAME ] Content is as expected."
else
echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT"
docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
exit 1
fi
}
Expand All @@ -78,14 +68,26 @@ function validate_megaservice() {
local CONTENT=$(curl -X POST "http://${ip_address}:6007/v1/dataprep" \
-H "Content-Type: multipart/form-data" \
-F 'link_list=["https://opea.dev"]' | tee ${LOG_PATH}/dataprep-redis-service-xeon.log)
validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-xeon" "dataprep-redis-server"
validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-xeon" || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 1 ]; then
docker logs dataprep-redis-server | tee -a ${LOG_PATH}/dataprep-redis-service-xeon.log
return 1
fi
return 0

# Curl the Mega Service
echo "Testing retriever service"
local CONTENT=$(curl http://${ip_address}:8889/v1/retrievaltool -X POST -H "Content-Type: application/json" -d '{
"text": "Explain the OPEA project?"
}' | tee ${LOG_PATH}/doc-index-retriever-service-xeon.log)
validate "$CONTENT" "Enterprise AI (OPEA)" "doc-index-retriever-service-xeon" "doc-index-retriever-server"
validate "$CONTENT" "Enterprise AI (OPEA)" "doc-index-retriever-service-xeon" || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 1 ]; then
docker logs tei-embedding-xeon-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
docker logs reranking-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
exit 1
fi
}

function stop_docker() {
Expand All @@ -101,7 +103,7 @@ function stop_docker() {
function main() {

stop_docker
if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
build_docker_images
start_time=$(date +%s)
start_services
end_time=$(date +%s)
Expand Down

0 comments on commit eb91097

Please sign in to comment.