Skip to content

Commit 1c57a4b

Browse files
committed
adding the basic testing framework
1 parent 1f6678d commit 1c57a4b

File tree

5 files changed

+125
-166
lines changed

5 files changed

+125
-166
lines changed

.github/workflows/build-agentex.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/integration-tests.yml

Lines changed: 105 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,110 +4,137 @@ on:
44
workflow_dispatch:
55
inputs:
66
commit-sha:
7-
description: "Commit SHA to test against (defaults to main)"
7+
description: "Commit SHA to test against (defaults to current branch)"
88
required: false
99
type: string
10-
default: main
1110

1211
permissions:
1312
contents: read
1413
packages: write
1514

1615
jobs:
17-
pull-agent-images:
18-
name: "Pull AgentEx Images"
16+
run-integration-tests:
17+
name: "Run Integration Tests - s000-hello-acp"
1918
runs-on: ubuntu-latest
2019
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ inputs.commit-sha || github.ref }}
24+
2125
- name: Login to GitHub Container Registry
2226
uses: docker/login-action@v3
2327
with:
2428
registry: ghcr.io
2529
username: ${{ github.repository_owner }}
2630
password: ${{ secrets.GITHUB_TOKEN }}
2731

28-
- name: Debug API Permissions
29-
env:
30-
GH_TOKEN: ${{ secrets.GH_READ_PACKAGES_SECRET }}
32+
- name: Pull agent image
3133
run: |
32-
echo "🔍 Testing API permissions..."
33-
34-
# Test basic user access
35-
echo "👤 Current user:"
36-
gh api user --jq '.login' || echo "❌ User API failed"
37-
38-
# Test organization access
39-
echo "🏢 Organization access:"
40-
gh api orgs/scaleapi --jq '.login' || echo "❌ Org API failed"
34+
echo "🐳 Pulling agent image..."
35+
docker pull ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest
36+
echo "✅ Agent image pulled successfully"
4137
42-
# Test different package API endpoints
43-
echo "📦 Testing package API endpoints:"
44-
45-
echo "1. Basic packages endpoint:"
46-
gh api "orgs/scaleapi/packages" --jq 'length' || echo "❌ Basic packages API failed"
47-
48-
echo "2. Container packages endpoint:"
49-
gh api "orgs/scaleapi/packages?package_type=container" --jq 'length' || echo "❌ Container packages API failed"
50-
51-
echo "3. Public packages endpoint:"
52-
gh api "orgs/scaleapi/packages?package_type=container&visibility=public" --jq 'length' || echo "❌ Public packages API failed"
38+
- name: Start AgentEx services with host access
39+
working-directory: ./agentex
40+
run: |
41+
echo "🚀 Starting AgentEx services with host access override..."
42+
docker compose -f docker-compose.yml -f docker-compose.host-access.yml up -d
43+
echo "⏳ Waiting for services to be ready..."
44+
sleep 30
45+
docker compose ps
5346
54-
- name: Discover and pull scale-agentex-python packages
55-
env:
56-
GH_TOKEN: ${{ github.token }}
47+
- name: Run agent integration test
5748
run: |
58-
echo "🔍 Discovering packages from scale-agentex-python repo..."
49+
echo "🧪 Running integration test for agent: s000-hello-acp"
50+
echo "🐳 Using image: ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest"
51+
52+
# Start the agent container
53+
docker run -d --name agent-test-s000-hello-acp \
54+
-e AGENT_NAME=s000-hello-acp \
55+
-e ACP_URL=http://localhost \
56+
-e ACP_PORT=8000 \
57+
-e ACP_TYPE=sync \
58+
-e AGENTEX_BASE_URL=http://agentex:5003 \
59+
-e AGENTEX_API_BASE_URL=http://agentex:5003 \
60+
-p 8000:8000 \
61+
--network agentex-network \
62+
ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest
63+
64+
echo "⏳ Waiting for agent to start..."
65+
sleep 10
66+
67+
# Check for "Application startup complete" log message
68+
echo "🔍 Waiting for 'Application startup complete' log message..."
69+
TIMEOUT=60
70+
ELAPSED=0
71+
72+
while [ $ELAPSED -lt $TIMEOUT ]; do
73+
if docker logs agent-test-s000-hello-acp 2>&1 | grep -q "Application startup complete"; then
74+
echo "✅ Agent application has started successfully"
75+
break
76+
fi
77+
78+
echo "⏳ Still waiting for startup... (${ELAPSED}s/${TIMEOUT}s)"
79+
sleep 2
80+
ELAPSED=$((ELAPSED + 2))
81+
done
5982
60-
# First get all packages and save to temp file to avoid shell issues
61-
gh api "orgs/scaleapi/packages?package_type=container" > /tmp/packages.json
83+
if [ $ELAPSED -ge $TIMEOUT ]; then
84+
echo "❌ Timeout waiting for 'Application startup complete' message"
85+
echo "📋 Container logs:"
86+
docker logs agent-test-s000-hello-acp
87+
exit 1
88+
fi
6289
63-
# Extract packages from scale-agentex-python repo
64-
PACKAGES=$(cat /tmp/packages.json | jq -r '.[] | select(.repository.name == "scale-agentex-python") | .name')
90+
- name: Run agent tests with retry
91+
run: |
92+
echo "🧪 Running pytest tests against the agent..."
93+
MAX_ATTEMPTS=5
94+
ATTEMPT=1
95+
SUCCESS=false
96+
97+
while [ $ATTEMPT -le $MAX_ATTEMPTS ] && [ "$SUCCESS" = false ]; do
98+
echo "📝 Test attempt $ATTEMPT/$MAX_ATTEMPTS"
99+
100+
if docker exec agent-test-s000-hello-acp pytest tests/test_agent.py -v; then
101+
echo "✅ Tests passed on attempt $ATTEMPT!"
102+
SUCCESS=true
103+
else
104+
echo "❌ Tests failed on attempt $ATTEMPT"
105+
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
106+
echo "⏳ Waiting 5 seconds before retry..."
107+
sleep 5
108+
fi
109+
fi
110+
111+
ATTEMPT=$((ATTEMPT + 1))
112+
done
65113
66-
if [ -z "$PACKAGES" ]; then
67-
echo "❌ No packages found in scale-agentex-python repo"
68-
echo "🔍 Available packages and their repos:"
69-
cat /tmp/packages.json | jq -r '.[] | "\(.name) -> \(.repository.name // "null")"'
70-
exit 0
114+
if [ "$SUCCESS" = false ]; then
115+
echo "❌ All $MAX_ATTEMPTS test attempts failed"
116+
exit 1
71117
fi
72118
73-
echo "📦 Found packages:"
74-
echo "$PACKAGES"
119+
echo "🎉 Agent tests completed successfully!"
75120
76-
# Pull each package
77-
for package in $PACKAGES; do
78-
echo "🐳 Pulling ghcr.io/scaleapi/$package:latest"
79-
docker pull "ghcr.io/scaleapi/$package:latest" || echo "⚠️ Failed to pull $package:latest"
80-
done
121+
- name: Show agent logs
122+
if: always()
123+
run: |
124+
echo "📋 Agent logs for s000-hello-acp:"
125+
docker logs agent-test-s000-hello-acp || echo "No logs available"
126+
127+
- name: Cleanup agent container
128+
if: always()
129+
run: |
130+
echo "🧹 Cleaning up agent container..."
131+
docker stop agent-test-s000-hello-acp || true
132+
docker rm agent-test-s000-hello-acp || true
81133
82-
- name: Show pulled images
134+
- name: Cleanup services
135+
if: always()
136+
working-directory: ./agentex
83137
run: |
84-
echo "🐳 Successfully pulled images:"
85-
docker images | grep "ghcr.io/scaleapi" || echo "No scaleapi images found"
86-
87-
# run-integration-tests:
88-
# name: "Run Integration Tests"
89-
# needs: pull-agent-images
90-
# runs-on: ubuntu-latest
91-
# steps:
92-
# - name: Checkout
93-
# uses: actions/checkout@v4
94-
# with:
95-
# ref: ${{ inputs.commit-sha || 'main' }}
96-
#
97-
# - name: Login to GitHub Container Registry
98-
# uses: docker/login-action@v3
99-
# with:
100-
# registry: ghcr.io
101-
# username: ${{ github.repository_owner }}
102-
# password: ${{ secrets.GITHUB_TOKEN }}
103-
#
104-
# - name: Verify available images
105-
# run: |
106-
# echo "🐳 Available Docker images for testing:"
107-
# docker images | grep "ghcr.io/scaleapi" || echo "No scaleapi images available"
108-
#
109-
# - name: Placeholder - Integration Tests
110-
# run: |
111-
# echo "🧪 Integration tests will run here"
112-
# echo "📦 AgentEx Python dependency images are available for testing"
113-
# echo "🔄 This is where actual integration test commands should be added"
138+
echo "🧹 Cleaning up services..."
139+
docker compose -f docker-compose.yml -f docker-compose.host-access.yml down
140+
docker system prune -f

