mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
78 lines
1.7 KiB
Go
78 lines
1.7 KiB
Go
package process
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func occupyPort(t *testing.T) (net.Listener, int) {
|
|
t.Helper()
|
|
|
|
ln, err := net.Listen("tcp", ":0")
|
|
require.NoError(t, err)
|
|
|
|
_, portStr, err := net.SplitHostPort(ln.Addr().String())
|
|
require.NoError(t, err)
|
|
|
|
port, err := strconv.Atoi(portStr)
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, ln.Close())
|
|
|
|
ln, err = net.Listen("tcp", fmt.Sprintf(":%d", port))
|
|
require.NoError(t, err)
|
|
|
|
return ln, port
|
|
}
|
|
|
|
func TestDefaultPortManager_FindFreePortSkipsBusyAndReserved(t *testing.T) {
|
|
pm := NewPortManager()
|
|
|
|
ln, busyPort := occupyPort(t)
|
|
defer ln.Close()
|
|
|
|
freePort, err := pm.FindFreePort(busyPort)
|
|
require.NoError(t, err)
|
|
assert.NotEqual(t, busyPort, freePort)
|
|
|
|
require.NoError(t, pm.ReservePort(freePort))
|
|
t.Cleanup(func() { _ = pm.ReleasePort(freePort) })
|
|
|
|
nextPort, err := pm.FindFreePort(freePort)
|
|
require.NoError(t, err)
|
|
assert.NotEqual(t, freePort, nextPort, "reserved ports should be skipped")
|
|
}
|
|
|
|
func TestDefaultPortManager_ReserveAndReleaseLifecycle(t *testing.T) {
|
|
pm := NewPortManager()
|
|
|
|
freePort, err := pm.FindFreePort(35000)
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, pm.ReservePort(freePort))
|
|
|
|
err = pm.ReservePort(freePort)
|
|
require.Error(t, err, "double reservation should fail")
|
|
|
|
require.NoError(t, pm.ReleasePort(freePort))
|
|
|
|
err = pm.ReleasePort(freePort)
|
|
require.Error(t, err, "releasing an unreserved port should fail")
|
|
}
|
|
|
|
func TestDefaultPortManager_ReserveFailsWhenSystemPortBusy(t *testing.T) {
|
|
pm := NewPortManager()
|
|
|
|
ln, busyPort := occupyPort(t)
|
|
defer ln.Close()
|
|
|
|
err := pm.ReservePort(busyPort)
|
|
require.Error(t, err)
|
|
assert.Contains(t, err.Error(), "not available")
|
|
}
|