Update database paths and fix foreign key references across coordinator API
- Change SQLite database path from `/home/oib/windsurf/aitbc/data/` to `/opt/data/` - Fix foreign key references to use correct table names (users, wallets, gpu_registry) - Replace governance router with new governance and community routers - Add multi-modal RL router to main application - Simplify DEPLOYMENT_READINESS_REPORT.md to focus on production deployment status - Update governance router with decentralized DAO voting
This commit is contained in:
39
apps/coordinator-api/tests/test_marketplace_health.py
Normal file
39
apps/coordinator-api/tests/test_marketplace_health.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Integration tests for marketplace health endpoints (skipped unless URLs provided).
|
||||
|
||||
Set env vars to run:
|
||||
MARKETPLACE_HEALTH_URL=http://127.0.0.1:18000/v1/health
|
||||
MARKETPLACE_HEALTH_URL_ALT=http://127.0.0.1:18001/v1/health
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _check_health(url: str) -> None:
|
||||
with urllib.request.urlopen(url, timeout=5) as resp: # nosec: B310 external URL controlled via env
|
||||
assert resp.status == 200
|
||||
data = resp.read().decode("utf-8")
|
||||
try:
|
||||
payload = json.loads(data)
|
||||
except json.JSONDecodeError:
|
||||
pytest.fail(f"Health response not JSON: {data}")
|
||||
assert payload.get("status", "").lower() in {"ok", "healthy", "pass"}
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("MARKETPLACE_HEALTH_URL"),
|
||||
reason="MARKETPLACE_HEALTH_URL not set; integration test skipped",
|
||||
)
|
||||
def test_marketplace_health_primary():
|
||||
_check_health(os.environ["MARKETPLACE_HEALTH_URL"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("MARKETPLACE_HEALTH_URL_ALT"),
|
||||
reason="MARKETPLACE_HEALTH_URL_ALT not set; integration test skipped",
|
||||
)
|
||||
def test_marketplace_health_secondary():
|
||||
_check_health(os.environ["MARKETPLACE_HEALTH_URL_ALT"])
|
||||
38
apps/coordinator-api/tests/test_phase8_optional_endpoints.py
Normal file
38
apps/coordinator-api/tests/test_phase8_optional_endpoints.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Optional integration checks for Phase 8 endpoints (skipped unless URLs are provided).
|
||||
|
||||
Env vars (set any that you want to exercise):
|
||||
EXPLORER_API_URL # e.g., http://127.0.0.1:8000/v1/explorer/blocks/head
|
||||
MARKET_STATS_URL # e.g., http://127.0.0.1:8000/v1/marketplace/stats
|
||||
ECON_STATS_URL # e.g., http://127.0.0.1:8000/v1/economics/summary
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _check_json(url: str) -> None:
|
||||
with urllib.request.urlopen(url, timeout=5) as resp: # nosec: B310 external URL controlled via env
|
||||
assert resp.status == 200
|
||||
data = resp.read().decode("utf-8")
|
||||
try:
|
||||
json.loads(data)
|
||||
except json.JSONDecodeError:
|
||||
pytest.fail(f"Response not JSON from {url}: {data}")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not os.getenv("EXPLORER_API_URL"), reason="EXPLORER_API_URL not set; explorer check skipped")
|
||||
def test_explorer_api_head():
|
||||
_check_json(os.environ["EXPLORER_API_URL"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(not os.getenv("MARKET_STATS_URL"), reason="MARKET_STATS_URL not set; market stats check skipped")
|
||||
def test_market_stats():
|
||||
_check_json(os.environ["MARKET_STATS_URL"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(not os.getenv("ECON_STATS_URL"), reason="ECON_STATS_URL not set; economics stats check skipped")
|
||||
def test_economics_stats():
|
||||
_check_json(os.environ["ECON_STATS_URL"])
|
||||
59
apps/coordinator-api/tests/test_phase8_tasks.py
Normal file
59
apps/coordinator-api/tests/test_phase8_tasks.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""Integration checks mapped to Phase 8 tasks (skipped unless URLs provided).
|
||||
|
||||
Environment variables to enable:
|
||||
MARKETPLACE_HEALTH_URL # e.g., http://127.0.0.1:18000/v1/health (multi-region primary)
|
||||
MARKETPLACE_HEALTH_URL_ALT # e.g., http://127.0.0.1:18001/v1/health (multi-region secondary)
|
||||
BLOCKCHAIN_RPC_URL # e.g., http://127.0.0.1:9080/rpc/head (blockchain integration)
|
||||
COORDINATOR_HEALTH_URL # e.g., http://127.0.0.1:8000/v1/health (agent economics / API health)
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _check_health(url: str, expect_status_field: bool = True) -> None:
|
||||
with urllib.request.urlopen(url, timeout=5) as resp: # nosec: B310 external URL controlled via env
|
||||
assert resp.status == 200
|
||||
data = resp.read().decode("utf-8")
|
||||
if not expect_status_field:
|
||||
return
|
||||
try:
|
||||
payload = json.loads(data)
|
||||
except json.JSONDecodeError:
|
||||
pytest.fail(f"Response not JSON: {data}")
|
||||
assert payload.get("status", "").lower() in {"ok", "healthy", "pass"}
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("MARKETPLACE_HEALTH_URL"),
|
||||
reason="MARKETPLACE_HEALTH_URL not set; multi-region primary health skipped",
|
||||
)
|
||||
def test_multi_region_primary_health():
|
||||
_check_health(os.environ["MARKETPLACE_HEALTH_URL"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("MARKETPLACE_HEALTH_URL_ALT"),
|
||||
reason="MARKETPLACE_HEALTH_URL_ALT not set; multi-region secondary health skipped",
|
||||
)
|
||||
def test_multi_region_secondary_health():
|
||||
_check_health(os.environ["MARKETPLACE_HEALTH_URL_ALT"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("BLOCKCHAIN_RPC_URL"),
|
||||
reason="BLOCKCHAIN_RPC_URL not set; blockchain RPC check skipped",
|
||||
)
|
||||
def test_blockchain_rpc_head():
|
||||
_check_health(os.environ["BLOCKCHAIN_RPC_URL"], expect_status_field=False)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.getenv("COORDINATOR_HEALTH_URL"),
|
||||
reason="COORDINATOR_HEALTH_URL not set; coordinator health skipped",
|
||||
)
|
||||
def test_agent_api_health():
|
||||
_check_health(os.environ["COORDINATOR_HEALTH_URL"])
|
||||
Reference in New Issue
Block a user