e2eutil

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package e2eutil provides helpers for running end-to-end tests against a Kubernetes cluster. The cluster and operator are expected to be already running. Each test provisions its own worker nodes for isolation.

Index

Constants

View Source
const (
	// LabelE2ETest is applied to test-scoped resources (nodes, pools).
	// Its value is the sanitized test name, used for both node
	// selection and label-based cleanup.
	LabelE2ETest = "bootc.dev/e2e-test"
)

Variables

This section is empty.

Functions

func Providers added in v0.1.1

func Providers(t *testing.T, supported ...string)

Providers skips the test if the current E2E_PROVIDER is not in the supported list. Call at the top of each test function.

func RetagImage

func RetagImage(t *testing.T, srcRef, dstTag string)

RetagImage reads the image at srcRef from the localhost registry and tags it as dstTag.

Types

type Env

type Env struct {
	// Client is a controller-runtime client with the bootc CRD scheme
	// registered.
	Client client.Client
	// contains filtered or unexported fields
}

Env holds a cluster context for a single e2e test. Each test creates its own Env via New(t), so test-scoped state (like the test ID used for node labeling and pool selectors) lives here.

func New

func New(t *testing.T) *Env

New connects to an existing cluster and returns an Env ready for testing. The cluster must be running with the operator deployed.

func (*Env) AddNode

func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string

AddNode provisions a worker node via the configured provider, waits for it to be Ready, and returns the node name. The node is labeled with LabelE2ETest (and any extra labels from WithLabel).

func (*Env) AuthImageRef added in v0.1.1

func (e *Env) AuthImageRef() string

AuthImageRef returns the image reference to use for pull secret tests. For bink, this rewrites the update digest to go through the auth registry (port 5001). For EKS, the update image already requires auth, so it is returned as-is.

func (*Env) NewPool

func (e *Env) NewPool(
	suffix, imageRef string,
	opts ...testutil.PoolOption,
) *bootcv1alpha1.BootcNodePool

NewPool creates a BootcNodePool with a test-scoped name and labels. The pool is labeled with LabelE2ETest for cleanup. If no WithNodeSelector option is provided, it defaults to selecting nodes with LabelE2ETest (i.e. all nodes belonging to this test).

func (*Env) NodeImageDigest

func (e *Env) NodeImageDigest() string

NodeImageDigest returns the manifest digest portion of the base node image reference.

func (*Env) NodeImageDigestedPullSpec

func (e *Env) NodeImageDigestedPullSpec() string

NodeImageDigestedPullSpec returns the full digest-qualified reference for the base node image.

func (*Env) NodeImageTagRef

func (e *Env) NodeImageTagRef() string

NodeImageTagRef returns the tag-based reference for the base node image (e.g. "registry.cluster.local:5000/node:latest").

func (*Env) NodeImageUpdate2Digest

func (e *Env) NodeImageUpdate2Digest() string

NodeImageUpdate2Digest returns the manifest digest portion of the second update image reference.

func (*Env) NodeImageUpdate2DigestedPullSpec

func (e *Env) NodeImageUpdate2DigestedPullSpec() string

NodeImageUpdate2DigestedPullSpec returns the full digest-qualified reference for the second update image.

func (*Env) NodeImageUpdateDigest

func (e *Env) NodeImageUpdateDigest() string

NodeImageUpdateDigest returns the manifest digest portion of the update image reference.

func (*Env) NodeImageUpdateDigestedPullSpec

func (e *Env) NodeImageUpdateDigestedPullSpec() string

NodeImageUpdateDigestedPullSpec returns the full digest-qualified reference for the update image.

func (*Env) RegistryHost added in v0.1.1

func (e *Env) RegistryHost() string

RegistryHost returns the hostname (with optional port) of the authenticated registry used for pull secret tests.

func (*Env) RegistryPassword

func (e *Env) RegistryPassword() string

RegistryPassword returns the authenticated registry password, or empty if not configured.

func (*Env) RegistryUser

func (e *Env) RegistryUser() string

RegistryUser returns the authenticated registry username, or empty if not configured.

func (*Env) TestID

func (e *Env) TestID() string

TestID returns the sanitized test name used for naming resources.

func (*Env) TestLabels

func (e *Env) TestLabels() map[string]string

TestLabels returns the label map identifying resources belonging to this test. Use with testutil.WithNodeSelector() when overriding the default node selector in NewPool.

type NodeOption

type NodeOption func(*nodeConfig)

NodeOption configures a node provisioned by AddNode.

func WithLabel

func WithLabel(key, value string) NodeOption

WithLabel adds a label to the provisioned node. This is in addition to the LabelE2ETest label which is always applied.

type NodeProvider added in v0.1.1

type NodeProvider interface {
	AddNode(ctx context.Context, labels map[string]string) (nodeName string, err error)
	RemoveNode(ctx context.Context, nodeName string) error
}

NodeProvider abstracts node provisioning so the same tests can run against different infrastructure (bink, EKS, etc.).

Jump to

Keyboard shortcuts

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