framework

package
v0.2.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireE2ELock

func AcquireE2ELock(ctx context.Context, clusterName string, timeout time.Duration) (func(), error)

AcquireE2ELock acquires a file lock for a given cluster name. It blocks with retries until the lock is acquired or timeout is reached.

func ApplyInfraAllSecrets

func ApplyInfraAllSecrets(ctx context.Context, kubeconfig, namespace string) error

func ApplyInfraControlPlaneSecrets

func ApplyInfraControlPlaneSecrets(ctx context.Context, kubeconfig, namespace string) error

func ApplyInfraDataPlaneSecrets

func ApplyInfraDataPlaneSecrets(ctx context.Context, kubeconfig, namespace string) error

func ApplyManifest

func ApplyManifest(ctx context.Context, kubeconfig, manifestPath string) error

ApplyManifest applies a YAML manifest to the cluster using kubectl.

func ApplyManifestContent added in v0.2.0

func ApplyManifestContent(ctx context.Context, kubeconfig, prefix, content string) error

func ApplySecret

func ApplySecret(ctx context.Context, kubeconfig string, spec SecretSpec) error

func DiscoverSampleManifests

func DiscoverSampleManifests(cfg Config, clusterType string) ([]string, error)

DiscoverSampleManifests returns sorted sample manifest paths.

func EnsureNamespace

func EnsureNamespace(ctx context.Context, kubeconfig, namespace string) error

func FindInfraRoot

func FindInfraRoot() (string, error)

FindInfraRoot locates the infra module root by searching for go.mod.

func GetSecretValue

func GetSecretValue(ctx context.Context, kubeconfig, namespace, secretName, key string) (string, error)

GetSecretValue reads a base64-encoded secret key value.

func GetServicePort

func GetServicePort(ctx context.Context, kubeconfig, namespace, service string) (int, error)

GetServicePort returns the first port exposed by a service.

func HelmUninstall

func HelmUninstall(ctx context.Context, releaseName, namespace, kubeconfig string) error

HelmUninstall removes a release using helm.

func HelmUpgradeInstall

func HelmUpgradeInstall(ctx context.Context, releaseName, chartPath, namespace, kubeconfig, valuesPath string, setValues []string) error

HelmUpgradeInstall installs or upgrades a release using helm.

func InstallOperator

func InstallOperator(ctx context.Context, cfg Config) error

InstallOperator installs or upgrades the infra-operator chart.

func Kubectl

func Kubectl(ctx context.Context, kubeconfig string, args ...string) error

Kubectl runs a kubectl command with optional kubeconfig.

func KubectlDeleteManifest

func KubectlDeleteManifest(ctx context.Context, kubeconfig, manifestPath string) error

KubectlDeleteManifest deletes resources from a manifest file.

func KubectlExecContainerOutput added in v0.2.0

func KubectlExecContainerOutput(ctx context.Context, kubeconfig, namespace, pod, container string, command ...string) (string, error)

KubectlExecContainerOutput runs kubectl exec against a specific container and returns output.

func KubectlExecOutput added in v0.2.0

func KubectlExecOutput(ctx context.Context, kubeconfig, namespace, pod string, command ...string) (string, error)

KubectlExecOutput runs kubectl exec and returns output.

func KubectlGetJSONPath

func KubectlGetJSONPath(ctx context.Context, kubeconfig, namespace, resource, name, jsonPath string) (string, error)

KubectlGetJSONPath fetches a jsonpath value for a resource.

func KubectlOutput

func KubectlOutput(ctx context.Context, kubeconfig string, args ...string) (string, error)

KubectlOutput runs a kubectl command and returns output.

func KubectlPatch

func KubectlPatch(ctx context.Context, kubeconfig, namespace, resource, name, patch string) error

KubectlPatch applies a merge patch to a resource.

func KubectlRolloutStatus

func KubectlRolloutStatus(ctx context.Context, kubeconfig, namespace, resource, timeout string) error

KubectlRolloutStatus waits for a rollout to finish.

func KubectlWaitForCondition

func KubectlWaitForCondition(ctx context.Context, kubeconfig, namespace, resource, name, condition, timeout string) error

KubectlWaitForCondition waits for a condition on a resource.

func KubectlWaitForDelete

func KubectlWaitForDelete(ctx context.Context, kubeconfig, namespace, resource, name, timeout string) error

KubectlWaitForDelete waits for a resource to be deleted.

func PortForwardService

func PortForwardService(ctx context.Context, kubeconfig, namespace, service string, remotePort int) (string, func(), error)

PortForwardService starts a kubectl port-forward to a service.

func ResolveSamplePath

func ResolveSamplePath(cfg Config, relativePath string) (string, error)

ResolveSamplePath returns the absolute path for a chart sample file.

