testcontroller

package
v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventNotRecordedforUnstruct

func AssertEventNotRecordedforUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured, reason string)

func AssertEventRecordedForObjectMetaAndKind

func AssertEventRecordedForObjectMetaAndKind(t *testing.T, c client.Client, kind string, om *metav1.ObjectMeta, reason string)

func AssertEventRecordedforUnstruct

func AssertEventRecordedforUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured, reason string)

func AssertLabelsMatchAndHaveManagedLabel

func AssertLabelsMatchAndHaveManagedLabel(t *testing.T, actual, expected map[string]string)

AssertLabelsMatchAndHaveManagedLabel checks that a given label appears in the label map.

func AssertObservedGenerationEquals

func AssertObservedGenerationEquals(t *testing.T, unstruct *unstructured.Unstructured, preReconcileGeneration int64)

func AssertReadyCondition

func AssertReadyCondition(t *testing.T, conditions []condition.Condition)

AssertReadyCondition checks that the given conditions slice contains a Ready condition.

func AssertServerGeneratedResourceIDMatch

func AssertServerGeneratedResourceIDMatch(t *testing.T, reconciledResourceID string, appliedUnstruct *unstructured.Unstructured)

func AssertUserSpecifiedResourceIDMatch

func AssertUserSpecifiedResourceIDMatch(t *testing.T, reconciledResourceID string, appliedUnstruct *unstructured.Unstructured)

func CollectEvents

func CollectEvents(t *testing.T, config *rest.Config, namespace string, expectedCount int, timeout time.Duration) []v1.Event

Collects an expected number of events from the API server. The timeout is applied on a per-event basis, so it is possible this function takes upwards of expectedCount * timeoutSeconds duration to 'timeout'. When a timeout does occur, t.Fatal(...) is invoked.

func DeleteAllEventsForUnstruct

func DeleteAllEventsForUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured)

func EnsureNamespaceExists

func EnsureNamespaceExists(c client.Client, name string) error

func EnsureNamespaceExistsT

func EnsureNamespaceExistsT(t *testing.T, c client.Client, name string)

func EnsureNamespaceHasProjectIDAnnotation

func EnsureNamespaceHasProjectIDAnnotation(t *testing.T, c client.Client, namespaceName, projectId string)

func GetCRDForKind

func GetCRDForKind(t *testing.T, kubeClient client.Client, kind string) *apiextensions.CustomResourceDefinition

func GetResourceID

func GetResourceID(t *testing.T, resourceUnstruct *unstructured.Unstructured) (string, bool)

func IsResourceIDFieldServerGenerated

func IsResourceIDFieldServerGenerated(rc *v1alpha1.ResourceConfig) bool

TODO(kcc-eng): Clean up all the duplicate IsResourceIDFieldServerGenerated functions.

func Name

func Name(t *testing.T) string

Name returns a suitable name for an object based on the test name.

func ReadFileToBytes

func ReadFileToBytes(t *testing.T, yamlPath string) []byte

func RemoveResourceID

func RemoveResourceID(u *unstructured.Unstructured)

func ReplaceTestVars

func ReplaceTestVars(t *testing.T, b []byte, uniqueId string, project testgcp.GCPProject) []byte

ReplaceTestVars replaces all occurrences of placeholder strings e.g. ${uniqueId} in a given byte slice.

func RunReconcilerAssertResults

func RunReconcilerAssertResults(t *testing.T, reconciler reconcile.Reconciler, objectMeta v1.ObjectMeta,
	expectedResult reconcile.Result, expectedErrorRegex *regexp.Regexp)

RunReconcilerAssertResults asserts the expected state of the reconciler run.

func SetResourceID

func SetResourceID(t *testing.T, u *unstructured.Unstructured, val string)

func SetupNamespaceForDefaultProject

func SetupNamespaceForDefaultProject(t *testing.T, c client.Client, name string)

func SetupNamespaceForProject

func SetupNamespaceForProject(t *testing.T, c client.Client, name, projectID string)

func StartMgr

func StartMgr(t *testing.T, mgr manager.Manager) func()

func StartTestManagerInstance

func StartTestManagerInstance(env *envtest.Environment, testType test.TestType, whCfgs []cnrmwebhook.WebhookConfig) (manager.Manager, func())

StartTestManager begins a new test manager, and returns a function to gracefully shutdown.

func SupportsResourceIDField

func SupportsResourceIDField(rc *v1alpha1.ResourceConfig) bool

TODO(kcc-eng): Clean up all the duplicate SupportsResourceIDField functions.

func UniqueName

func UniqueName(t *testing.T, name string) string

UniqueName takes a name and returns a unique version.

func WaitForUnstructDeleteToFinish

func WaitForUnstructDeleteToFinish(t *testing.T, kubeClient client.Client, origUnstruct *unstructured.Unstructured)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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