Skip to content

Commit

Permalink
Merge pull request #39 from Lanture1064/dev
Browse files Browse the repository at this point in the history
feat: add test script for cli server
  • Loading branch information
bjwswang committed Mar 13, 2024
2 parents aff57b1 + a85ffb4 commit e7c5c59
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
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
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
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

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

0 comments on commit e7c5c59

Please sign in to comment.