framework

package
v1.12.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PodinfoAppResourceFlags = []string{
	"--set", "resources.limits.memory=256Mi",
	"--set", "resources.limits.cpu=100m",
}

PodinfoAppResourceFlags are the values testdata/helm/app_helmchart_podinfo.yaml sets besides replicaCount. A vanilla release installed with them has the pod template the Application renders, so adopting it rolls no pods.

View Source
var ScalerTrait = &v1beta1.TraitDefinition{
	TypeMeta: metav1.TypeMeta{
		Kind:       "TraitDefinition",
		APIVersion: "core.oam.dev/v1beta1",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:        "scaler-trait",
		Annotations: map[string]string{},
	},
	Spec: v1beta1.TraitDefinitionSpec{
		Version: "1.0.0",
		Schematic: &common.Schematic{
			CUE: &common.CUE{
				Template: "",
			},
		},
	},
}
View Source
var ScalerTraitOutputTemplate = `patch: spec: replicas: 1`

Functions

func ApplyDefinition

func ApplyDefinition(ctx context.Context, cli client.Client, obj client.Object)

ApplyDefinition creates a definition and waits until the controller has acted on it.

A definition is written through the API server but read back by the webhook through the manager's cache, and admission is synchronous. Lose that race and an Application referring to a definition applied milliseconds earlier is refused outright - "WorkloadDefinition ... not found" from a definition that plainly exists - rather than requeued. In a negative spec it is worse than a flake: the wrong denial arrives and the assertion reads as a real regression.

Each of these controllers stamps status once it has seen the object, so that status is direct evidence the cache holds it. Cheaper and more honest than a sleep, which would be both slower and still racy.

func CreateFreshNamespace

func CreateFreshNamespace(ctx context.Context, cli client.Client, name string) (corev1.Namespace, error)

func ExprTraitDefinition

func ExprTraitDefinition(namespace, name, template string) *v1beta1.TraitDefinition

ExprTraitDefinition builds a TraitDefinition that applies to every workload.

func HelmTestSuffix

func HelmTestSuffix() string

func OptIn

OptIn marks an Application as wanting $( ) property expressions.

The suites run the controller in opt-in mode - expressions enabled, but only for Applications that ask - because that is the configuration a cluster should actually run. Running it wide open would leave the annotation path untested and would read $(VAR) in every Application on the cluster, which is what the gate exists to avoid.

func RandomNamespaceName

func RandomNamespaceName(basic string) string

RandomNamespaceName generates an independent DNS-label name for each case. Empty prefixes are used as suffixes by the PostDispatch fixtures; keep that suffix short enough for their longest object name.

func RunCommand

func RunCommand(name string, args ...string) (string, error)

func RunCommandSucceed

func RunCommandSucceed(name string, args ...string) string

func TestDataPath

func TestDataPath(parts ...string) string

TestDataPath resolves shared fixtures independently of a suite's working directory.

Types

type Framework