func RunCommand

func RunCommand(ctx context.Context, name string, args ...string) error

RunCommand executes a command and returns a detailed error on failure.

func RunCommandOutput

func RunCommandOutput(ctx context.Context, name string, args ...string) (string, error)

RunCommandOutput executes a command and returns stdout/stderr on success.

func UninstallOperator

func UninstallOperator(ctx context.Context, cfg Config) error

UninstallOperator removes the infra-operator release.

func WaitForDeployment

func WaitForDeployment(ctx context.Context, kubeconfig, namespace, name string, timeout string) error

WaitForDeployment waits until a deployment is ready.

func WaitForOperatorReady

func WaitForOperatorReady(ctx context.Context, cfg Config, timeout string) error

WaitForOperatorReady waits until the operator deployment is ready.

func WaitForSandbox0InfraReady

func WaitForSandbox0InfraReady(ctx context.Context, kubeconfig string, infra InfraConfig, timeout string) error

WaitForSandbox0InfraReady waits for the Ready condition.

Types

type Cluster

type Cluster struct {
	Name       string
	Kubeconfig string
}

Cluster manages a Kind-backed Kubernetes cluster for E2E tests.

func NewCluster

func NewCluster(name string) *Cluster

NewCluster creates a new cluster descriptor.

func (*Cluster) CreateKind

func (c *Cluster) CreateKind(ctx context.Context, configPath string) error

CreateKind creates a Kind cluster with the provided config file. If the cluster already exists, it does nothing and returns nil.

func (*Cluster) DeleteKind

func (c *Cluster) DeleteKind(ctx context.Context) error

DeleteKind deletes the Kind cluster.

func (*Cluster) ExportKubeconfig

func (c *Cluster) ExportKubeconfig(ctx context.Context) (string, error)

ExportKubeconfig exports the cluster kubeconfig to a temporary file and returns the path.

func (*Cluster) LoadDockerImage

func (c *Cluster) LoadDockerImage(ctx context.Context, image string) error

LoadDockerImage loads a local Docker image into the cluster.

type Config

type Config struct {
	ClusterName           string
	KindConfigPath        string
	Kubeconfig            string
	UseExistingCluster    bool
	SkipClusterDelete     bool
	SkipOperatorInstall   bool
	SkipOperatorUninstall bool

	OperatorChartPath       string
	OperatorNamespace       string
	OperatorReleaseName     string
	OperatorDeploymentName  string
	OperatorValuesPath      string
	OperatorImageRepo       string
	OperatorImageTag        string
	OperatorImagePullPolicy string

	InfraNamespace string
}

Config defines E2E runtime configuration.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig reads E2E configuration from environment variables.

type InfraConfig

type InfraConfig struct {
	Name      string
	Namespace string
}

InfraConfig identifies a Sandbox0Infra instance for E2E tests.

type RolloutTarget

type RolloutTarget struct {
	Kind      string
	Name      string
	Namespace string
	Timeout   string
}

RolloutTarget represents a workload to wait on.

func (RolloutTarget) ResourceID

func (r RolloutTarget) ResourceID() (string, error)

ResourceID returns the kubernetes resource reference for rollout checks.

type Scenario

type Scenario struct {
	Name           string
	ManifestPath   string
	InfraName      string
	InfraNamespace string
	Secrets        []SecretSpec
	Rollouts       []RolloutTarget
	ReadyTimeout   string
}

Scenario describes a test environment driven by a sample manifest.

func BuildScenarioFromManifest

func BuildScenarioFromManifest(cfg Config, manifestPath string) (Scenario, error)

BuildScenarioFromManifest builds a Scenario from a Sandbox0Infra manifest.

type ScenarioEnv

type ScenarioEnv struct {
	Config   Config
	Scenario Scenario
	TestCtx  *TestContext
	Infra    InfraConfig
}

ScenarioEnv binds runtime config to a scenario.

func SetupScenario

func SetupScenario(cfg Config, scenario Scenario) (*ScenarioEnv, func(), error)

SetupScenario provisions a cluster, installs the operator, and applies a sample manifest.

type SecretSpec

type SecretSpec struct {
	Name       string
	Namespace  string
	Type       string
	StringData map[string]string
}

func AdminPasswordSecret

func AdminPasswordSecret(namespace string) SecretSpec

AdminPasswordSecret returns a randomized admin password secret spec.

type TestContext

type TestContext struct {
	Context    context.Context
	Cluster    *Cluster
	Namespace  string
	StartedAt  time.Time
	Timeout    time.Duration
	RetryDelay time.Duration
}

TestContext carries shared dependencies across suites.

func NewTestContext

func NewTestContext(cluster *Cluster) *TestContext

NewTestContext creates a base context for E2E suites.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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