Documentation
¶
Index ¶
- Constants
- func CreateTempConfigFile(t *testing.T, config *configv1.UpstreamServiceConfig) string
- func CreateTempNatsConfigFile(t *testing.T) string
- func FindFreePort(t *testing.T) int
- func GetProjectRoot() (string, error)
- func IsDockerSocketAccessible() bool
- func ProjectRoot(t *testing.T) string
- func RegisterGRPCService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterHTTPService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterHTTPServiceWithJSONRPC(t *testing.T, ...)
- func RegisterHTTPServiceWithParams(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterOpenAPIService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterServiceViaAPI(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterStdioMCPService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterStdioService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterStdioServiceWithSetup(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterStreamableMCPService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterWebrtcService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func RegisterWebsocketService(t *testing.T, regClient apiv1.RegistrationServiceClient, ...)
- func StartDockerContainer(t *testing.T, imageName, containerName string, runArgs []string, ...) (cleanupFunc func())
- func StartNatsServer(t *testing.T) (string, func())
- func StartRedisContainer(t *testing.T) (redisAddr string, cleanupFunc func())
- func WaitForGRPCReady(t *testing.T, grpcAddress string, timeout time.Duration)
- func WaitForHTTPHealth(t *testing.T, url string, timeout time.Duration)
- func WaitForPortFromLogs(t *testing.T, mp *ManagedProcess, serverName string) (string, error)
- func WaitForTCPPort(t *testing.T, port int, timeout time.Duration)
- func WaitForWebsocketReady(t *testing.T, url string, timeout time.Duration)
- type MCPANYTestServerInfo
- func StartInProcessMCPANYServer(t *testing.T, _ string) *MCPANYTestServerInfo
- func StartMCPANYServer(t *testing.T, testName string, extraArgs ...string) *MCPANYTestServerInfo
- func StartMCPANYServerWithClock(t *testing.T, testName string, healthCheck bool, extraArgs ...string) *MCPANYTestServerInfo
- func StartMCPANYServerWithConfig(t *testing.T, testName, configContent string) *MCPANYTestServerInfo
- func StartMCPANYServerWithNoHealthCheck(t *testing.T, testName string, extraArgs ...string) *MCPANYTestServerInfo
- type MCPJSONRPCError
- type ManagedProcess
- type WebsocketEchoServerInfo
Constants ¶
const ( // McpAnyServerStartupTimeout is the timeout for the server to start. McpAnyServerStartupTimeout = 60 * time.Second // ServiceStartupTimeout is the timeout for services to start up. ServiceStartupTimeout = 60 * time.Second // TestWaitTimeShort is a short wait time for tests. TestWaitTimeShort = 120 * time.Second // TestWaitTimeMedium is the default timeout for medium duration tests. TestWaitTimeMedium = 240 * time.Second // TestWaitTimeLong is the default timeout for long duration tests. TestWaitTimeLong = 5 * time.Minute // RetryInterval is the interval between retries. RetryInterval = 250 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func CreateTempConfigFile ¶
func CreateTempConfigFile(t *testing.T, config *configv1.UpstreamServiceConfig) string
CreateTempConfigFile creates a temporary configuration file for the configured upstream service.
func CreateTempNatsConfigFile ¶
CreateTempNatsConfigFile creates a temporary configuration file for NATS.
func FindFreePort ¶
FindFreePort finds a free TCP port on localhost.
func GetProjectRoot ¶
GetProjectRoot returns the absolute path to the project root.
func IsDockerSocketAccessible ¶
func IsDockerSocketAccessible() bool
IsDockerSocketAccessible checks if the Docker daemon is accessible.
func ProjectRoot ¶
ProjectRoot returns the absolute path to the project root.
func RegisterGRPCService ¶
func RegisterGRPCService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, grpcTargetAddress string, authConfig *configv1.UpstreamAuthentication)
RegisterGRPCService registers a gRPC service.
func RegisterHTTPService ¶
func RegisterHTTPService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, baseURL, operationID, endpointPath, httpMethod string, authConfig *configv1.UpstreamAuthentication)
RegisterHTTPService registers a simple HTTP service.
func RegisterHTTPServiceWithJSONRPC ¶
func RegisterHTTPServiceWithJSONRPC(t *testing.T, mcpanyEndpoint, serviceID, baseURL, operationID, endpointPath, httpMethod string, authConfig *configv1.UpstreamAuthentication)
RegisterHTTPServiceWithJSONRPC registers an HTTP service using the JSON-RPC endpoint.
func RegisterHTTPServiceWithParams ¶
func RegisterHTTPServiceWithParams(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, baseURL string, toolDef *configv1.ToolDefinition, endpointPath, httpMethod string, params []*configv1.HttpParameterMapping, authConfig *configv1.UpstreamAuthentication)
RegisterHTTPServiceWithParams registers an HTTP service with parameters.
func RegisterOpenAPIService ¶
func RegisterOpenAPIService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, openAPISpecPath, serverURLOverride string, authConfig *configv1.UpstreamAuthentication)
RegisterOpenAPIService registers an OpenAPI service.
func RegisterServiceViaAPI ¶
func RegisterServiceViaAPI(t *testing.T, regClient apiv1.RegistrationServiceClient, req *apiv1.RegisterServiceRequest)
RegisterServiceViaAPI registers a service using the gRPC API.
func RegisterStdioMCPService ¶
func RegisterStdioMCPService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, command string, toolAutoDiscovery bool)
RegisterStdioMCPService registers an MCP service using stdio.
func RegisterStdioService ¶
func RegisterStdioService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, commandName string, toolAutoDiscovery bool, commandArgs ...string)
RegisterStdioService registers a raw stdio service.
func RegisterStdioServiceWithSetup ¶
func RegisterStdioServiceWithSetup(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, commandName string, toolAutoDiscovery bool, workingDir, containerImage string, setupCommands []string, env map[string]string, commandArgs ...string)
RegisterStdioServiceWithSetup registers a stdio service with setup steps.
func RegisterStreamableMCPService ¶
func RegisterStreamableMCPService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, targetURL string, toolAutoDiscovery bool, authConfig *configv1.UpstreamAuthentication)
RegisterStreamableMCPService registers a streamable MCP service (SSE).
func RegisterWebrtcService ¶
func RegisterWebrtcService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, baseURL, operationID string, authConfig *configv1.UpstreamAuthentication)
RegisterWebrtcService registers a WebRTC service.
func RegisterWebsocketService ¶
func RegisterWebsocketService(t *testing.T, regClient apiv1.RegistrationServiceClient, serviceID, baseURL, operationID string, authConfig *configv1.UpstreamAuthentication)
RegisterWebsocketService registers a WebSocket service.
func StartDockerContainer ¶
func StartDockerContainer(t *testing.T, imageName, containerName string, runArgs []string, command ...string) (cleanupFunc func())
StartDockerContainer starts a docker container with the given image and args.
func StartNatsServer ¶
StartNatsServer starts a NATS server for testing.
func StartRedisContainer ¶
StartRedisContainer starts a Redis container for testing.
func WaitForGRPCReady ¶
WaitForGRPCReady waits for a gRPC server to become ready by attempting to connect.
func WaitForHTTPHealth ¶
WaitForHTTPHealth waits for an HTTP endpoint to return a 200 OK status.
func WaitForPortFromLogs ¶
WaitForPortFromLogs waits for a log line indicating the server is listening and extracts the address.
func WaitForTCPPort ¶
WaitForTCPPort waits for a TCP port to become open and accepting connections.
Types ¶
type MCPANYTestServerInfo ¶
type MCPANYTestServerInfo struct {
Process *ManagedProcess
JSONRPCEndpoint string
HTTPEndpoint string
GrpcRegistrationEndpoint string
NatsURL string
SessionID string
HTTPClient *http.Client
GRPCRegConn *grpc.ClientConn
RegistrationClient apiv1.RegistrationServiceClient
CleanupFunc func()
T *testing.T
}
MCPANYTestServerInfo contains information about a running MCPANY test server. --- MCPANY Server Helper (External Process) --- MCPANYTestServerInfo contains information about a running MCP Any server instance for testing.
func StartInProcessMCPANYServer ¶
func StartInProcessMCPANYServer(t *testing.T, _ string) *MCPANYTestServerInfo
StartInProcessMCPANYServer starts an in-process MCP Any server for testing.
func StartMCPANYServer ¶
func StartMCPANYServer(t *testing.T, testName string, extraArgs ...string) *MCPANYTestServerInfo
StartMCPANYServer starts the MCP Any server with default settings.
func StartMCPANYServerWithClock ¶
func StartMCPANYServerWithClock(t *testing.T, testName string, healthCheck bool, extraArgs ...string) *MCPANYTestServerInfo
StartMCPANYServerWithClock starts the MCP Any server, optionally waiting for health.
func StartMCPANYServerWithConfig ¶
func StartMCPANYServerWithConfig(t *testing.T, testName, configContent string) *MCPANYTestServerInfo
StartMCPANYServerWithConfig starts the MCP Any server with a provided config content.
func StartMCPANYServerWithNoHealthCheck ¶
func StartMCPANYServerWithNoHealthCheck(t *testing.T, testName string, extraArgs ...string) *MCPANYTestServerInfo
StartMCPANYServerWithNoHealthCheck starts the MCP Any server but skips the health check.
func (*MCPANYTestServerInfo) CallTool ¶
func (s *MCPANYTestServerInfo) CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
CallTool calls tools/call via JSON-RPC.
func (*MCPANYTestServerInfo) ListTools ¶
func (s *MCPANYTestServerInfo) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)
ListTools calls tools/list via JSON-RPC.
type MCPJSONRPCError ¶
type MCPJSONRPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
MCPJSONRPCError represents a JSON-RPC error.
func (*MCPJSONRPCError) Error ¶
func (e *MCPJSONRPCError) Error() string
type ManagedProcess ¶
type ManagedProcess struct {
IgnoreExitStatusOne bool
Port int
Dir string
// contains filtered or unexported fields
}
ManagedProcess represents an external process managed by the test framework. --- Process Management for External Services --- ManagedProcess manages an external process for testing.
func NewManagedProcess ¶
func NewManagedProcess(t *testing.T, label, command string, args []string, env []string) *ManagedProcess
NewManagedProcess creates a new ManagedProcess instance.
func (*ManagedProcess) Cmd ¶
func (mp *ManagedProcess) Cmd() *exec.Cmd
Cmd returns the underlying exec.Cmd.
func (*ManagedProcess) StderrString ¶
func (mp *ManagedProcess) StderrString() string
StderrString returns the captured stderr as a string.
func (*ManagedProcess) StdoutString ¶
func (mp *ManagedProcess) StdoutString() string
StdoutString returns the captured stdout as a string.
func (*ManagedProcess) Stop ¶
func (mp *ManagedProcess) Stop()
Stop stops the process, attempting graceful shutdown then force kill.
func (*ManagedProcess) WaitForText ¶
WaitForText waits for specific text to appear in the process's stdout.
type WebsocketEchoServerInfo ¶
type WebsocketEchoServerInfo struct {
URL string
CleanupFunc func()
}
WebsocketEchoServerInfo contains information about a running Websocket echo server. --- Websocket Echo Server Helper --- WebsocketEchoServerInfo contains information about a running mock WebSocket echo server.
func StartWebsocketEchoServer ¶
func StartWebsocketEchoServer(t *testing.T) *WebsocketEchoServerInfo
StartWebsocketEchoServer starts a mock WebSocket echo server.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
command-tester
command
Package main is a helper command for integration tests.
|
Package main is a helper command for integration tests. |
|
mocks/grpc_authed_weather_server
command
Package main implements a mock gRPC authenticated weather server for testing.
|
Package main implements a mock gRPC authenticated weather server for testing. |
|
mocks/grpc_weather_server
command
Package main implements a mock gRPC weather server.
|
Package main implements a mock gRPC weather server. |
|
mocks/http_authed_echo_server
command
Package main implements a mock HTTP authenticated echo server for testing.
|
Package main implements a mock HTTP authenticated echo server for testing. |
|
mocks/http_caching_server
command
Package main provides a mock HTTP caching server for integration testing.
|
Package main provides a mock HTTP caching server for integration testing. |
|
mocks/http_echo_server
command
Package main provides a mock HTTP echo server for integration testing.
|
Package main provides a mock HTTP echo server for integration testing. |
|
mocks/openapi_weather_server
command
Package main implements a mock OpenWeatherMap server.
|
Package main implements a mock OpenWeatherMap server. |
|
mocks/prompt-server
command
Package main implements a mock prompt server for integration tests.
|
Package main implements a mock prompt server for integration tests. |
|
mocks/webrtc_weather_server
command
Package main implements a mock WebRTC weather server for testing.
|
Package main implements a mock WebRTC weather server for testing. |
|
mocks/websocket_echo_server
command
Package main provides a mock WebSocket echo server for integration tests.
|
Package main provides a mock WebSocket echo server for integration tests. |