Skip to content

Commit

Permalink
Check build fail and change port 8008 to 5025/5026. (#487)
Browse files Browse the repository at this point in the history
Signed-off-by: zepan <[email protected]>
  • Loading branch information
ZePan110 authored Aug 15, 2024
1 parent 4a67d42 commit 5159aac
Show file tree
Hide file tree
Showing 33 changed files with 344 additions and 84 deletions.
7 changes: 6 additions & 1 deletion tests/test_agent_langchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ function build_docker_images() {
cd $WORKPATH
echo $WORKPATH
docker build -t opea/comps-agent-langchain:comps -f comps/agent/langchain/docker/Dockerfile .

if $? ; then
echo "opea/comps-agent-langchain built fail"
exit 1
else
echo "opea/comps-agent-langchain built successful"
fi
}

function start_service() {
Expand Down
12 changes: 12 additions & 0 deletions tests/test_asr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/whisper:comps -f comps/asr/whisper/Dockerfile .
if $? ; then
echo "opea/whisper built fail"
exit 1
else
echo "opea/whisper built successful"
fi
docker build --no-cache -t opea/asr:comps -f comps/asr/Dockerfile .
if $? ; then
echo "opea/asr built fail"
exit 1
else
echo "opea/asr built successful"
fi
}

function start_service() {
Expand Down
9 changes: 8 additions & 1 deletion tests/test_chathistory_mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -xe
set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')
Expand All @@ -18,6 +18,12 @@ function build_docker_images() {
docker run -d -p 27017:27017 --name=test-comps-mongo mongo:latest

docker build --no-cache -t opea/chathistory-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/mongo/docker/Dockerfile .
if $? ; then
echo "opea/chathistory-mongo-server built fail"
exit 1
else
echo "opea/chathistory-mongo-server built successful"
fi
}

function start_service() {
Expand All @@ -42,6 +48,7 @@ function validate_microservice() {
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-chathistory-mongo-server
exit 1
fi

Expand Down
12 changes: 12 additions & 0 deletions tests/test_dataprep_milvus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ function build_docker_images() {
echo $(pwd)
# langchain mosec embedding image
docker build --no-cache -t opea/langchain-mosec:comps --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -f comps/embeddings/langchain-mosec/mosec-docker/Dockerfile .
if $? ; then
echo "opea/langchain-mosec built fail"
exit 1
else
echo "opea/langchain-mosec built successful"
fi
# dataprep milvus image
docker build --no-cache -t opea/dataprep-milvus:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/milvus/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-milvus built fail"
exit 1
else
echo "opea/dataprep-milvus built successful"
fi
}

function start_service() {
Expand Down
6 changes: 6 additions & 0 deletions tests/test_dataprep_pgvector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ function build_docker_images() {

# build dataprep image for pgvector
docker build -t opea/dataprep-pgvector:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f $WORKPATH/comps/dataprep/pgvector/langchain/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-pgvector built fail"
exit 1
else
echo "opea/dataprep-pgvector built successful"
fi
}

function start_service() {
Expand Down
22 changes: 14 additions & 8 deletions tests/test_dataprep_pinecone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,49 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -xe
set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')
function build_docker_images() {
cd $WORKPATH

# build dataprep image for pinecone
docker build -t opea/dataprep-pinecone:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f $WORKPATH/comps/dataprep/pinecone/docker/Dockerfile .
docker build -t opea/dataprep-pinecone:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f $WORKPATH/comps/dataprep/pinecone/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-pinecone built fail"
exit 1
else
echo "opea/dataprep-pinecone built successful"
fi
}

function start_service() {
export PINECONE_API_KEY=$PINECONE_KEY
export PINECONE_INDEX_NAME="test-index"
export HUGGINGFACEHUB_API_TOKEN=$HF_TOKEN

docker run -d --name="dataprep-pinecone" -p 6007:6007 -p 6008:6008 -p 6009:6009 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e PINECONE_API_KEY=$PINECONE_API_KEY -e PINECONE_INDEX_NAME=$PINECONE_INDEX_NAME opea/dataprep-pinecone:latest
docker run -d --name="test-comps-dataprep-pinecone" -p 6007:6007 -p 6008:6008 -p 6009:6009 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e PINECONE_API_KEY=$PINECONE_API_KEY -e PINECONE_INDEX_NAME=$PINECONE_INDEX_NAME opea/dataprep-pinecone:comps

sleep 1m
}

function validate_microservice() {
URL="http://$ip_address:6007/v1/dataprep"
echo 'The OPEA platform includes: Detailed framework of composable building blocks for state-of-the-art generative AI systems including LLMs, data stores, and prompt engines' > ./dataprep_file.txt
curl --noproxy $ip_address --location --request POST \
--form 'files=@./dataprep_file.txt' $URL
result=$(curl --noproxy $ip_address --location --request POST \
--form 'files=@./dataprep_file.txt' $URL)

DELETE_URL="http://$ip_address:6009/v1/dataprep/delete_file"
curl --noproxy $ip_address --location --request POST \
-d '{"file_path": "all"}' -H 'Content-Type: application/json' $DELETE_URL
result_2=$(curl --noproxy $ip_address --location --request POST \
-d '{"file_path": "all"}' -H 'Content-Type: application/json' $DELETE_URL)
}

function stop_docker() {
cid=$(docker ps -aq --filter "name=vectorstore-pinecone*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi

cid=$(docker ps -aq --filter "name=dataprep-pinecone*")
cid=$(docker ps -aq --filter "name=test-comps-dataprep-pinecone*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
}

Expand Down
6 changes: 6 additions & 0 deletions tests/test_dataprep_qdrant_langchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function build_docker_images() {

# dataprep qdrant image
docker build --no-cache -t opea/dataprep-qdrant:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/qdrant/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-qdrant built fail"
exit 1
else
echo "opea/dataprep-qdrant built successful"
fi
}

function start_service() {
Expand Down
6 changes: 6 additions & 0 deletions tests/test_dataprep_redis_langchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/dataprep-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/redis/langchain/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-redis built fail"
exit 1
else
echo "opea/dataprep-redis built successful"
fi
}

function start_service() {
Expand Down
15 changes: 10 additions & 5 deletions tests/test_dataprep_redis_langchain_ray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ function build_docker_images() {
echo "Building the docker images"
cd $WORKPATH
docker build -t opea/dataprep-on-ray-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/redis/langchain_ray/docker/Dockerfile .
echo "Docker image built successfully"
if $? ; then
echo "opea/dataprep-on-ray-redis built fail"
exit 1
else
echo "opea/dataprep-on-ray-redis built successful"
fi
}

function start_service() {
echo "Starting redis microservice"
# redis endpoint
docker run -d --name="test-comps-dataprep-redis-ray" --runtime=runc -p 6382:6379 -p 8004:8001 redis/redis-stack:7.2.0-v9
docker run -d --name="test-comps-dataprep-redis-ray" --runtime=runc -p 5038:6379 -p 8004:8001 redis/redis-stack:7.2.0-v9

# dataprep-redis-server endpoint
export REDIS_URL="redis://${ip_address}:6382"
export REDIS_URL="redis://${ip_address}:5038"
export INDEX_NAME="rag-redis"
echo "Starting dataprep-redis-server"
docker run -d --name="test-comps-dataprep-redis-ray-server" --runtime=runc -p 6009:6007 -p 6010:6008 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e TIMEOUT_SECONDS=600 opea/dataprep-on-ray-redis:comps
docker run -d --name="test-comps-dataprep-redis-ray-server" --runtime=runc -p 5037:6007 -p 6010:6008 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e TIMEOUT_SECONDS=600 opea/dataprep-on-ray-redis:comps

sleep 10
echo "Service started successfully"
Expand All @@ -33,7 +38,7 @@ function start_service() {
function validate_microservice() {
cd $LOG_PATH

dataprep_service_port=6009
dataprep_service_port=5037
export URL="http://${ip_address}:$dataprep_service_port/v1/dataprep"

echo "Starting validating the microservice"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_dataprep_redis_llama_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/dataprep-redis-llama-index:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/redis/llama_index/docker/Dockerfile .
if $? ; then
echo "opea/dataprep-redis-llama-index built fail"
exit 1
else
echo "opea/dataprep-redis-llama-index built successful"
fi
}

function start_service() {
Expand Down
12 changes: 12 additions & 0 deletions tests/test_embeddings_langchain-mosec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@ function build_mosec_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --no-cache -t opea/embedding-langchain-mosec-endpoint:comps -f comps/embeddings/langchain-mosec/mosec-docker/Dockerfile .
if $? ; then
echo "opea/embedding-langchain-mosec-endpoint built fail"
exit 1
else
echo "opea/embedding-langchain-mosec-endpoint built successful"
fi
}

function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --no-cache -t opea/embedding-langchain-mosec:comps -f comps/embeddings/langchain-mosec/docker/Dockerfile .
if $? ; then
echo "opea/embedding-langchain-mosec built fail"
exit 1
else
echo "opea/embedding-langchain-mosec built successful"
fi
}

function start_service() {
Expand Down
12 changes: 9 additions & 3 deletions tests/test_embeddings_langchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -xe
set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')
Expand All @@ -11,6 +11,12 @@ function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/embedding-tei:comps -f comps/embeddings/langchain/docker/Dockerfile .
if $? ; then
echo "opea/embedding-tei built fail"
exit 1
else
echo "opea/embedding-tei built successful"
fi
}

function start_service() {
Expand All @@ -27,10 +33,10 @@ function start_service() {

function validate_microservice() {
tei_service_port=5002
http_proxy="" curl http://${ip_address}:$tei_service_port/v1/embeddings \
result=$(http_proxy="" curl http://${ip_address}:$tei_service_port/v1/embeddings \
-X POST \
-d '{"text":"What is Deep Learning?"}' \
-H 'Content-Type: application/json'
-H 'Content-Type: application/json')
}

function stop_docker() {
Expand Down
8 changes: 7 additions & 1 deletion tests/test_embeddings_llama_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -xe
set -x

WORKPATH=$(dirname "$PWD")
LOG_PATH="$WORKPATH/tests"
Expand All @@ -12,6 +12,12 @@ function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/embedding-tei-llamaindex:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/embeddings/llama_index/docker/Dockerfile .
if $? ; then
echo "opea/embedding-tei-llamaindex built fail"
exit 1
else
echo "opea/embedding-tei-llamaindex built successful"
fi
}

function start_service() {
Expand Down
25 changes: 16 additions & 9 deletions tests/test_guardrails_llama_guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -xe
set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')
Expand All @@ -12,40 +12,47 @@ function build_docker_images() {
cd $WORKPATH
docker pull ghcr.io/huggingface/tgi-gaudi:2.0.1
docker build --no-cache -t opea/guardrails-tgi:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/guardrails/llama_guard/docker/Dockerfile .
echo "Docker images built"
if $? ; then
echo "opea/guardrails-tgi built fail"
exit 1
else
echo "opea/guardrails-tgi built successful"
fi
}

function start_service() {
echo "Starting microservice"
export model_id="meta-llama/Meta-Llama-Guard-2-8B"
export SAFETY_GUARD_MODEL_ID="meta-llama/Meta-Llama-Guard-2-8B"
export SAFETY_GUARD_ENDPOINT=http://${ip_address}:8088/v1/chat/completions
export SAFETY_GUARD_ENDPOINT=http://${ip_address}:5035/v1/chat/completions

docker run -d --name="test-comps-guardrails-langchain-tgi-server" -p 8088:80 --runtime=habana -e HF_TOKEN=$HF_TOKEN -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host -e HTTPS_PROXY=$https_proxy -e HTTP_PROXY=$https_proxy ghcr.io/huggingface/tgi-gaudi:2.0.1 --model-id $model_id --max-input-length 1024 --max-total-tokens 2048
docker run -d --name="test-comps-guardrails-langchain-tgi-server" -p 5035:80 --runtime=habana -e HF_TOKEN=$HF_TOKEN -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host -e HTTPS_PROXY=$https_proxy -e HTTP_PROXY=$https_proxy ghcr.io/huggingface/tgi-gaudi:2.0.1 --model-id $model_id --max-input-length 1024 --max-total-tokens 2048
sleep 4m
docker run -d --name="test-comps-guardrails-langchain-service" -p 9090:9090 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e SAFETY_GUARD_MODEL_ID=$SAFETY_GUARD_MODEL_ID -e SAFETY_GUARD_ENDPOINT=$SAFETY_GUARD_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HF_TOKEN opea/guardrails-tgi:comps
docker run -d --name="test-comps-guardrails-langchain-service" -p 5036:9090 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e SAFETY_GUARD_MODEL_ID=$SAFETY_GUARD_MODEL_ID -e SAFETY_GUARD_ENDPOINT=$SAFETY_GUARD_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HF_TOKEN opea/guardrails-tgi:comps
sleep 10s
echo "Microservice started"
}

function validate_microservice() {
echo "Validate microservice started"
echo "test 1 - violated policies"
docker logs test-comps-guardrails-langchain-tgi-server
docker logs test-comps-guardrails-langchain-service
result=$(http_proxy= curl http://localhost:9090/v1/guardrails -X POST -d '{"text":"How do you buy a tiger in the US?","parameters":{"max_new_tokens":32}}' -H 'Content-Type: application/json')
result=$(http_proxy= curl http://localhost:5036/v1/guardrails -X POST -d '{"text":"How do you buy a tiger in the US?","parameters":{"max_new_tokens":32}}' -H 'Content-Type: application/json')
if [[ $result == *"Violated"* ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-guardrails-langchain-tgi-server
docker logs test-comps-guardrails-langchain-service
exit 1
fi
echo "test 2 - safe"
result=$(http_proxy= curl http://localhost:9090/v1/guardrails -X POST -d '{"text":"How do you buy a car in the US?","parameters":{"max_new_tokens":32}}' -H 'Content-Type: application/json')
result=$(http_proxy= curl http://localhost:5036/v1/guardrails -X POST -d '{"text":"How do you buy a car in the US?","parameters":{"max_new_tokens":32}}' -H 'Content-Type: application/json')
if [[ $result == *"car"* ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-guardrails-langchain-tgi-server
docker logs test-comps-guardrails-langchain-service
exit 1
fi

Expand Down
7 changes: 6 additions & 1 deletion tests/test_guardrails_pii_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ function build_docker_images() {
echo "Start building docker images for microservice"
cd $WORKPATH
docker build -t opea/guardrails-pii-detection:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/guardrails/pii_detection/docker/Dockerfile .
echo "Docker images built"
if $? ; then
echo "opea/guardrails-pii-detection built fail"
exit 1
else
echo "opea/guardrails-pii-detection built successful"
fi
}

function start_service() {
Expand Down
Loading

0 comments on commit 5159aac

Please sign in to comment.