e2e

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package e2e provides end-to-end testing framework for the control-plane. It simulates complete user workflows including app creation, service configuration, deployment, and verification. **Validates: Requirements 12.2**

Package e2e provides end-to-end testing framework for the control-plane.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyAllDeploymentsRunning

func VerifyAllDeploymentsRunning(deployments []*models.Deployment) error

VerifyAllDeploymentsRunning verifies that all deployments for an app are running. **Validates: Requirements 12.2**

func VerifyDeploymentState

func VerifyDeploymentState(deployment *models.Deployment, expectedStatus models.DeploymentStatus) error

VerifyDeploymentState verifies that a deployment is in the expected state. **Validates: Requirements 12.2**

func VerifyEventSequence

func VerifyEventSequence(events []Event, expectedTypes []EventType) error

VerifyEventSequence verifies that events occurred in the expected order. **Validates: Requirements 12.2**

Types

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	EntityID  string
	Details   map[string]interface{}
}

Event represents an event that occurred during testing.

type EventType

type EventType string

EventType represents the type of event.

const (
	EventAppCreated        EventType = "app_created"
	EventServiceAdded      EventType = "service_added"
	EventDeploymentCreated EventType = "deployment_created"
	EventBuildStarted      EventType = "build_started"
	EventBuildCompleted    EventType = "build_completed"
	EventBuildFailed       EventType = "build_failed"
	EventDeploymentStarted EventType = "deployment_started"
	EventDeploymentRunning EventType = "deployment_running"
	EventDeploymentFailed  EventType = "deployment_failed"
	EventSecretSet         EventType = "secret_set"
	EventNodeRegistered    EventType = "node_registered"
)

type TestConfig

type TestConfig struct {
	// SimulateBuildDelay adds artificial delay to build operations
	SimulateBuildDelay time.Duration
	// SimulateDeployDelay adds artificial delay to deploy operations
	SimulateDeployDelay time.Duration
	// FailBuildProbability is the probability (0-1) that a build will fail
	FailBuildProbability float64
	// FailDeployProbability is the probability (0-1) that a deploy will fail
	FailDeployProbability float64
}

TestConfig holds configuration for the test environment.

func DefaultTestConfig

func DefaultTestConfig() *TestConfig

DefaultTestConfig returns a default test configuration.

type TestEnvironment

type TestEnvironment struct {

	// In-memory stores
	Apps        map[string]*models.App
	Deployments map[string]*models.Deployment
	Nodes       map[string]*models.Node
	Builds      map[string]*models.BuildJob
	Secrets     map[string]map[string]string // appID -> key -> value

	// Event tracking
	Events []Event

	// Configuration
	Config *TestConfig
	// contains filtered or unexported fields
}

TestEnvironment represents a complete test environment with all components. **Validates: Requirements 12.2**

func NewTestEnvironment

func NewTestEnvironment(config *TestConfig) *TestEnvironment

NewTestEnvironment creates a new test environment. **Validates: Requirements 12.2**

func (*TestEnvironment) GetEvents

func (env *TestEnvironment) GetEvents() []Event

GetEvents returns all recorded events.

func (*TestEnvironment) GetEventsByType

func (env *TestEnvironment) GetEventsByType(eventType EventType) []Event

GetEventsByType returns events filtered by type.

type UserSimulator

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

UserSimulator provides helper functions for simulating user workflows. **Validates: Requirements 12.2**

func NewUserSimulator

func NewUserSimulator(env *TestEnvironment) *UserSimulator

NewUserSimulator creates a new user simulator.

func (*UserSimulator) AddService

func (s *UserSimulator) AddService(ctx context.Context, appID string, service models.ServiceConfig) error

AddService simulates a user adding a service to an application. **Validates: Requirements 12.2**

func (*UserSimulator) CreateApp

func (s *UserSimulator) CreateApp(ctx context.Context, name, description string) (*models.App, error)

CreateApp simulates a user creating a new application. **Validates: Requirements 12.2**

func (*UserSimulator) Deploy

func (s *UserSimulator) Deploy(ctx context.Context, appID, serviceName, gitRef string) (*models.Deployment, error)

Deploy simulates a user triggering a deployment. **Validates: Requirements 12.2**

func (*UserSimulator) GetApp

func (s *UserSimulator) GetApp(ctx context.Context, appID string) (*models.App, error)

GetApp retrieves an app by ID.

func (*UserSimulator) GetDeployment

func (s *UserSimulator) GetDeployment(ctx context.Context, deploymentID string) (*models.Deployment, error)

GetDeployment retrieves a deployment by ID.

func (*UserSimulator) ListDeployments

func (s *UserSimulator) ListDeployments(ctx context.Context, appID string) ([]*models.Deployment, error)

ListDeployments lists all deployments for an app.

func (*UserSimulator) RegisterNode

func (s *UserSimulator) RegisterNode(ctx context.Context, hostname, address string, resources *models.NodeResources) (*models.Node, error)

RegisterNode simulates registering a node in the cluster. **Validates: Requirements 12.2**

func (*UserSimulator) SetSecret

func (s *UserSimulator) SetSecret(ctx context.Context, appID, key, value string) error

SetSecret simulates a user setting a secret for an application. **Validates: Requirements 12.2**

type WorkflowExecutor

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

WorkflowExecutor simulates the backend processing of deployments. **Validates: Requirements 12.2**

func NewWorkflowExecutor

func NewWorkflowExecutor(env *TestEnvironment) *WorkflowExecutor

NewWorkflowExecutor creates a new workflow executor.

func (*WorkflowExecutor) ExecuteFullWorkflow

func (w *WorkflowExecutor) ExecuteFullWorkflow(ctx context.Context, appID string) *WorkflowResult

ExecuteFullWorkflow executes a complete workflow and returns the result. **Validates: Requirements 12.2**

func (*WorkflowExecutor) ProcessAllPendingDeployments

func (w *WorkflowExecutor) ProcessAllPendingDeployments(ctx context.Context) error

ProcessAllPendingDeployments processes all pending deployments.

func (*WorkflowExecutor) ProcessDeployment

func (w *WorkflowExecutor) ProcessDeployment(ctx context.Context, deploymentID string) error

ProcessDeployment simulates the complete deployment workflow. This includes: build → schedule → deploy **Validates: Requirements 12.2**

type WorkflowResult

type WorkflowResult struct {
	Success      bool
	Deployments  []*models.Deployment
	Builds       []*models.BuildJob
	Events       []Event
	Duration     time.Duration
	ErrorMessage string
}

WorkflowResult contains the result of a workflow execution.

Jump to

Keyboard shortcuts

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