framework

package
v0.0.0-...-be7b520 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package framework provides testing framework utilities.

Index

Constants

View Source
const DefaultClaudeModel = "claude-3-5-sonnet-latest"

DefaultClaudeModel is the default Claude model to use.

View Source
const DefaultModel = "gemini-2.5-flash"

DefaultModel is the default Gemini model to use.

Variables

View Source
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

func NoOpMiddleware(_ *testing.T, next http.Handler) http.Handler

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 TestE2ECaching

func TestE2ECaching(t *testing.T)

TestE2ECaching tests the end-to-end caching functionality.

t is the t.

func ValidateCaching

func ValidateCaching(t *testing.T, mcpanyEndpoint, upstreamEndpoint string)

ValidateCaching validates that caching is working correctly.

t is the t. mcpanyEndpoint is the mcpanyEndpoint. upstreamEndpoint is the upstreamEndpoint.

func ValidateRegisteredTool

func ValidateRegisteredTool(t *testing.T, mcpanyEndpoint string, expectedTool *mcp.Tool)

ValidateRegisteredTool validates that the expected tool is registered.

t is the t. mcpanyEndpoint is the mcpanyEndpoint. expectedTool is the expectedTool.

func VerifyMCPClient

func VerifyMCPClient(t *testing.T, mcpanyEndpoint string)

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 NewClaudeCLI

func NewClaudeCLI(t *testing.T) *ClaudeCLI

NewClaudeCLI creates a new ClaudeCLI instance.

t is the t.

Returns the result.

func (*ClaudeCLI) AddMCP

func (c *ClaudeCLI) AddMCP(name, endpoint string)

AddMCP adds an MCP server to the Claude CLI configuration.

name is the name of the resource. endpoint is the endpoint.

func (*ClaudeCLI) Install

func (c *ClaudeCLI) Install()

Install installs the Claude CLI tool.

func (*ClaudeCLI) RemoveMCP

func (c *ClaudeCLI) RemoveMCP(name string)

RemoveMCP removes an MCP server from the Claude CLI configuration.

name is the name of the resource.

func (*ClaudeCLI) Run

func (c *ClaudeCLI) Run(apiKey, prompt string) (string, error)

Run executes a prompt against the Claude CLI.

apiKey is the apiKey. prompt is the prompt.

Returns the result. Returns an error if the operation fails.

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) Install

func (c *CopilotCLI) Install()

Install installs the Copilot CLI tool.

func (*CopilotCLI) RemoveMCP

func (c *CopilotCLI) RemoveMCP(name string)

RemoveMCP removes an MCP server.

name is the name of the resource.

func (*CopilotCLI) Run

func (c *CopilotCLI) Run(apiKey, prompt string) (string, error)

Run executes a prompt.

apiKey is the apiKey. prompt is the prompt.

Returns the result. Returns an error if the operation fails.

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 NewGeminiCLI

func NewGeminiCLI(t *testing.T) *GeminiCLI

NewGeminiCLI creates a new GeminiCLI instance.

t is the t.

Returns the result.

func (*GeminiCLI) AddMCP

func (g *GeminiCLI) AddMCP(name, endpoint string)

AddMCP adds an MCP server to the Gemini CLI configuration.

name is the name of the resource. endpoint is the endpoint.

func (*GeminiCLI) Install

func (g *GeminiCLI) Install()

Install installs the Gemini CLI tool.

func (*GeminiCLI) RemoveMCP

func (g *GeminiCLI) RemoveMCP(name string)

RemoveMCP removes an MCP server from the Gemini CLI configuration.

name is the name of the resource.

func (*GeminiCLI) Run

func (g *GeminiCLI) Run(apiKey, prompt string) (string, error)

Run executes a prompt against the Gemini CLI using the provided API key.

apiKey is the apiKey. prompt is the prompt.

Returns the result. Returns an error if the operation fails.

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL