e2e

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProjectRoot is the relative path from the test/e2e/cli package to the
	// repository root. Go test runners set the working directory to the
	// package under test, so all paths must be anchored relative to it.
	ProjectRoot = "../../.."

	// BinaryPath is the path to the helmet-ex binary relative to the
	// project root.
	BinaryPath = "example/helmet-ex/helmet-ex"

	// ConfigPath is the path to the test configuration file relative to the
	// project root. Passed to the binary which opens it via io/fs (no
	// absolute paths or ".." traversals allowed).
	ConfigPath = "test/config.yaml"
)

Variables

This section is empty.

Functions

func GetKubeConfig

func GetKubeConfig() (*rest.Config, error)

GetKubeConfig loads kubeconfig from the KUBECONFIG environment variable or the default location (~/.kube/config).

func MCPTestImage

func MCPTestImage() string

MCPTestImage returns the container image reference for the MCP server. Uses IMAGE environment varable if set, falls back to default.

func NewHelmConfig

func NewHelmConfig(namespace string) (*action.Configuration, error)

NewHelmConfig creates a Helm action.Configuration for the specified namespace using the KUBECONFIG environment variable.

Types

type Checker

type Checker interface {
	Check(ctx context.Context) Result
}

Checker defines the interface for cluster state validation components.

type ClusterValidator

type ClusterValidator struct {
	// contains filtered or unexported fields
}

ClusterValidator composes multiple checkers for comprehensive cluster state validation.

func NewClusterValidator

func NewClusterValidator(checkers ...Checker) *ClusterValidator

NewClusterValidator creates a validator with the specified checkers.

func (*ClusterValidator) RunAll

func (v *ClusterValidator) RunAll(ctx context.Context) []Result

RunAll executes all checkers sequentially and returns all results. It does not short-circuit on failure, collecting all validation errors for comprehensive reporting.

type ConfigChecker

type ConfigChecker struct {
	// contains filtered or unexported fields
}

ConfigChecker validates the cluster configuration ConfigMap exists and contains product definitions.

func NewConfigChecker

func NewConfigChecker(
	kubeClient kubernetes.Interface,
	namespace string,
	appName string,
) *ConfigChecker

NewConfigChecker creates a ConfigChecker for the specified application name.

func (*ConfigChecker) Check

func (c *ConfigChecker) Check(ctx context.Context) Result

Check verifies the ConfigMap exists with the expected label and contains valid config.yaml data with at least one product definition.

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

MCPClient communicates with a helmet-ex mcp-server subprocess via JSON-RPC 2.0 over STDIO. Created by Runner.StartMCPServer.

func NewMCPClient

func NewMCPClient(
	cmd *exec.Cmd,
	stdin io.WriteCloser,
	reader *bufio.Reader,
	nextID int64,
) *MCPClient

NewMCPClient instantiates an MCPClient.

func (*MCPClient) CallTool

func (c *MCPClient) CallTool(
	ctx context.Context,
	name string,
	args map[string]any,
) ToolResult

CallTool invokes a tool by name with optional arguments. Tool errors arrive as ToolResult with IsError=true, not as Go errors. Go errors indicate protocol-level failures only; they are reported via Gomega Expect to fail the test immediately.

func (*MCPClient) Initialize

func (c *MCPClient) Initialize(ctx context.Context) error

Initialize performs the MCP initialize handshake. Must be called before any tool calls.

func (*MCPClient) ListTools

func (c *MCPClient) ListTools(ctx context.Context) ([]string, error)

ListTools calls tools/list and returns the tool names.

func (*MCPClient) Shutdown

func (c *MCPClient) Shutdown() error

Shutdown sends a clean shutdown and waits for the subprocess to exit.

type ReleasesChecker

type ReleasesChecker struct {
	// contains filtered or unexported fields
}

ReleasesChecker validates Helm releases are installed and deployed in the correct topology order.

func NewReleasesChecker

