mirror of
https://github.com/hanzoai/agent.git
synced 2026-09-11 21:08:51 +00:00
The reasoner-admin gRPC service, its middleware, and the generated *_grpc.pb.go now require -tags grpc to compile. Default builds use only the ZAP-native admin path. The adminpb stub keeps `UnimplementedAdminReasonerServiceServer` available as a zero-field struct so embedders compile. Generated file regen via protoc will erase the build constraint — inline comment in reasoner_admin_grpc.pb.go flags this for the next person who runs the codegen.
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
//go:build grpc
|
|
|
|
package server
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/hanzoai/agents/control-plane/internal/storage"
|
|
"github.com/hanzoai/agents/control-plane/pkg/adminpb"
|
|
"github.com/hanzoai/agents/control-plane/pkg/types"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestListReasonersAggregatesNodes(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx := context.Background()
|
|
tempDir := t.TempDir()
|
|
cfg := storage.StorageConfig{
|
|
Mode: "local",
|
|
Local: storage.LocalStorageConfig{
|
|
DatabasePath: filepath.Join(tempDir, "hanzo-agents.db"),
|
|
KVStorePath: filepath.Join(tempDir, "hanzo-agents.bolt"),
|
|
},
|
|
}
|
|
|
|
localStore := storage.NewLocalStorage(storage.LocalStorageConfig{})
|
|
if err := localStore.Initialize(ctx, cfg); err != nil {
|
|
if strings.Contains(strings.ToLower(err.Error()), "fts5") {
|
|
t.Skip("sqlite3 compiled without FTS5; skipping reasoner aggregation test")
|
|
}
|
|
require.NoError(t, err)
|
|
}
|
|
t.Cleanup(func() { _ = localStore.Close(ctx) })
|
|
|
|
srv := &HanzoAgentsServer{storage: localStore}
|
|
|
|
schema := json.RawMessage("{}")
|
|
node := &types.AgentNode{
|
|
ID: "node-1",
|
|
HealthStatus: types.HealthStatusActive,
|
|
Version: "1.0.0",
|
|
LastHeartbeat: time.Now().UTC(),
|
|
Reasoners: []types.ReasonerDefinition{
|
|
{ID: "reason", InputSchema: schema, OutputSchema: schema},
|
|
{ID: "another", InputSchema: schema, OutputSchema: schema},
|
|
},
|
|
}
|
|
require.NoError(t, localStore.RegisterAgent(ctx, node))
|
|
|
|
resp, err := srv.ListReasoners(ctx, &adminpb.ListReasonersRequest{})
|
|
require.NoError(t, err)
|
|
require.Len(t, resp.Reasoners, 2)
|
|
require.Equal(t, "node-1.reason", resp.Reasoners[0].ReasonerId)
|
|
require.Equal(t, "node-1", resp.Reasoners[0].AgentNodeId)
|
|
require.NotEmpty(t, resp.Reasoners[0].LastHeartbeat)
|
|
}
|