From 316dc8e8944928aa4f37c2980ec178fc9379633a Mon Sep 17 00:00:00 2001 From: aitbc Date: Sat, 2 May 2026 13:34:08 +0200 Subject: [PATCH] Update workflows for agent coordinator and app deps --- .gitea/workflows/api-endpoint-tests.yml | 8 +++---- .gitea/workflows/integration-tests.yml | 4 ++-- .gitea/workflows/python-tests.yml | 10 +++++---- .../tests/test_communication.py | 22 +++++++++---------- scripts/ci/test_api_endpoints.py | 4 ++-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.gitea/workflows/api-endpoint-tests.yml b/.gitea/workflows/api-endpoint-tests.yml index 6463e442..6690f335 100644 --- a/.gitea/workflows/api-endpoint-tests.yml +++ b/.gitea/workflows/api-endpoint-tests.yml @@ -4,7 +4,7 @@ on: push: branches: [main, develop] paths: - - 'apps/coordinator-api/**' + - 'apps/agent-coordinator/**' - 'apps/exchange/**' - 'apps/wallet/**' - 'scripts/ci/test_api_endpoints.py' @@ -93,13 +93,13 @@ jobs: service_host="" for candidate in "${host_candidates[@]}"; do - code=$(curl -so /dev/null -w '%{http_code}' "http://$candidate:8000/health" 2>/dev/null) || code=0 + code=$(curl -so /dev/null -w '%{http_code}' "http://$candidate:9001/health" 2>/dev/null) || code=0 if [ "$code" -gt 0 ] && [ "$code" -lt 600 ]; then service_host="$candidate" break fi - code=$(curl -so /dev/null -w '%{http_code}' "http://$candidate:8000/v1/health" 2>/dev/null) || code=0 + code=$(curl -so /dev/null -w '%{http_code}' "http://$candidate:9001/v1/health" 2>/dev/null) || code=0 if [ "$code" -gt 0 ] && [ "$code" -lt 600 ]; then service_host="$candidate" break @@ -116,7 +116,7 @@ jobs: echo "Using service host: $service_host" echo "services_available=true" > /var/lib/aitbc-workspaces/api-tests/status - for port in 8000 8001 8003 8006; do + for port in 9001 8001 8003 8006; do port_ready=0 for i in $(seq 1 15); do code=$(curl -so /dev/null -w '%{http_code}' "http://$service_host:$port/health" 2>/dev/null) || code=0 diff --git a/.gitea/workflows/integration-tests.yml b/.gitea/workflows/integration-tests.yml index 8e3df23e..c98bf3fa 100644 --- a/.gitea/workflows/integration-tests.yml +++ b/.gitea/workflows/integration-tests.yml @@ -87,7 +87,7 @@ jobs: run: | echo "Waiting for services..." services_available=true - for port in 8000 8001 8003 8006 9001; do + for port in 9001 8001 8003 8006; do port_ready=0 for i in $(seq 1 15); do code=$(curl -so /dev/null -w '%{http_code}' "http://localhost:$port/health" 2>/dev/null) || code=0 @@ -142,7 +142,7 @@ jobs: run: | cd /var/lib/aitbc-workspaces/integration-tests/repo source venv/bin/activate - export PYTHONPATH="apps/coordinator-api/src:apps/wallet/src:apps/exchange/src:$PYTHONPATH" + export PYTHONPATH="apps/agent-coordinator/src:apps/wallet/src:apps/exchange/src:$PYTHONPATH" # Skip if services not available if [ "${{ steps.wait-services.outputs.services_available }}" != "true" ]; then diff --git a/.gitea/workflows/python-tests.yml b/.gitea/workflows/python-tests.yml index 32c82393..a139bf9d 100644 --- a/.gitea/workflows/python-tests.yml +++ b/.gitea/workflows/python-tests.yml @@ -52,7 +52,7 @@ jobs: --venv-dir "$PWD/venv" \ --skip-requirements \ --mode copy \ - --extra-packages "pytest pytest-cov pytest-mock pytest-timeout pytest-asyncio locust pydantic-settings fastapi uvicorn sqlmodel>=0.0.38" + --extra-packages "pytest pytest-cov pytest-mock pytest-timeout pytest-asyncio locust pydantic-settings fastapi uvicorn aiohttp>=3.12.14 sqlmodel>=0.0.38" echo "✅ Python environment ready" - name: Run linting @@ -73,7 +73,7 @@ jobs: venv/bin/python -m pip install -e packages/py/aitbc-crypto/ venv/bin/python -m pip install -e packages/py/aitbc-sdk/ - export PYTHONPATH="$PWD/apps/coordinator-api/src:$PWD/apps/blockchain-node/src:$PWD/apps/wallet/src:$PWD/packages/py/aitbc-crypto/src:$PWD/packages/py/aitbc-sdk/src:$PWD:$PYTHONPATH" + export PYTHONPATH="$PWD/apps/agent-coordinator/src:$PWD/apps/blockchain-node/src:$PWD/apps/wallet/src:$PWD/packages/py/aitbc-crypto/src:$PWD/packages/py/aitbc-sdk/src:$PWD:$PYTHONPATH" venv/bin/python -m pytest tests/archived_phase_tests/ \ tests/cross_phase/ \ @@ -85,14 +85,16 @@ jobs: run: | cd /var/lib/aitbc-workspaces/python-tests/repo - export PYTHONPATH="$PWD/apps/coordinator-api/src:$PWD/apps/blockchain-node/src:$PWD/apps/wallet/src:$PWD/packages/py/aitbc-crypto/src:$PWD/packages/py/aitbc-sdk/src:$PWD:$PYTHONPATH" + export PYTHONPATH="$PWD/apps/agent-coordinator:$PWD/apps/agent-coordinator/src:$PWD/packages/py/aitbc-crypto/src:$PWD/packages/py/aitbc-sdk/src:$PWD:$PYTHONPATH" # Test if packages are importable venv/bin/python -c "import aitbc_crypto; print('✅ aitbc_crypto imported')" venv/bin/python -c "import aitbc_sdk; print('✅ aitbc_sdk imported')" + venv/bin/python -c "import src.app; print('✅ agent-coordinator src.app imported')" + venv/bin/python -c "import app; print('✅ agent-coordinator app imported')" venv/bin/python -m pytest \ - apps/coordinator-api/tests/ \ + apps/agent-coordinator/tests/test_communication.py \ packages/py/aitbc-crypto/tests/ \ packages/py/aitbc-sdk/tests/ \ -c /dev/null --rootdir "$PWD" --import-mode=importlib \ diff --git a/apps/agent-coordinator/tests/test_communication.py b/apps/agent-coordinator/tests/test_communication.py index 3ecae5fe..1e9dccda 100644 --- a/apps/agent-coordinator/tests/test_communication.py +++ b/apps/agent-coordinator/tests/test_communication.py @@ -86,13 +86,13 @@ class TestHierarchicalProtocol: def test_add_sub_agent(self, master_protocol): """Test adding sub-agent""" - master_protocol.add_sub_agent("sub-agent-001") + asyncio.run(master_protocol.add_sub_agent("sub-agent-001")) assert "sub-agent-001" in master_protocol.sub_agents def test_send_to_sub_agents(self, master_protocol): """Test sending to sub-agents""" - master_protocol.add_sub_agent("sub-agent-001") - master_protocol.add_sub_agent("sub-agent-002") + asyncio.run(master_protocol.add_sub_agent("sub-agent-001")) + asyncio.run(master_protocol.add_sub_agent("sub-agent-002")) message = MessageTemplates.create_heartbeat("master-agent") @@ -129,19 +129,19 @@ class TestPeerToPeerProtocol: def test_add_peer(self, p2p_protocol): """Test adding peer""" - p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"}) + asyncio.run(p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"})) assert "agent-002" in p2p_protocol.peers assert p2p_protocol.peers["agent-002"]["endpoint"] == "http://localhost:8002" def test_remove_peer(self, p2p_protocol): """Test removing peer""" - p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"}) - p2p_protocol.remove_peer("agent-002") + asyncio.run(p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"})) + asyncio.run(p2p_protocol.remove_peer("agent-002")) assert "agent-002" not in p2p_protocol.peers def test_send_to_peer(self, p2p_protocol): """Test sending to peer""" - p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"}) + asyncio.run(p2p_protocol.add_peer("agent-002", {"endpoint": "http://localhost:8002"})) message = MessageTemplates.create_task_assignment( "agent-001", "agent-002", {"task": "test"} @@ -165,16 +165,16 @@ class TestBroadcastProtocol: def test_subscribe_unsubscribe(self, broadcast_protocol): """Test subscribe and unsubscribe""" - broadcast_protocol.subscribe("agent-002") + asyncio.run(broadcast_protocol.subscribe("agent-002")) assert "agent-002" in broadcast_protocol.subscribers - broadcast_protocol.unsubscribe("agent-002") + asyncio.run(broadcast_protocol.unsubscribe("agent-002")) assert "agent-002" not in broadcast_protocol.subscribers def test_broadcast(self, broadcast_protocol): """Test broadcasting""" - broadcast_protocol.subscribe("agent-002") - broadcast_protocol.subscribe("agent-003") + asyncio.run(broadcast_protocol.subscribe("agent-002")) + asyncio.run(broadcast_protocol.subscribe("agent-003")) message = MessageTemplates.create_discovery("agent-001") diff --git a/scripts/ci/test_api_endpoints.py b/scripts/ci/test_api_endpoints.py index c79fab88..d5f2417e 100755 --- a/scripts/ci/test_api_endpoints.py +++ b/scripts/ci/test_api_endpoints.py @@ -12,7 +12,7 @@ import sys API_HOST = os.environ.get("AITBC_API_HOST", "localhost") SERVICES = { - "coordinator": {"url": f"http://{API_HOST}:8000", "endpoints": ["/", "/health", "/info"]}, + "agent_coordinator": {"url": f"http://{API_HOST}:9001", "endpoints": ["/", "/health"]}, "exchange": {"url": f"http://{API_HOST}:8001", "endpoints": ["/", "/api/health", "/health", "/info"]}, "wallet": {"url": f"http://{API_HOST}:8003", "endpoints": ["/", "/health", "/wallets"]}, "blockchain_rpc": {"url": f"http://{API_HOST}:8006", "endpoints": ["/health", "/rpc/head", "/rpc/head?chain_id=ait-mainnet", "/rpc/head?chain_id=ait-testnet", "/rpc/mempool"]}, @@ -79,7 +79,7 @@ def main(): print("\n⚡ Performance tests...") perf = test_performance([ - ("Coordinator", f"http://{API_HOST}:8000/health"), + ("Agent Coordinator", f"http://{API_HOST}:9001/health"), ("Exchange", f"http://{API_HOST}:8001/api/health"), ("Wallet", f"http://{API_HOST}:8003/health"), ("Blockchain RPC", f"http://{API_HOST}:8006/health"),