func NewReleasesChecker(
	helmConfig *action.Configuration,
	kubeClient kubernetes.Interface,
	namespace string,
	expectedOrder []string,
) *ReleasesChecker

NewReleasesChecker creates a ReleasesChecker. The expectedOrder slice defines the topology-sorted deployment order. The deploy-sequence ConfigMap name defaults to "deploy-sequence".

func (*ReleasesChecker) Check

func (r *ReleasesChecker) Check(ctx context.Context) Result

Check verifies:

  1. All expected releases exist (via helm list).
  2. All releases are in "deployed" status.
  3. Deploy order matches expected topology (via deploy-sequence ConfigMap).

type Result

type Result struct {
	Passed  bool   // true if validation succeeded
	Message string // descriptive message (error details if Passed=false)
}

Result represents the outcome of a checker validation.

func NewFailedResult

func NewFailedResult(err error) Result

NewFailedResult creates a failed result with an error message.

func NewResult

func NewResult(message string) Result

NewResult creates a successful result with an optional message.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes helmet-ex CLI commands in a subprocess. All paths (binary, config) are relative to the project root. The binary is launched with its working directory set to the project root so that the embedded ChartFS (io/fs based) can resolve paths correctly.

func NewRunner

func NewRunner(projectRoot, binaryPath, configPath, namespace string) (*Runner, error)

NewRunner creates a new CLI command runner. The projectRoot is used as the working directory for the child process; it is resolved to an absolute path so the runner works regardless of where the test binary executes.

func (*Runner) ConfigCreate

func (r *Runner) ConfigCreate(ctx context.Context) error

ConfigCreate executes: "helmet-ex config --create --namespace <ns> <configPath>".

func (*Runner) ConfigDelete

func (r *Runner) ConfigDelete(ctx context.Context)

ConfigDelete executes: "helmet-ex config --delete". Errors are ignored so it can be called even when no config exists yet.

func (*Runner) Deploy

func (r *Runner) Deploy(ctx context.Context) error

Deploy executes: "helmet-ex deploy".

func (*Runner) Integration

func (r *Runner) Integration(
	ctx context.Context,
	module string,
	flags ...string,
) error

Integration executes: helmet-ex integration <module> <flags...>.

func (*Runner) StartMCPServer

func (r *Runner) StartMCPServer(
	ctx context.Context,
	image string,
) (*MCPClient, error)

StartMCPServer launches the MCP server as a long-lived subprocess and returns a client connected to its STDIO pipes. The Runner's projectRoot and binaryPath are reused; the image argument is passed as --image to the mcp-server subcommand.

func (*Runner) Topology

func (r *Runner) Topology(ctx context.Context) error

Topology executes: "helmet-ex topology".

type SecretsChecker

type SecretsChecker struct {
	// contains filtered or unexported fields
}

SecretsChecker validates that integration Secrets exist in the target namespace.

func NewSecretsChecker

func NewSecretsChecker(
	kubeClient kubernetes.Interface,
	namespace string,
	secretNames []string,
) *SecretsChecker

NewSecretsChecker creates a SecretsChecker for the specified secrets.

func (*SecretsChecker) Check

func (s *SecretsChecker) Check(ctx context.Context) Result

Check verifies all expected secrets exist in the namespace.

type SharedContext

type SharedContext struct {
	KubeConfig *rest.Config
	KubeClient kubernetes.Interface
	HelmConfig *action.Configuration
	Namespace  string
}

SharedContext holds common resources for E2E tests.

func NewSharedContext

func NewSharedContext(namespace string) (*SharedContext, error)

NewSharedContext initializes the shared E2E test context. It verifies KUBECONFIG is set and creates Kubernetes clients.

type ToolResult

type ToolResult struct {
	mcp.CallToolResult
}

ToolResult wraps a CallToolResult with convenience accessors.

func (ToolResult) Text

func (r ToolResult) Text() string

Text extracts the concatenated text from all TextContent entries. Returns empty string if no text content is present.

Jump to

Keyboard shortcuts

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