Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
optimize e2e tests
Antonio Ojea2642c0126ce0
diff --git a/tests/e2e/container_mesh.bats b/tests/e2e/container_mesh.batsindex 9838c4a0..07a2514e 100644--- a/tests/e2e/container_mesh.bats+++ b/tests/e2e/container_mesh.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_envmkdir -p tests/e2e/logs}diff --git a/tests/e2e/datapath.bats b/tests/e2e/datapath.batsindex a9d6bcff..29effa60 100644--- a/tests/e2e/datapath.bats+++ b/tests/e2e/datapath.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" || ! -x "./bin/mcp-client" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_env}diff --git a/tests/e2e/docs_snippets.bats b/tests/e2e/docs_snippets.batsindex 9936857f..fdb3d233 100644--- a/tests/e2e/docs_snippets.bats+++ b/tests/e2e/docs_snippets.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_env}diff --git a/tests/e2e/find_remote_tools.bats b/tests/e2e/find_remote_tools.batsindex d53fa53d..01387d51 100644--- a/tests/e2e/find_remote_tools.bats+++ b/tests/e2e/find_remote_tools.bats@@ -24,9 +24,6 @@ start_calc_mcp() {}setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fimesh_setup_envbuild_calc_mcp_image}diff --git a/tests/e2e/key_rotation_test.bats b/tests/e2e/key_rotation_test.batsindex 7586443c..8803717d 100644--- a/tests/e2e/key_rotation_test.bats+++ b/tests/e2e/key_rotation_test.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_env}diff --git a/tests/e2e/kind_wi.bats b/tests/e2e/kind_wi.batsindex 6337a4e3..b167c241 100644--- a/tests/e2e/kind_wi.bats+++ b/tests/e2e/kind_wi.bats@@ -1,25 +1,12 @@#!/usr/bin/env batssetup() {- if ! command -v kind >/dev/null 2>&1; then- skip "kind not available"- fi- if ! command -v kubectl >/dev/null 2>&1; then- skip "kubectl not available"- fi- if ! command -v jq >/dev/null 2>&1; then- skip "jq not available"- fi-# We use a unique cluster name to avoid conflictsCLUSTER_NAME="sam-wi-test-$RANDOM"# Create Kind clusterkind create cluster --name "${CLUSTER_NAME}"- # Build images- make docker-build-# Load images into Kindkind load docker-image sam-hub:local --name "${CLUSTER_NAME}"kind load docker-image sam-node:local --name "${CLUSTER_NAME}"diff --git a/tests/e2e/lib/container_mesh.bash b/tests/e2e/lib/container_mesh.bashindex b796a2c9..7fc84afe 100644--- a/tests/e2e/lib/container_mesh.bash+++ b/tests/e2e/lib/container_mesh.bash@@ -47,6 +47,9 @@ if [[ -z "${MESH_HELPERS_LOADED:-}" ]]; then}mesh_setup_env() {+ if [[ -n "${MESH_NETWORK:-}" ]]; then+ return 0+ fimesh_cleanup_stale_resourcesmesh_build_runtime_image@@ -72,19 +75,21 @@ if [[ -z "${MESH_HELPERS_LOADED:-}" ]]; thenfi}- mesh_cleanup_env() {+ mesh_cleanup_test_resources() {local cfor c in "${MESH_CONTAINERS[@]}"; dodocker rm -f "${c}" >/dev/null 2>&1 || truedone- if [[ -n "${MESH_NETWORK}" ]]; then- docker network rm "${MESH_NETWORK}" >/dev/null 2>&1 || true- fi- if [[ -n "${MESH_SOCKET_DIR}" ]]; then- rm -rf "${MESH_SOCKET_DIR}"- fiMESH_CONTAINERS=()- MESH_NETWORK=""+ }++ mesh_cleanup_env() {+ mesh_cleanup_test_resources+ # We leave the network and socket dir alive for the suite+ }++ mesh_cleanup_suite() {+ mesh_cleanup_stale_resources}mesh_gen_hex32() {@@ -187,6 +192,9 @@ if [[ -z "${MESH_HELPERS_LOADED:-}" ]]; thenmesh_start_mock_oidc() {local name="${MESH_PREFIX}-oidc"+ if docker inspect -f '{{.State.Running}}' "${name}" 2>/dev/null | grep -q "true"; then+ return 0+ fidocker run -d \--name "${name}" \--network "${MESH_NETWORK}" \@@ -199,6 +207,9 @@ if [[ -z "${MESH_HELPERS_LOADED:-}" ]]; thenmesh_start_hub() {local name="${MESH_PREFIX}-hub"+ if docker inspect -f '{{.State.Running}}' "${name}" 2>/dev/null | grep -q "true"; then+ return 0+ filocal keykey="$(mesh_gen_hex32)"diff --git a/tests/e2e/policy.bats b/tests/e2e/policy.batsindex e95bd339..af9ba09e 100644--- a/tests/e2e/policy.bats+++ b/tests/e2e/policy.bats@@ -135,14 +135,6 @@ mesh_call_remote_tool() {}setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_envmkdir -p tests/e2e/logsdiff --git a/tests/e2e/python_sdk_test.bats b/tests/e2e/python_sdk_test.batsindex 1f3d4bf6..63637099 100644--- a/tests/e2e/python_sdk_test.bats+++ b/tests/e2e/python_sdk_test.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_env}diff --git a/tests/e2e/relay.bats b/tests/e2e/relay.batsindex e9b71502..228b082f 100644--- a/tests/e2e/relay.bats+++ b/tests/e2e/relay.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_envmkdir -p tests/e2e/logs}diff --git a/tests/e2e/revocation_test.bats b/tests/e2e/revocation_test.batsindex 76bd1ee6..d32ac40b 100644--- a/tests/e2e/revocation_test.bats+++ b/tests/e2e/revocation_test.bats@@ -3,14 +3,6 @@load "lib/container_mesh.bash"setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_env}diff --git a/tests/e2e/sam.bats b/tests/e2e/sam.batsindex f519b49c..5b636d4e 100644--- a/tests/e2e/sam.bats+++ b/tests/e2e/sam.bats@@ -4,14 +4,6 @@ setup() {export SAM_NODE_BINARY="${SAM_NODE_BINARY:-./bin/sam-node}"export SAM_HUB_BINARY="${SAM_HUB_BINARY:-./bin/sam-hub}"- make- if [[ ! -x "$SAM_NODE_BINARY" ]]; then- skip "sam-node binary not found at $SAM_NODE_BINARY"- fi- if [[ ! -x "$SAM_HUB_BINARY" ]]; then- skip "sam-hub binary not found at $SAM_HUB_BINARY"- fi-export TEST_TMPDIRTEST_TMPDIR="$(mktemp -d)"export HOME="$TEST_TMPDIR/home"diff --git a/tests/e2e/services.bats b/tests/e2e/services.batsindex 27a501f4..8a29102e 100644--- a/tests/e2e/services.bats+++ b/tests/e2e/services.bats@@ -23,14 +23,6 @@ start_calc_mcp() {}setup() {- if ! mesh_require_docker; then- skip "docker not available or daemon not running"- fi-- if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" || ! -x "./bin/mcp-client" ]]; then- skip "missing binaries; run: make build"- fi-mesh_setup_envbuild_calc_mcp_image}diff --git a/tests/e2e/setup_suite.bash b/tests/e2e/setup_suite.bashindex bebdfb73..58301f96 100644--- a/tests/e2e/setup_suite.bash+++ b/tests/e2e/setup_suite.bash@@ -5,12 +5,47 @@ set -eufunction setup_suite {export BATS_TEST_TIMEOUT=150+ if ! command -v docker >/dev/null 2>&1 || ! docker info >/dev/null 2>&1; then+ echo "docker not available or daemon not running" >&2+ exit 1+ fi+ if ! command -v kind >/dev/null 2>&1; then+ echo "kind not available" >&2+ exit 1+ fi+ if ! command -v kubectl >/dev/null 2>&1; then+ echo "kubectl not available" >&2+ exit 1+ fi+ if ! command -v jq >/dev/null 2>&1; then+ echo "jq not available" >&2+ exit 1+ fi+# tests/e2ecd "$BATS_TEST_DIRNAME"/../..makemake docker-build++ if [[ ! -x "./bin/sam-node" || ! -x "./bin/sam-hub" || ! -x "./bin/mcp-client" ]]; then+ echo "missing binaries; run: make build" >&2+ exit 1+ fi++ export BATS_TEST_NUMBER=0+ source tests/e2e/lib/container_mesh.bash+ mesh_setup_env+ export MESH_PREFIX+ export MESH_NETWORK++ # Ensure the mock oidc and hub are running for all tests+ mesh_start_mock_oidc+ mesh_start_hub}function teardown_suite {+ cd "$BATS_TEST_DIRNAME"/../..+ source tests/e2e/lib/container_mesh.bash+ mesh_cleanup_suiteecho "teardown suite"}\ No newline at end of file