-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Lanture1064/dev
feat: add test script for cli server
- Loading branch information
Showing
3 changed files
with
114 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,69 @@ | ||
name: Build and Test KubeAGI CLI Server | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
env: | ||
PYTHON_INDEX_URL: https://pypi.org/simple | ||
PACKAGE_REGISTRY: deb.debian.org | ||
|
||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Maximize build space | ||
uses: easimon/maximize-build-space@master | ||
with: | ||
overprovision-lvm: true | ||
remove-dotnet: 'true' | ||
remove-android: 'true' | ||
remove-haskell: 'true' | ||
remove-codeql: 'true' | ||
remove-docker-images: 'true' | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: --debug | ||
config-inline: | | ||
[worker.oci] | ||
max-parallelism = 1 | ||
- name: Set up GCC | ||
uses: egor-tensin/setup-gcc@v1 | ||
with: | ||
version: latest | ||
platform: x64 | ||
- name: Build core library cli image | ||
id: build-worker | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
load: true | ||
push: false | ||
tags: test-image | ||
build-args: | | ||
PACKAGE_REGISTRY=${{ env.PACKAGE_REGISTRY }} | ||
PYTHON_INDEX_URL=${{ env.PYTHON_INDEX_URL }} | ||
- name: Run Docker Container | ||
run: | | ||
docker run -d --name cli-container test-image | ||
docker ps | ||
- name: Run test script | ||
run: | | ||
docker logs cli-container | ||
docker cp tests/example_test.sh cli-container:/tmp/example_test.sh | ||
docker exec cli-container bash /tmp/example_test.sh | ||
- name: Stop and Remove Container | ||
if: always() | ||
run: | | ||
docker stop cli-container | ||
docker rm cli-container |
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
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,36 @@ | ||
#!/bin/sh | ||
|
||
# Install curl | ||
apt-get install -y curl | ||
|
||
# Test GET /api/v1/health | ||
echo "---------------------------------------" | ||
echo "Sleeping for 20 seconds..." | ||
sleep 20 | ||
|
||
echo "Testing GET /api/v1/health" | ||
response=$(curl -s -X GET http://localhost:8000/api/v1/health) | ||
expected='{"Health":true}' | ||
|
||
if [ "$response" = "$expected" ]; then | ||
echo "GET /api/v1/health passed" | ||
else | ||
echo "GET /api/v1/health failed. Expected $expected, got $response" | ||
exit 1 | ||
fi | ||
|
||
echo "---------------------------------------" | ||
|
||
# Test POST /api/v1/reranking | ||
echo "Testing POST /api/v1/reranking" | ||
data='{"question": "How are you today?", "answers": ["I am fine now, thank you.", "I was doing my business."]}' | ||
response=$(curl -s -X POST -H "Content-Type: application/json" -H 'accept: application/json' -d "$data" http://localhost:8000/api/v1/reranking) | ||
|
||
if [ -z "$response" ]; then | ||
echo "POST /api/v1/reranking failed to get a response" | ||
exit 1 | ||
else | ||
echo "Reranking results: $response" | ||
fi | ||
|
||
echo "All tests passed" |