Documentation
¶
Overview ¶
Package framework provides testing framework utilities.
Index ¶
- Constants
- Variables
- func BuildCachingServer(t *testing.T) *integration.ManagedProcess
- func BuildEverythingServer(t *testing.T) *integration.ManagedProcess
- func BuildGRPCAuthedWeatherServer(t *testing.T) *integration.ManagedProcess
- func BuildGRPCWeatherServer(t *testing.T) *integration.ManagedProcess
- func BuildHTTPAuthedEchoServer(t *testing.T) *integration.ManagedProcess
- func BuildHTTPEchoServer(t *testing.T) *integration.ManagedProcess
- func BuildOpenAPIAuthedServer(t *testing.T) *integration.ManagedProcess
- func BuildOpenAPIWeatherServer(t *testing.T) *integration.ManagedProcess
- func BuildStdioDockerServer(_ *testing.T) *integration.ManagedProcess
- func BuildStdioServer(_ *testing.T) *integration.ManagedProcess
- func BuildStreamableHTTPServer(t *testing.T) *integration.ManagedProcess
- func BuildWebrtcWeatherServer(t *testing.T) *integration.ManagedProcess
- func BuildWebsocketWeatherServer(t *testing.T) *integration.ManagedProcess
- func NoOpMiddleware(_ *testing.T, next http.Handler) http.Handler
- func RegisterCachingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterEverythingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterGRPCAuthedWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterGRPCWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterHTTPAuthedEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterHTTPEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterOpenAPIAuthedService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterOpenAPIWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterStdioDockerService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)
- func RegisterStdioService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)
- func RegisterStreamableHTTPService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterWebrtcWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RegisterWebsocketWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, ...)
- func RunE2ETest(t *testing.T, testCase *E2ETestCase)
- func TestE2ECaching(t *testing.T)
- func ValidateCaching(t *testing.T, mcpanyEndpoint, upstreamEndpoint string)
- func ValidateRegisteredTool(t *testing.T, mcpanyEndpoint string, expectedTool *mcp.Tool)
- func VerifyMCPClient(t *testing.T, mcpanyEndpoint string)
- func WaitForPort(t *testing.T, proc *integration.ManagedProcess) int
- type AITool
- type ClaudeCLI
- type CopilotCLI
- type E2ETestCase
- type GeminiCLI
- type MCPConfig
- type MCPServerConfig
- type RegistrationMethod
Constants ¶
const DefaultClaudeModel = "claude-3-5-sonnet-latest"
DefaultClaudeModel is the default Claude model to use.
const DefaultModel = "gemini-2.5-flash"
DefaultModel is the default Gemini model to use.
Variables ¶
var ( FindFreePort = integration.FindFreePort NewManagedProcess = integration.NewManagedProcess WaitForTCPPort = integration.WaitForTCPPort GetProjectRoot = integration.GetProjectRoot ServiceStartupTimeout = 15 * time.Second )
Re-exporting these from the integration package so that framework users don't need to import both.
Functions ¶
func BuildCachingServer ¶
func BuildCachingServer(t *testing.T) *integration.ManagedProcess
BuildCachingServer builds and starts a caching server for testing.
t is the t.
Returns the result.
func BuildEverythingServer ¶
func BuildEverythingServer(t *testing.T) *integration.ManagedProcess
BuildEverythingServer builds a server with everything.
t is the t.
Returns the result.
func BuildGRPCAuthedWeatherServer ¶
func BuildGRPCAuthedWeatherServer(t *testing.T) *integration.ManagedProcess
BuildGRPCAuthedWeatherServer builds the authenticated gRPC weather server.
t is the t.
Returns the result.
func BuildGRPCWeatherServer ¶
func BuildGRPCWeatherServer(t *testing.T) *integration.ManagedProcess
BuildGRPCWeatherServer builds the gRPC weather server.
t is the t.
Returns the result.
func BuildHTTPAuthedEchoServer ¶
func BuildHTTPAuthedEchoServer(t *testing.T) *integration.ManagedProcess
BuildHTTPAuthedEchoServer builds the HTTP authed echo server for testing.
t is the t.
Returns the result.
func BuildHTTPEchoServer ¶
func BuildHTTPEchoServer(t *testing.T) *integration.ManagedProcess
BuildHTTPEchoServer builds and starts an HTTP echo server for testing.
t is the t.
Returns the result.
func BuildOpenAPIAuthedServer ¶
func BuildOpenAPIAuthedServer(t *testing.T) *integration.ManagedProcess
BuildOpenAPIAuthedServer builds the openapi authenticated server.
t is the t.
Returns the result.
func BuildOpenAPIWeatherServer ¶
func BuildOpenAPIWeatherServer(t *testing.T) *integration.ManagedProcess
BuildOpenAPIWeatherServer builds the openapi weather server.
t is the t.
Returns the result.
func BuildStdioDockerServer ¶
func BuildStdioDockerServer(_ *testing.T) *integration.ManagedProcess
BuildStdioDockerServer builds the stdio docker server (nop).
_ is an unused parameter.
Returns the result.
func BuildStdioServer ¶
func BuildStdioServer(_ *testing.T) *integration.ManagedProcess
BuildStdioServer builds the stdio server (nop).
_ is an unused parameter.
Returns the result.
func BuildStreamableHTTPServer ¶
func BuildStreamableHTTPServer(t *testing.T) *integration.ManagedProcess
BuildStreamableHTTPServer builds the streamable http server.
t is the t.
Returns the result.
func BuildWebrtcWeatherServer ¶
func BuildWebrtcWeatherServer(t *testing.T) *integration.ManagedProcess
BuildWebrtcWeatherServer builds the webrtc weather server.
t is the t.
Returns the result.
func BuildWebsocketWeatherServer ¶
func BuildWebsocketWeatherServer(t *testing.T) *integration.ManagedProcess
BuildWebsocketWeatherServer builds the websocket weather server.
t is the t.
Returns the result.
func NoOpMiddleware ¶
NoOpMiddleware is a middleware that does nothing and calls the next handler.
_ is an unused parameter. next is the next.
Returns the result.
func RegisterCachingService ¶
func RegisterCachingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterCachingService registers the caching service with the MCP server.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterEverythingService ¶
func RegisterEverythingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterEverythingService registers everything service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterGRPCAuthedWeatherService ¶
func RegisterGRPCAuthedWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterGRPCAuthedWeatherService registers the authenticated gRPC weather service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterGRPCWeatherService ¶
func RegisterGRPCWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterGRPCWeatherService registers the gRPC weather service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterHTTPAuthedEchoService ¶
func RegisterHTTPAuthedEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterHTTPAuthedEchoService registers the HTTP authed echo service with the given registration client.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterHTTPEchoService ¶
func RegisterHTTPEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterHTTPEchoService registers the HTTP echo service with the MCP server.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterOpenAPIAuthedService ¶
func RegisterOpenAPIAuthedService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterOpenAPIAuthedService registers the openapi authenticated service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterOpenAPIWeatherService ¶
func RegisterOpenAPIWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterOpenAPIWeatherService registers the openapi weather service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterStdioDockerService ¶
func RegisterStdioDockerService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)
RegisterStdioDockerService registers the stdio docker service.
t is the t. registrationClient is the registrationClient. _ is an unused parameter.
func RegisterStdioService ¶
func RegisterStdioService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)
RegisterStdioService registers the stdio service.
t is the t. registrationClient is the registrationClient. _ is an unused parameter.
func RegisterStreamableHTTPService ¶
func RegisterStreamableHTTPService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterStreamableHTTPService registers the streamable http service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterWebrtcWeatherService ¶
func RegisterWebrtcWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterWebrtcWeatherService registers the webrtc weather service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RegisterWebsocketWeatherService ¶
func RegisterWebsocketWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
RegisterWebsocketWeatherService registers the websocket weather service.
t is the t. registrationClient is the registrationClient. upstreamEndpoint is the upstreamEndpoint.
func RunE2ETest ¶
func RunE2ETest(t *testing.T, testCase *E2ETestCase)
RunE2ETest runs an end-to-end test case.
t is the t. testCase is the testCase.
func ValidateCaching ¶
ValidateCaching validates that caching is working correctly.
t is the t. mcpanyEndpoint is the mcpanyEndpoint. upstreamEndpoint is the upstreamEndpoint.
func ValidateRegisteredTool ¶
ValidateRegisteredTool validates that the expected tool is registered.
t is the t. mcpanyEndpoint is the mcpanyEndpoint. expectedTool is the expectedTool.
func VerifyMCPClient ¶
VerifyMCPClient verifies the MCP client.
t is the t. mcpanyEndpoint is the mcpanyEndpoint.
func WaitForPort ¶
func WaitForPort(t *testing.T, proc *integration.ManagedProcess) int
WaitForPort waits for a process to output its assigned port. WaitForPort waits for a process to output its assigned port.
Types ¶
type AITool ¶
type AITool interface {
// Install performs any necessary installation steps for the AI tool.
Install()
// AddMCP registers a new MCP server with the AI tool.
//
// Parameters:
// name: The name to assign to the MCP server.
// endpoint: The URL or address of the MCP server.
AddMCP(name, endpoint string)
// RemoveMCP unregisters an MCP server from the AI tool.
//
// Parameters:
// name: The name of the MCP server to remove.
RemoveMCP(name string)
// Run executes the AI tool with a specific prompt.
//
// Parameters:
// apiKey: The API key to use for authentication with the AI provider.
// model: The name of the model to use (e.g., "gemini-1.5-pro").
// prompt: The input text prompt to send to the model.
//
// Returns:
// string: The response generated by the AI tool.
// error: An error if the execution fails.
Run(apiKey, model, prompt string) (string, error)
}
AITool represents an AI tool used in testing.
type ClaudeCLI ¶
type ClaudeCLI struct {
// contains filtered or unexported fields
}
ClaudeCLI handles interactions with the Claude CLI tool for testing.
func (*ClaudeCLI) AddMCP ¶
AddMCP adds an MCP server to the Claude CLI configuration.
name is the name of the resource. endpoint is the endpoint.
type CopilotCLI ¶
type CopilotCLI struct {
// contains filtered or unexported fields
}
CopilotCLI handles interactions with the GitHub Copilot CLI tool for testing.
func NewCopilotCLI ¶
func NewCopilotCLI(t *testing.T) *CopilotCLI
NewCopilotCLI creates a new CopilotCLI instance.
t is the t.
Returns the result.
func (*CopilotCLI) AddMCP ¶
func (c *CopilotCLI) AddMCP(name, endpoint string)
AddMCP adds an MCP server to the Copilot CLI configuration by writing to mcp-config.json.
name is the name of the resource. endpoint is the endpoint.
func (*CopilotCLI) RemoveMCP ¶
func (c *CopilotCLI) RemoveMCP(name string)
RemoveMCP removes an MCP server.
name is the name of the resource.
type E2ETestCase ¶
type E2ETestCase struct {
Name string
UpstreamServiceType string
BuildUpstream func(t *testing.T) *integration.ManagedProcess
RegisterUpstream func(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
ValidateTool func(t *testing.T, mcpanyEndpoint string)
ValidateMiddlewares func(t *testing.T, mcpanyEndpoint string, upstreamEndpoint string)
InvokeAIClient func(t *testing.T, mcpanyEndpoint string)
InvokeAIClientWithServerInfo func(t *testing.T, serverInfo *integration.MCPANYTestServerInfo)
RegistrationMethods []RegistrationMethod
GenerateUpstreamConfig func(_ string) string
StartMCPANYServer func(t *testing.T, testName string, extraArgs ...string) *integration.MCPANYTestServerInfo
RegisterUpstreamWithJSONRPC func(t *testing.T, mcpanyEndpoint, upstreamEndpoint string)
}
E2ETestCase defines the structure for an end-to-end test case.
type GeminiCLI ¶
type GeminiCLI struct {
// contains filtered or unexported fields
}
GeminiCLI handles interactions with the Gemini CLI tool for testing.
func (*GeminiCLI) AddMCP ¶
AddMCP adds an MCP server to the Gemini CLI configuration.
name is the name of the resource. endpoint is the endpoint.
type MCPConfig ¶
type MCPConfig struct {
MCPServers map[string]MCPServerConfig `json:"mcpServers"`
}
MCPConfig defines the configuration file structure.
type MCPServerConfig ¶
type MCPServerConfig struct {
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"`
Type string `json:"type"` // "local", "http", "sse"
}
MCPServerConfig defines the configuration for an MCP server.
type RegistrationMethod ¶
type RegistrationMethod string
RegistrationMethod defines the method used to register an upstream service.
const ( // FileRegistration uses a configuration file for registration. FileRegistration RegistrationMethod = "file" // GRPCRegistration uses the RegistrationService via gRPC. GRPCRegistration RegistrationMethod = "grpc" // JSONRPCRegistration uses the RegistrationService via JSON-RPC. JSONRPCRegistration RegistrationMethod = "jsonrpc" )