Skip to content

Commit 63ee480

Browse files
committed
adding more env vars
1 parent bc2f5c5 commit 63ee480

File tree

1 file changed

+128
-111
lines changed

1 file changed

+128
-111
lines changed

.github/workflows/integration-tests.yml

Lines changed: 128 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,6 @@ jobs:
172172
echo "📋 Final service status after health checks:"
173173
docker compose ps
174174
175-
- name: Install agent container dependencies
176-
run: |
177-
# Set variables for this agent
178-
AGENT_NAME="${{ matrix.agent.agent_name }}"
179-
CONTAINER_NAME="agent-test-${AGENT_NAME}"
180-
181-
echo "📦 Installing Node.js and NPM in agent container..."
182-
docker exec "${CONTAINER_NAME}" sh -c "
183-
apt-get update -qq &&
184-
apt-get install -y -qq nodejs npm &&
185-
echo '✅ Node.js version:' && node --version &&
186-
echo '✅ NPM version:' && npm --version
187-
" || echo "⚠️ Failed to install Node.js, tests may fail"
188-
189175
- name: Run agent integration test
190176
env:
191177
OPENAI_API_KEY: ${{ secrets.TUTORIAL_OPENAI_API_KEY }}
@@ -198,45 +184,95 @@ jobs:
198184
echo "🧪 Running integration test for agent: ${AGENT_NAME}"
199185
echo "🐳 Using image: ${AGENT_IMAGE}"
200186
201-
# Debug: Check if OPENAI_API_KEY is available
202-
if [ -z "$OPENAI_API_KEY" ]; then
203-
echo "⚠️ OPENAI_API_KEY is not set or empty"
204-
else
205-
echo "✅ OPENAI_API_KEY is available (length: ${#OPENAI_API_KEY})"
206-
fi
207-
208-
# Determine ACP type from image name
187+
# Determine ACP type and agent characteristics from image name
209188
if [[ "${AGENT_IMAGE}" == *"10_async"* ]]; then
210189
ACP_TYPE="async"
211-
echo "🔄 Detected ASYNC agent type"
212190
else
213191
ACP_TYPE="sync"
214-
echo "🔄 Detected SYNC agent type"
215192
fi
216193
217-
# Start the agent container
218-
docker run -d --name "${CONTAINER_NAME}" \
219-
-e AGENT_NAME="${AGENT_NAME}" \
220-
-e ACP_URL="http://${CONTAINER_NAME}" \
221-
-e ACP_PORT=8000 \
222-
-e ACP_TYPE="${ACP_TYPE}" \
223-
-e AGENTEX_BASE_URL=http://agentex:5003 \
224-
-e AGENTEX_API_BASE_URL=http://agentex:5003 \
225-
-e REDIS_URL=redis://agentex-redis:6379 \
226-
-e TEMPORAL_ADDRESS=agentex-temporal:7233 \
227-
-e TEMPORAL_HOST=agentex-temporal \
228-
-e OPENAI_API_KEY="${OPENAI_API_KEY}" \
229-
-p 8000:8000 \
230-
--network agentex-network \
231-
"${AGENT_IMAGE}"
194+
# Check if this is a Temporal agent
195+
if [[ "${AGENT_IMAGE}" == *"temporal"* ]]; then
196+
IS_TEMPORAL_AGENT=true
197+
198+
# Extract queue name from agent name (e.g., "10-temporal-000-hello-acp" -> "000_hello_acp_queue")
199+
QUEUE_NAME=$(echo "${AGENT_NAME}" | sed -E 's/.*temporal-([0-9]+)-(.*)$/\1_\2_queue/' | tr '-' '_')
200+
else
201+
IS_TEMPORAL_AGENT=false
202+
fi
203+
204+
# Start the agent container with appropriate configuration
205+
if [ "${IS_TEMPORAL_AGENT}" = true ]; then
206+
# Temporal agent: start both worker and ACP server
207+
docker run -d --name "${CONTAINER_NAME}" \
208+
-e ENVIRONMENT=development \
209+
-e AGENT_NAME="${AGENT_NAME}" \
210+
-e ACP_URL="http://${CONTAINER_NAME}" \
211+
-e ACP_PORT=8000 \
212+
-e ACP_TYPE="${ACP_TYPE}" \
213+
-e AGENTEX_BASE_URL=http://agentex:5003 \
214+
-e AGENTEX_API_BASE_URL=http://agentex:5003 \
215+
-e REDIS_URL=redis://agentex-redis:6379 \
216+
-e TEMPORAL_ADDRESS=agentex-temporal:7233 \
217+
-e TEMPORAL_HOST=agentex-temporal \
218+
-e AGENTEX_SERVER_TASK_QUEUE=agentex-server \
219+
-e WORKFLOW_NAME="${AGENT_NAME}" \
220+
-e WORKFLOW_TASK_QUEUE="${QUEUE_NAME}" \
221+
-e DATABASE_URL=postgresql://postgres:postgres@agentex-postgres:5432/agentex \
222+
-e MONGODB_URI=mongodb://agentex-mongodb:27017 \
223+
-e MONGODB_DATABASE_NAME=agentex \
224+
-e OPENAI_API_KEY="${OPENAI_API_KEY}" \
225+
-p 8000:8000 \
226+
--network agentex-network \
227+
"${AGENT_IMAGE}" \
228+
bash -c "python project/run_worker.py & uvicorn project.acp:acp --host 0.0.0.0 --port 8000"
229+
else
230+
# Non-temporal agent: start ACP server only
231+
docker run -d --name "${CONTAINER_NAME}" \
232+
-e ENVIRONMENT=development \
233+
-e AGENT_NAME="${AGENT_NAME}" \
234+
-e ACP_URL="http://${CONTAINER_NAME}" \
235+
-e ACP_PORT=8000 \
236+
-e ACP_TYPE="${ACP_TYPE}" \
237+
-e AGENTEX_BASE_URL=http://agentex:5003 \
238+
-e AGENTEX_API_BASE_URL=http://agentex:5003 \
239+
-e REDIS_URL=redis://agentex-redis:6379 \
240+
-e OPENAI_API_KEY="${OPENAI_API_KEY}" \
241+
-p 8000:8000 \
242+
--network agentex-network \
243+
"${AGENT_IMAGE}"
244+
fi
245+
246+
# there are some agents that need npx to be installed to be run
247+
echo "📦 Installing Node.js, NPM, and NPX in agent container..."
248+
docker exec "${CONTAINER_NAME}" sh -c "
249+
set -e
250+
echo '🔄 Updating package list...'
251+
apt-get update -qq
252+
253+
echo '🔄 Installing Node.js and NPM...'
254+
apt-get install -y -qq curl
255+
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
256+
apt-get install -y -qq nodejs
257+
258+
echo '✅ Versions after installation:'
259+
node --version
260+
npm --version
261+
262+
" || {
263+
echo "❌ Node.js installation failed, checking container state..."
264+
docker exec "${CONTAINER_NAME}" sh -c "
265+
echo 'Container OS info:'
266+
cat /etc/os-release || echo 'OS info not available'
267+
echo 'Available packages:'
268+
apt list --installed | grep node || echo 'No node packages found'
269+
"
270+
exit 1
271+
}
232272
233273
echo "⏳ Waiting for agent to start..."
234274
sleep 10
235275
236-
# Debug: Check environment variables inside the container
237-
echo "🔍 Checking environment variables in agent container..."
238-
docker exec "${CONTAINER_NAME}" env | grep -E "OPENAI|AGENTEX|REDIS" | head -10 || echo "No relevant env vars found"
239-
240276
# Check for "Application startup complete" log message
241277
echo "🔍 Waiting for 'Application startup complete' log message..."
242278
TIMEOUT=60
@@ -260,100 +296,81 @@ jobs:
260296
exit 1
261297
fi
262298
263-
echo "🔍 Verifying agent registration with AgentEx..."
299+
echo "🔍 Waiting for agent registration with AgentEx..."
264300
REGISTRATION_TIMEOUT=30
265301
REGISTRATION_ELAPSED=0
266302
267303
while [ $REGISTRATION_ELAPSED -lt $REGISTRATION_TIMEOUT ]; do
268-
AGENT_DATA=$(curl -s http://localhost:5003/agents)
269-
if echo "$AGENT_DATA" | grep -q "${AGENT_NAME}"; then
270-
echo "✅ Agent successfully registered with AgentEx"
271-
272-
# Verify the ACP URL doesn't have double port
273-
if echo "$AGENT_DATA" | grep -q ":8000:8000"; then
274-
echo "❌ Double port detected in agent registration!"
275-
echo "📋 Agent data:"
276-
echo "$AGENT_DATA" | jq '.' || echo "$AGENT_DATA"
277-
exit 1
278-
else
279-
echo "✅ ACP URL correctly formatted (no double port)"
280-
fi
304+
if curl -s http://localhost:5003/agents | grep -q "${AGENT_NAME}"; then
305+
echo "✅ Agent registered successfully"
281306
break
282307
fi
283-
echo "⏳ Waiting for agent registration... (${REGISTRATION_ELAPSED}s/${REGISTRATION_TIMEOUT}s)"
308+
echo "⏳ Waiting for registration... (${REGISTRATION_ELAPSED}s/${REGISTRATION_TIMEOUT}s)"
284309
sleep 5
285310
REGISTRATION_ELAPSED=$((REGISTRATION_ELAPSED + 5))
286311
done
287312
288313
if [ $REGISTRATION_ELAPSED -ge $REGISTRATION_TIMEOUT ]; then
289-
echo "❌ Agent registration check timeout - test failed"
290-
echo "📋 Current agents registered:"
291-
curl -s http://localhost:5003/agents || echo "Failed to query agents"
292-
293-
echo "📋 Agent container logs:"
294-
docker logs "${CONTAINER_NAME}"
295-
296-
echo "📋 AgentEx service logs:"
297-
cd agentex && docker compose logs --tail=50 agentex
298-
cd ..
299-
300-
echo "🧹 Cleaning up container..."
301-
docker rm -f "${CONTAINER_NAME}"
302-
314+
echo "❌ Agent registration timeout after ${REGISTRATION_TIMEOUT}s"
303315
exit 1
304316
fi
305317
306-
# Test connectivity before running main tests
307-
echo "🔍 Testing connectivity to agent..."
308-
if ! docker exec "${CONTAINER_NAME}" curl -s http://localhost:8000/health > /dev/null 2>&1; then
309-
echo "⚠️ Agent health endpoint not responding, checking if agent is listening..."
310-
docker exec "${CONTAINER_NAME}" netstat -tlnp 2>/dev/null || echo "netstat not available"
311-
fi
312318
313-
echo "🔍 Testing connectivity to AgentEx from agent container..."
314-
if ! docker exec "${CONTAINER_NAME}" curl -s http://agentex:5003/health > /dev/null 2>&1; then
315-
echo "❌ Cannot reach AgentEx from agent container"
316-
echo "📋 AgentEx service logs:"
317-
cd agentex && docker compose logs --tail=50 agentex
318-
cd ..
319-
else
320-
echo "✅ Agent can reach AgentEx services"
321-
fi
322-
323-
# Show pre-test logs
324-
echo "📋 Agent logs before testing:"
325-
docker logs --tail=20 "${CONTAINER_NAME}"
319+
# Run the test inside the container with retry logic for resilience
320+
echo "🧪 Running tests inside the agent container with retry logic..."
321+
MAX_RETRIES=3
322+
RETRY_COUNT=0
323+
TEST_PASSED=false
326324
327-
echo "📋 AgentEx logs before testing:"
328-
cd agentex && docker compose logs --tail=20 agentex
329-
cd ..
325+
while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$TEST_PASSED" = false ]; do
326+
RETRY_COUNT=$((RETRY_COUNT + 1))
327+
echo "🔄 Test attempt $RETRY_COUNT/$MAX_RETRIES"
330328
331-
# Run the test inside the container with explicit exit code handling
332-
echo "🧪 Running tests inside the agent container..."
333-
set +e # Don't exit on error immediately
334-
docker exec "${CONTAINER_NAME}" pytest tests/test_agent.py -v
335-
TEST_EXIT_CODE=$?
336-
set -e # Re-enable exit on error
329+
set +e # Don't exit on error immediately
330+
docker exec "${CONTAINER_NAME}" pytest tests/test_agent.py -v
331+
TEST_EXIT_CODE=$?
332+
set -e # Re-enable exit on error
337333
338-
echo "🔍 Test exit code: $TEST_EXIT_CODE"
334+
echo "🔍 Test exit code for attempt $RETRY_COUNT: $TEST_EXIT_CODE"
339335
340-
# Show post-test logs regardless of outcome
341-
echo "📋 Agent logs after testing:"
342-
docker logs --tail=50 "${CONTAINER_NAME}"
336+
# Show post-test logs after each attempt
337+
echo "📋 Agent logs after test attempt $RETRY_COUNT:"
338+
docker logs --tail=30 "${CONTAINER_NAME}"
343339
344-
echo "📋 AgentEx logs after testing:"
345-
cd agentex && docker compose logs --tail=50 agentex
346-
cd ..
340+
echo "<details><summary>📋 AgentEx logs after test attempt $RETRY_COUNT (click to expand)</summary>"
341+
echo ""
342+
echo '```'
343+
cd agentex && docker compose logs --tail=30 agentex
344+
cd ..
345+
echo '```'
346+
echo "</details>"
347+
348+
if [ $TEST_EXIT_CODE -eq 0 ]; then
349+
echo "✅ Tests passed successfully on attempt $RETRY_COUNT"
350+
TEST_PASSED=true
351+
else
352+
echo "❌ Test attempt $RETRY_COUNT failed with exit code $TEST_EXIT_CODE"
353+
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
354+
echo "🔄 Will retry in 5 seconds..."
355+
sleep 5
356+
fi
357+
fi
358+
done
347359
348-
if [ $TEST_EXIT_CODE -eq 0 ]; then
349-
echo "✅ Tests passed successfully"
360+
# Final result handling
361+
if [ "$TEST_PASSED" = true ]; then
362+
echo "🎉 Tests passed after $RETRY_COUNT attempts"
350363
else
351-
echo "❌ Tests failed with exit code $TEST_EXIT_CODE"
364+
echo "❌ All $MAX_RETRIES test attempts failed"
352365
echo "📋 Full agent logs:"
353366
docker logs "${CONTAINER_NAME}"
354-
echo "📋 Full AgentEx logs:"
367+
echo "<details><summary>📋 Full AgentEx logs (click to expand)</summary>"
368+
echo ""
369+
echo '```'
355370
cd agentex && docker compose logs agentex
356371
cd ..
372+
echo '```'
373+
echo "</details>"
357374
exit 1
358375
fi
359376

0 commit comments

Comments
 (0)