From e44030711bf46eb3665de988be25282ae7070062 Mon Sep 17 00:00:00 2001 From: letonghan Date: Tue, 10 Dec 2024 14:20:49 +0800 Subject: [PATCH] combine test script Signed-off-by: letonghan --- .../test_retrievers_redis_langchain.sh | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/retrievers/test_retrievers_redis_langchain.sh b/tests/retrievers/test_retrievers_redis_langchain.sh index dd34a2a0f..0439f5bcf 100644 --- a/tests/retrievers/test_retrievers_redis_langchain.sh +++ b/tests/retrievers/test_retrievers_redis_langchain.sh @@ -42,14 +42,29 @@ function start_service() { sleep 3m } +function start_multimodal_service() { + # redis + docker run -d --name test-comps-retriever-redis-vector-db -p 5689:6379 -p 5011:8001 -e HTTPS_PROXY=$https_proxy -e HTTP_PROXY=$https_proxy redis/redis-stack:7.2.0-v9 + sleep 10s + + # redis retriever + export REDIS_URL="redis://${ip_address}:5689" + export INDEX_NAME="rag-redis" + retriever_port=5434 + unset http_proxy + docker run -d --name="test-comps-retriever-redis-server" -p ${retriever_port}:7000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e BRIDGE_TOWER_EMBEDDING=true opea/retriever-redis:comps + + sleep 5m +} + function validate_microservice() { + local test_embedding="$1" + retriever_port=5435 export PATH="${HOME}/miniforge3/bin:$PATH" source activate URL="http://${ip_address}:$retriever_port/v1/retrieval" - test_embedding=$(python -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)") - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "{\"text\":\"test\",\"embedding\":${test_embedding}}" -H 'Content-Type: application/json' "$URL") if [ "$HTTP_STATUS" -eq 200 ]; then echo "[ retriever ] HTTP status is 200. Checking content..." @@ -81,12 +96,20 @@ function stop_docker() { function main() { stop_docker - build_docker_images + + # test text retriever start_service + test_embedding=$(python -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)") + validate_microservice "$test_embedding" - validate_microservice + # test multimodal retriever + stop_docker + start_multimodal_service + test_embedding_multi=$(python -c "import random; embedding = [random.uniform(-1, 1) for _ in range(512)]; print(embedding)") + validate_microservice "$test_embedding_multi" + # clean env stop_docker echo y | docker system prune