agentex/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ FROM base AS dev
3232
RUN uv sync --group dev
3333

3434
COPY agentex/src/ ./src/
35+
COPY agentex/tests/ ./tests/
36+
COPY agentex/pyproject.toml ./pyproject.toml
3537
EXPOSE 5003
3638
ENV PYTHONPATH=/app
3739
CMD ["ddtrace-run", "uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "5003", "--reload"]

agentex/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ dev-wipe: ## Stop dev server and wipe DB
5353
@echo "Stopping dev server and wiping DB"
5454
docker compose down -v
5555

56+
dev-test: install-dev ## Start development server with host access for testing
57+
@echo "🚀 Starting development server with host access for testing..."
58+
docker compose -f docker-compose.yml -f docker-compose.host-access.yml up --build
59+
60+
dev-test-stop: ## Stop development server with host access configuration
61+
@echo "Stopping dev test server with host access configuration"
62+
docker compose -f docker-compose.yml -f docker-compose.host-access.yml down
63+
5664
# Database Commands
5765
#
5866

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# docker-compose.host-access.yml
2+
# Override file to add host access when needed
3+
# Usage: docker-compose -f docker-compose.yml -f docker-compose.host-access.yml up
4+
# docker-compose.host-access.yml
5+
services:
6+
agentex:
7+
networks:
8+
agentex-network:
9+
aliases:
10+
- localhost # Make agentex reachable as localhost

0 commit comments

Comments
 (0)