forked from opea-project/GenAIComps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -x | ||
|
||
WORKPATH=$(dirname "$PWD") | ||
ip_address=$(hostname -I | awk '{print $1}') | ||
|
||
export ARANGO_HOST=${ip_address} | ||
export ARANGO_PORT=8529 | ||
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL:-"http"} | ||
export ARANGO_USERNAME=${ARANGO_USERNAME:-"root"} | ||
export ARANGO_PASSWORD=${ARANGO_PASSWORD:-"test"} | ||
export DB_NAME=${DB_NAME:-"Conversations"} | ||
export COLLECTION_NAME=${COLLECTION_NAME:-"test"} | ||
|
||
function build_docker_images() { | ||
cd $WORKPATH | ||
echo $(pwd) | ||
docker run -d -p 8529:8529 --name=test-comps-arango arangodb/arangodb:latest | ||
|
||
docker build --no-cache -t opea/chathistory-arango-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/arango/Dockerfile . | ||
if [ $? -ne 0 ]; then | ||
echo "opea/chathistory-arango-server built fail" | ||
exit 1 | ||
else | ||
echo "opea/chathistory-arango-server built successful" | ||
fi | ||
} | ||
|
||
function start_service() { | ||
|
||
docker run -d --name="test-comps-chathistory-arango-server" \ | ||
-p 6012:6012 \ | ||
-e http_proxy=$http_proxy \ | ||
-e https_proxy=$https_proxy \ | ||
-e no_proxy=$no_proxy \ | ||
-e ARANGO_HOST=${ARANGO_HOST} \ | ||
-e ARANGO_PORT=${ARANGO_PORT} \ | ||
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \ | ||
-e ARANGO_USERNAME=${ARANGO_USERNAME} \ | ||
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \ | ||
-e DB_NAME=${DB_NAME} \ | ||
-e COLLECTION_NAME=${COLLECTION_NAME} \ | ||
opea/chathistory-arango-server:comps | ||
|
||
sleep 10s | ||
} | ||
|
||
function validate_microservice() { | ||
result=$(curl -X 'POST' \ | ||
http://${ip_address}:6012/v1/chathistory/create \ | ||
-H 'accept: application/json' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"data": { | ||
"messages": "test Messages", "user": "test" | ||
} | ||
}') | ||
echo $result | ||
if [[ ${#result} -eq 26 ]]; then | ||
echo "Result correct." | ||
else | ||
echo "Result wrong." | ||
docker logs test-comps-chathistory-arango-server | ||
exit 1 | ||
fi | ||
|
||
} | ||
|
||
function stop_docker() { | ||
cid=$(docker ps -aq --filter "name=test-comps*") | ||
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi | ||
} | ||
|
||
function main() { | ||
|
||
stop_docker | ||
|
||
build_docker_images | ||
start_service | ||
|
||
validate_microservice | ||
|
||
stop_docker | ||
echo y | docker system prune | ||
|
||
} | ||
|
||
main |
113 changes: 113 additions & 0 deletions
113
tests/feedback_management/test_feedback_management_arango.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -xe | ||
|
||
WORKPATH=$(dirname "$PWD") | ||
ip_address=$(hostname -I | awk '{print $1}') | ||
|
||
export ARANGO_HOST=${ip_address} | ||
export ARANGO_PORT=8529 | ||
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL:-"http"} | ||
export ARANGO_USERNAME=${ARANGO_USERNAME:-"root"} | ||
export ARANGO_PASSWORD=${ARANGO_PASSWORD:-"test"} | ||
export DB_NAME=${DB_NAME:-"Feedback"} | ||
export COLLECTION_NAME=${COLLECTION_NAME:-"test"} | ||
|
||
function build_docker_images() { | ||
cd $WORKPATH | ||
echo $(pwd) | ||
docker run -d -p 8529:8529 --name=test-comps-arango arangodb/arangodb:latest | ||
|
||
docker build --no-cache -t opea/feedbackmanagement-arango-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/feedback_management/arango/Dockerfile . | ||
if [ $? -ne 0 ]; then | ||
echo "opea/feedbackmanagement-arango-server built fail" | ||
exit 1 | ||
else | ||
echo "opea/feedbackmanagement-arango-server built successful" | ||
fi | ||
} | ||
|
||
function start_service() { | ||
|
||
docker run -d --name="test-comps-feedbackmanagement-arango-server" \ | ||
-p 6016:6016 \ | ||
-e http_proxy=$http_proxy \ | ||
-e https_proxy=$https_proxy \ | ||
-e no_proxy=$no_proxy \ | ||
-e ARANGO_HOST=${ARANGO_HOST} \ | ||
-e ARANGO_PORT=${ARANGO_PORT} \ | ||
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \ | ||
-e ARANGO_USERNAME=${ARANGO_USERNAME} \ | ||
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \ | ||
-e DB_NAME=${DB_NAME} \ | ||
-e COLLECTION_NAME=${COLLECTION_NAME} \ | ||
opea/feedbackmanagement-arango-server:comps | ||
|
||
sleep 10s | ||
} | ||
|
||
function validate_microservice() { | ||
result=$(curl -X 'POST' \ | ||
http://$ip_address:6016/v1/feedback/create \ | ||
-H 'accept: application/json' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"chat_id": "66445d4f71c7eff23d44f78d", | ||
"chat_data": { | ||
"user": "test", | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "You are helpful assistant" | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "hi", | ||
"time": "1724915247" | ||
}, | ||
{ | ||
"role": "assistant", | ||
"content": "Hi, may I help you?", | ||
"time": "1724915249" | ||
} | ||
] | ||
}, | ||
"feedback_data": { | ||
"comment": "Moderate", | ||
"rating": 3, | ||
"is_thumbs_up": true | ||
} | ||
}') | ||
echo $result | ||
if [[ ${#result} -eq 26 ]]; then | ||
echo "Correct result." | ||
else | ||
echo "Incorrect result." | ||
docker logs test-comps-feedbackmanagement-arango-server | ||
exit 1 | ||
fi | ||
|
||
} | ||
|
||
function stop_docker() { | ||
cid=$(docker ps -aq --filter "name=test-comps*") | ||
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi | ||
} | ||
|
||
function main() { | ||
|
||
stop_docker | ||
|
||
build_docker_images | ||
start_service | ||
|
||
validate_microservice | ||
|
||
stop_docker | ||
echo y | docker system prune | ||
|
||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -x | ||
|
||
WORKPATH=$(dirname "$PWD") | ||
ip_address=$(hostname -I | awk '{print $1}') | ||
|
||
export ARANGO_HOST=${ip_address} | ||
export ARANGO_PORT=8529 | ||
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL:-"http"} | ||
export ARANGO_USERNAME=${ARANGO_USERNAME:-"root"} | ||
export ARANGO_PASSWORD=${ARANGO_PASSWORD:-"test"} | ||
export DB_NAME=${DB_NAME:-"Prompts"} | ||
export COLLECTION_NAME=${COLLECTION_NAME:-"test"} | ||
|
||
function build_docker_images() { | ||
cd $WORKPATH | ||
echo $(pwd) | ||
docker run -d -p 8529:8529 --name=test-comps-arango arangodb/arangodb:latest | ||
|
||
docker build --no-cache -t opea/promptregistry-arango-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/prompt_registry/arango/Dockerfile . | ||
if [ $? -ne 0 ]; then | ||
echo "opea/promptregistry-arango-server built fail" | ||
exit 1 | ||
else | ||
echo "opea/promptregistry-arango-server built successful" | ||
fi | ||
} | ||
|
||
function start_service() { | ||
|
||
docker run -d --name="test-comps-promptregistry-arango-server" \ | ||
-p 6018:6018 \ | ||
-e http_proxy=$http_proxy \ | ||
-e https_proxy=$https_proxy \ | ||
-e no_proxy=$no_proxy \ | ||
-e ARANGO_HOST=${ARANGO_HOST} \ | ||
-e ARANGO_PORT=${ARANGO_PORT} \ | ||
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \ | ||
-e ARANGO_USERNAME=${ARANGO_USERNAME} \ | ||
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \ | ||
-e DB_NAME=${DB_NAME} \ | ||
-e COLLECTION_NAME=${COLLECTION_NAME} \ | ||
opea/promptregistry-arango-server:comps | ||
|
||
sleep 10s | ||
} | ||
|
||
function validate_microservice() { | ||
result=$(curl -X 'POST' \ | ||
http://$ip_address:6018/v1/prompt/create \ | ||
-H 'accept: application/json' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"prompt_text": "test prompt", "user": "test" | ||
}') | ||
echo $result | ||
if [[ ${#result} -eq 26 ]]; then | ||
echo "Correct result." | ||
else | ||
echo "Incorrect result." | ||
docker logs test-comps-promptregistry-arango-server | ||
exit 1 | ||
fi | ||
|
||
} | ||
|
||
function stop_docker() { | ||
cid=$(docker ps -aq --filter "name=test-comps*") | ||
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi | ||
} | ||
|
||
function main() { | ||
|
||
stop_docker | ||
|
||
build_docker_images | ||
start_service | ||
|
||
validate_microservice | ||
|
||
stop_docker | ||
echo y | docker system prune | ||
|
||
} | ||
|
||
main |