Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test script for cli server #39

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/cli_test.yaml
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
bjwswang marked this conversation as resolved.
Show resolved Hide resolved
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: .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
9 changes: 9 additions & 0 deletions .github/workflows/image_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ jobs:
test_image_build:
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
Expand Down
36 changes: 36 additions & 0 deletions tests/example_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

# Install curl
apt-get install -y curl
bjwswang marked this conversation as resolved.
Show resolved Hide resolved

# 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"
Loading