Skip to content

Agent Mesh

remove python e2e by bats

Antonio Ojeaacb2f1dea657
diff --git a/Makefile b/Makefile
index aed0fd13..a56d3c17 100644
--- a/Makefile
+++ b/Makefile
@@ -26,10 +26,8 @@ test-python:
./sam-mcp-python/.venv/bin/pip install -e ./sam-mcp-python[test]
./sam-mcp-python/.venv/bin/pytest sam-mcp-python/tests/unit
-test-python-e2e: build
- python3 -m venv sam-mcp-python/.venv
- ./sam-mcp-python/.venv/bin/pip install -e ./sam-mcp-python[test]
- ./sam-mcp-python/.venv/bin/pytest sam-mcp-python/tests/e2e
+test-python-e2e: build docker-build
+ bats --verbose-run tests/e2e/python_sdk_test.bats
e2e-test:
bats --verbose-run tests/e2e/
diff --git a/sam-mcp-python/tests/e2e/test_e2e.py b/sam-mcp-python/tests/e2e/test_e2e.py
deleted file mode 100644
index 65bac71e..00000000
--- a/sam-mcp-python/tests/e2e/test_e2e.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import asyncio
-import os
-import subprocess
-import time
-import pytest
-from sam_mcp.client import SamClient
-
[email protected](scope="session")
-def sam_node_binary():
- """Ensures the sam-node binary is built."""
- repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../"))
- bin_path = os.path.join(repo_root, "bin", "sam-node")
-
- if not os.path.exists(bin_path):
- print(f"Binary not found at {bin_path}, building...")
- subprocess.run(["make", "build"], cwd=repo_root, check=True)
-
- return bin_path
-
[email protected](scope="function")
-def sam_node(sam_node_binary, tmp_path):
- """Spins up a sam-node instance for testing."""
- log_file_path = tmp_path / "node.log"
- log_file = open(log_file_path, "w")
-
- # Run sam-node with a dummy JWT and custom TCP address (let it choose free port).
- process = subprocess.Popen(
- [sam_node_binary, "run", "--mcp-addr", "127.0.0.1:0", "--jwt", "dummy-token", "--hub", "127.0.0.1:8080"],
- stdout=log_file,
- stderr=log_file,
- )
-
- # Wait for the log file to contain the bound address
- mcp_addr = None
- for _ in range(20):
- if os.path.exists(log_file_path):
- with open(log_file_path, "r") as f:
- content = f.read()
- if "Starting MCP server on TCP address " in content:
- parts = content.split("Starting MCP server on TCP address ")
- if len(parts) > 1:
- mcp_addr = parts[1].split("\n")[0].strip()
- break
- time.sleep(0.5)
-
- if not mcp_addr:
- process.kill()
- log_file.close()
- with open(log_file_path, "r") as f:
- log_content = f.read()
- pytest.fail(f"sam-node failed to print bound address. Log content: {log_content}")
-
- yield mcp_addr
-
- process.terminate()
- try:
- process.wait(timeout=5)
- except subprocess.TimeoutExpired:
- process.kill()
- log_file.close()
-
-async def test_e2e_get_tools(sam_node):
- """Verifies that we can connect to the real node and get tools."""
- os.environ["SAM_MCP_URL"] = f"http://{sam_node}/"
-
- async with SamClient() as client:
- tools = await client.get_tools()
- assert isinstance(tools, list)
- print(f"Received tools: {tools}")
-
-async def test_e2e_call_echo_tool(sam_node):
- """Verifies that we can call a tool on the real node."""
- os.environ["SAM_MCP_URL"] = f"http://{sam_node}/"
-
- async with SamClient() as client:
- try:
- result = await client.call_tool("get_mesh_info", {})
- print(f"Tool result: {result}")
- assert "hub_peer_id" in str(result).lower() or "peers" in str(result).lower()
- except Exception as e:
- print(f"Tool call failed: {e}")
- # If it's a method not found, that's also a valid interaction verifying the pipeline
- if "Method not found" in str(e) or "error" in str(e).lower():
- pass
- else:
- raise e