HyperFleet E2E is a Ginkgo-based black-box testing framework for validating HyperFleet cluster lifecycle management.
- Ephemeral resource management - Tests create and cleanup temporary resources
- Configuration-driven execution - Behavior controlled through config files, env vars, and CLI flags
- Structured logging - All operations tracked with component, cluster ID, and error context
- OpenAPI client generation - Type-safe API client auto-generated from HyperFleet OpenAPI spec
pkg/
├── api/ - OpenAPI generated client
├── client/ - HyperFleet API client wrapper
├── config/ - Configuration loading and validation
├── e2e/ - Test execution engine (Ginkgo)
├── helper/ - Test helper utilities (waits, assertions)
├── labels/ - Test label definitions
└── logger/ - Structured logging (slog)
HyperFleet E2E creates ephemeral resources per test for complete isolation.
Resource Lifecycle: Per-test creation and cleanup
- Each test creates its own cluster via API
- Full isolation between tests
- Automatic cleanup after completion
- Supports parallel execution
Workflow:
Test starts
→ Create new Helper instance
→ GetTestCluster() creates cluster via API
→ Wait for cluster Ready phase
→ Execute test assertions
→ CleanupTestCluster() deletes cluster
Test ends
Example Configuration:
api:
url: https://api.hyperfleet.example.com
resources:
keep: false
timeouts:
cluster:
ready: 5mPurpose: Configuration loading, validation, and management
Key Features:
- Multi-source configuration loading (file, environment variables, CLI flags)
- Detailed validation with helpful error messages
- Configuration priority enforcement
Configuration Priority Chain:
CLI Flags (highest priority)
↓
Environment Variables (HYPERFLEET_* prefix)
↓
Config File (configs/config.yaml)
↓
Built-in Defaults (lowest priority)
Key Types:
Config- Top-level configuration structAPIConfig,TimeoutsConfig,PollingConfig,LogConfig- Nested configuration sections
Key Functions:
Load()- Load and validate configurationValidate()- Validate configuration requirementsDisplay()- Log merged configuration using structured logging
Purpose: Wrapper around generated OpenAPI client with test-friendly methods
Key Features:
- Generic HTTP response handler
- Structured error handling
- Convenience methods for common operations
- Direct access to underlying OpenAPI client
Key Types:
HyperFleetClient- Main client interface- Wraps generated OpenAPI
Clientfrompkg/api/openapi
Key Methods:
GetCluster(ctx, clusterID)- Fetch cluster detailsCreateCluster(ctx, payload)- Create new clusterDeleteCluster(ctx, clusterID)- Delete clusterGetNodePool(ctx, clusterID, nodePoolID)- Fetch nodepool details- Similar methods for all HyperFleet resources
Purpose: Test helper utilities for resource management
Key Features:
- Resource lifecycle management (create, wait, cleanup)
- Condition polling and validation
- Per-test helper instance creation
Key Types:
Helper- Main helper struct with resource management methods
Key Methods:
Resource Management:
GetTestCluster(ctx, payloadPath)- Create temporary test clusterCleanupTestCluster(ctx, clusterID)- Delete test clusterGetTestNodePool(ctx, clusterID, payloadPath)- Create nodepoolCleanupTestNodePool(ctx, clusterID, nodePoolID)- Delete nodepool
Wait Operations:
WaitForClusterPhase(ctx, clusterID, phase, timeout)- Poll until cluster reaches phaseWaitForAllAdapterConditions(ctx, clusterID, conditions)- Wait for adapter conditions
Condition Validation:
ValidateAdapterConditions(ctx, clusterID, expectedConditions)- Check adapter status
Purpose: Structured logging based on Go's log/slog package
Key Features:
- Structured logging with automatic fields (component, version, hostname)
- Context-aware methods for cluster and error logging
- Configurable output format (text, JSON)
- Configurable log level (debug, info, warn, error)
Key Functions:
Init(cfg, buildVersion)- Initialize logger with configurationInfoWithCluster(clusterID, msg, fields...)- Log with cluster contextErrorWithError(msg, err, fields...)- Log with error details
Automatic Fields:
component- Package/module nameversion- Framework versionhostname- Execution hostcluster_id- Cluster ID (when using InfoWithCluster)error- Error details (when using ErrorWithError)
Purpose: Test execution engine and Ginkgo configuration
Key Features:
- Ginkgo suite configuration
- JUnit report generation
- Test filtering (labels, focus, skip)
- Suite timeout management
Key Functions:
RunTests(cfg)- Main entry point for test execution- Configures Ginkgo reporters, timeouts, and filters
- Handles suite-level setup and teardown
Configuration values are applied in this priority order:
┌──────────────────────────────────────────────────────────────────┐
│ 1. CLI Flags (highest priority) │
│ Example: --api-url, --log-level │
└──────────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────────┐
│ 2. Environment Variables │
│ Example: HYPERFLEET_API_URL, HYPERFLEET_LOG_LEVEL │
└──────────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────────┐
│ 3. Config File │
│ Example: configs/config.yaml │
└──────────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────────┐
│ 4. Built-in Defaults (lowest priority) │
│ Example: timeout: 30m, poll: 5s │
└──────────────────────────────────────────────────────────────────┘
Example: If you set HYPERFLEET_API_URL=https://env.example.com and also pass --api-url=https://flag.example.com, the CLI flag value (https://flag.example.com) wins.
CLI Invoked (hyperfleet-e2e test)
↓
┌─────────────────────────────────────┐
│ Load Configuration │
│ • Read config file │
│ • Apply environment variables │
│ • Apply CLI flags │
│ • Validate configuration │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Initialize Logger │
│ • Setup structured logging │
│ • Display merged configuration │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Configure Ginkgo │
│ • Apply label filters │
│ • Setup JUnit reporter │
│ • Configure timeouts │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Run Test Suites │
│ • Discover all e2e/*_test.go │
│ • Execute matched tests │
│ • Collect results │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Generate Reports │
│ • JUnit XML (if configured) │
│ • Console output │
│ • Exit code (0 = pass, 1 = fail) │
└─────────────────────────────────────┘
The framework uses code generation to maintain type-safe API clients.
- Source: HyperFleet OpenAPI specification (YAML/JSON)
- Generator: oapi-codegen (Go client)
- Output:
pkg/api/openapi/package - Regeneration:
make generate(when API spec changes)
The generated client is wrapped by pkg/client.HyperFleetClient to provide:
- Simplified error handling
- Test-friendly method signatures
- Automatic retry logic (future)
- Request/response logging
Example:
// Generated client (low-level)
apiClient := openapi.NewClient(...)
resp, httpResp, err := apiClient.ClustersAPI.GetCluster(ctx, clusterID).Execute()
// Wrapped client (test-friendly)
client := client.NewHyperFleetClient(apiURL)
cluster, err := client.GetCluster(ctx, clusterID)The OpenAPI specification is typically maintained in the main HyperFleet repository and referenced during code generation. Updates to the API require regenerating the client:
make generateThis ensures the test framework stays in sync with API changes.