type Framework struct {
	Client client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

Framework owns one test process's client and suite lifecycle.

func New

func New() *Framework

func (*Framework) ApplyApp

func (f *Framework) ApplyApp(ctx context.Context, namespaceName, source string, app *v1beta1.Application)

func (*Framework) ConsistentlyReconciled

func (f *Framework) ConsistentlyReconciled(ctx context.Context, o client.Object, assertion func(g gomega.Gomega)) gomega.AsyncAssertion

ConsistentlyReconciled holds assertion while requesting reconciles of o, so "nothing changed" is checked across real reconciles. The controller records nothing when a requested reconcile completes, so the window spans three requests rather than relying on the first one finishing.

func (*Framework) ConsistentlyReconciledAll

func (f *Framework) ConsistentlyReconciledAll(ctx context.Context, objs []client.Object, assertion func(g gomega.Gomega)) gomega.AsyncAssertion

ConsistentlyReconciledAll is ConsistentlyReconciled for an assertion that spans several objects, each requested independently.

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(ctx context.Context, namespaceName string) corev1.Namespace

func (*Framework) CreateServiceAccount

func (f *Framework) CreateServiceAccount(ctx context.Context, ns, name string)

func (*Framework) EventuallyReconciled

func (f *Framework) EventuallyReconciled(ctx context.Context, o client.Object, assertion func(g gomega.Gomega)) gomega.AsyncAssertion

EventuallyReconciled polls assertion, requesting a reconcile of o whenever the controller has left it alone for quietPeriod. Every reconcile also re-runs a failing workflow step, so the long gaps of the step backoff are cut short.

func (*Framework) EventuallyReconciledAll

func (f *Framework) EventuallyReconciledAll(ctx context.Context, objs []client.Object, assertion func(g gomega.Gomega)) gomega.AsyncAssertion

EventuallyReconciledAll is EventuallyReconciled for an assertion that spans several objects, each requested independently.

func (*Framework) NewHelmTestContext

func (f *Framework) NewHelmTestContext() *HelmTestContext

func (*Framework) Register

func (f *Framework) Register(auth bool, ready func(client.Client)) bool

Register synchronizes shared setup and waits for all workers before cleanup.

func (*Framework) RequestReconcileNow

func (f *Framework) RequestReconcileNow(ctx context.Context, o client.Object)

RequestReconcileNow queues o for an immediate reconcile. The Application controller watches neither Component nor Trait definitions, nor the workloads it applies, so a change to them is otherwise seen on the next resync.

func (*Framework) UpdateApp

func (f *Framework) UpdateApp(ctx context.Context, namespaceName, target string, app *v1beta1.Application)

func (*Framework) VerifyApplicationDelaySuspendExpected

func (f *Framework) VerifyApplicationDelaySuspendExpected(ctx context.Context, ns, appName, suspendStep, nextStep, duration string)

func (*Framework) VerifyApplicationPhase

func (f *Framework) VerifyApplicationPhase(ctx context.Context, ns, appName string, expected oamcomm.ApplicationPhase)

func (*Framework) VerifyWorkloadRunningExpected

func (f *Framework) VerifyWorkloadRunningExpected(ctx context.Context, namespaceName, workloadName string, replicas int32, image string)

type HelmTestContext

type HelmTestContext struct {
	Framework    *Framework
	Ctx          context.Context
	Namespace    string
	AppNamespace string
	App          *v1beta1.Application
	AppKey       client.ObjectKey
	Attempted    bool
}

func (*HelmTestContext) Cleanup

func (h *HelmTestContext) Cleanup()

func (*HelmTestContext) CleanupNamespaceOnly

func (h *HelmTestContext) CleanupNamespaceOnly()

func (*HelmTestContext) CountSurvivingPods

func (h *HelmTestContext) CountSurvivingPods(originalUIDs map[types.UID]bool) int

func (*HelmTestContext) CreateNamespace

func (h *HelmTestContext) CreateNamespace()

func (*HelmTestContext) DeployApp

func (h *HelmTestContext) DeployApp()

func (*HelmTestContext) DeployAppFrom

func (h *HelmTestContext) DeployAppFrom(yamlPath string)

func (*HelmTestContext) FreshAttempt

func (h *HelmTestContext) FreshAttempt()

FreshAttempt moves a retried spec to a new namespace, removing the previous attempt's Application and release. FlakeAttempts reruns an It but not its BeforeAll, and a helm install into the first attempt's namespace fails.

func (*HelmTestContext) GetHelmSecrets

func (h *HelmTestContext) GetHelmSecrets() *corev1.SecretList

func (*HelmTestContext) LatestHelmSecretName

func (h *HelmTestContext) LatestHelmSecretName() string

LatestHelmSecretName returns the release secret with the highest revision. Secrets are named sh.helm.release.v1.<release>.v<N>, so the revision is compared as a number: v10 is newer than v9.

func (*HelmTestContext) RecordPodUIDs

func (h *HelmTestContext) RecordPodUIDs() map[types.UID]bool

func (*HelmTestContext) UpdateAppValues

func (h *HelmTestContext) UpdateAppValues(values map[string]interface{})

func (*HelmTestContext) WaitForAppRunning

func (h *HelmTestContext) WaitForAppRunning()

func (*HelmTestContext) WaitForDeploymentReady

func (h *HelmTestContext) WaitForDeploymentReady()

Jump to

Keyboard shortcuts

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