framework

package
v0.0.0-...-c3f02f9 Latest Latest
Warning

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

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

Documentation

Overview

Package framework is the artifact-driven test harness for kube-applier integration tests.

A test case is a directory under artifacts/. Inside, each subdirectory is a numbered step:

NN-stepType-description/

where NN orders execution and stepType selects the step kind. See the step_*.go files in this package for available step types and the JSON shape each one expects. Steps run sequentially against a single mock Cosmos and the shared envtest cluster.

Index

Constants

View Source
const (

	// EventuallyTimeout bounds how long an Eventually step polls before
	// failing. Workqueue rate-limit backoff plus cosmos relist take a few
	// seconds in the worst case under contention.
	EventuallyTimeout = 30 * time.Second
	// EventuallyTick is the polling interval for Eventually steps.
	EventuallyTick = 100 * time.Millisecond
)
View Source
const ManagementCluster = "/providers/microsoft.redhatopenshift/stamps/test/managementclusters/mgmt-1"

ManagementCluster is the partition-key value used by every test case. The kube-applier process is single-tenant per management cluster, so a fixed value is correct here. After the *Desire API changed Spec.ManagementCluster from a free-form string to an azcorearm.ResourceID, the partition key value must be the lowercased canonical form of that resourceID; tests' JSON fixtures (e.g. artifacts/.../desire.json) likewise embed the same path string.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	KubeApplierDBClient kubeappliercosmosstorage.KubeApplierDBClient
	Dyn                 dynamic.Interface
	Namespace           string
}

Harness holds the per-test runtime that steps read from / mutate.

KubeApplierDBClient is the interface (not the concrete mock) so a future joint backend+kube-applier test can swap in an implementation that shares storage with the backend's MockDBClient.

type Step

type Step interface {
	// StepID returns the directory name (e.g. "01-loadApplyDesire-hello").
	// Used in test logs.
	StepID() string
	// Run executes the step against the test's harness. Failures use t.Fatal.
	Run(ctx context.Context, t *testing.T, h *Harness)
}

Step is the unit of work a test case runs. Each implementation parses its own JSON files out of stepDir and either mutates state (load/apply/delete) or asserts state (eventually).

type TestCase

type TestCase struct {
	// Name is the artifact subdirectory name.
	Name string
	// Steps are read in directory-name order.
	Steps []Step
}

TestCase is a single artifact-driven test.

func LoadTestCases

func LoadTestCases(artifactsFS fs.FS, root string) ([]TestCase, error)

LoadTestCases discovers every test under root in artifactsFS. Each immediate subdirectory becomes a TestCase. Within that subdirectory, each numbered subdirectory becomes a Step.

func (TestCase) RunCase

func (tc TestCase) RunCase(t *testing.T, cfg *rest.Config)

RunCase executes one TestCase against a fresh harness.

It expects envtest to already be running; cfg must be its rest.Config. The harness creates a per-test namespace named after tc.Name (with hyphens preserved), so artifact JSONs that reference that exact namespace name will land in their own scope and not collide with sibling tests.

Jump to

Keyboard shortcuts

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