util

package
v0.0.0-...-9cb7711 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestNamespaceName     = "test-namespace"
	CronJobNamePrefix     = "cronjob"
	DaemonSetNamePrefix   = "daemonset"
	DeploymentNamePrefix  = "deployment"
	JobNamePrefix         = "job"
	PodNamePrefix         = "pod"
	ReplicaSetNamePrefix  = "replicaset"
	StatefulSetNamePrefix = "statefulset"
)
View Source
const (
	Dash0CustomResourceName = "dash0-test-resource"
)

Variables

View Source
var (
	True  = true
	False = false
)
View Source
var (
	ArbitraryNumer int64 = 1302
)
View Source
var (
	Dash0CustomResourceQualifiedName = types.NamespacedName{
		Namespace: TestNamespaceName,
		Name:      Dash0CustomResourceName,
	}
)

Functions

func AddLabel

func AddLabel(meta *metav1.ObjectMeta, key string, value string)

func AddOptOutLabel

func AddOptOutLabel(meta *metav1.ObjectMeta)

func BasicCronJob

func BasicCronJob(namespace string, name string) *batchv1.CronJob

func BasicDaemonSet

func BasicDaemonSet(namespace string, name string) *appsv1.DaemonSet

func BasicDeployment

func BasicDeployment(namespace string, name string) *appsv1.Deployment

func BasicJob

func BasicJob(namespace string, name string) *batchv1.Job

func BasicPod

func BasicPod(namespace string, name string) *corev1.Pod

func BasicReplicaSet

func BasicReplicaSet(namespace string, name string) *appsv1.ReplicaSet

func BasicStatefulSet

func BasicStatefulSet(namespace string, name string) *appsv1.StatefulSet

func CreateBasicCronJob

func CreateBasicCronJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.CronJob

func CreateBasicDaemonSet

func CreateBasicDaemonSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.DaemonSet

func CreateBasicDeployment

func CreateBasicDeployment(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.Deployment

func CreateBasicJob

func CreateBasicJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.Job

func CreateBasicPod

func CreateBasicPod(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *corev1.Pod

func CreateBasicReplicaSet

func CreateBasicReplicaSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.ReplicaSet

func CreateBasicStatefulSet

func CreateBasicStatefulSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.StatefulSet

func CreateCronJobWithOptOutLabel

func CreateCronJobWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.CronJob

func CreateDaemonSetWithOptOutLabel

func CreateDaemonSetWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.DaemonSet

func CreateDash0CustomResource

func CreateDash0CustomResource(
	ctx context.Context,
	k8sClient client.Client,
	dash0CustomResourceName types.NamespacedName,
) client.Object

func CreateDeploymentWithOptOutLabel

func CreateDeploymentWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.Deployment

func CreateInstrumentedCronJob

func CreateInstrumentedCronJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.CronJob

func CreateInstrumentedDaemonSet

func CreateInstrumentedDaemonSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.DaemonSet

func CreateInstrumentedDeployment

func CreateInstrumentedDeployment(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.Deployment

func CreateInstrumentedJob

func CreateInstrumentedJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.Job

func CreateInstrumentedPod

func CreateInstrumentedPod(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *corev1.Pod

func CreateInstrumentedReplicaSet

func CreateInstrumentedReplicaSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.ReplicaSet

func CreateInstrumentedStatefulSet

func CreateInstrumentedStatefulSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.StatefulSet

func CreateJobForWhichAnInstrumentationAttemptHasFailed

func CreateJobForWhichAnInstrumentationAttemptHasFailed(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.Job

func CreateJobWithOptOutLabel

func CreateJobWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.Job

func CreatePodOwnedByReplicaSet

func CreatePodOwnedByReplicaSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *corev1.Pod

func CreateReplicaSetOwnedByDeployment

func CreateReplicaSetOwnedByDeployment(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.ReplicaSet

func CreateReplicaSetWithOptOutLabel

func CreateReplicaSetWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.ReplicaSet

func CreateStatefulSetWithOptOutLabel

func CreateStatefulSetWithOptOutLabel(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.StatefulSet

func CreateWorkload

func CreateWorkload(ctx context.Context, k8sClient client.Client, workload client.Object) client.Object

func CronJobWithOptOutLabel

func CronJobWithOptOutLabel(namespace string, name string) *batchv1.CronJob

func DaemonSetWithOptOutLabel

func DaemonSetWithOptOutLabel(namespace string, name string) *appsv1.DaemonSet

func DeleteAllCreatedObjects

func DeleteAllCreatedObjects(
	ctx context.Context,
	k8sClient client.Client,
	createdObjects []client.Object,
) []client.Object

func DeleteAllEvents

func DeleteAllEvents(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
)

func DeploymentWithExistingDash0Artifacts

func DeploymentWithExistingDash0Artifacts(namespace string, name string) *appsv1.Deployment

func DeploymentWithMoreBellsAndWhistles

func DeploymentWithMoreBellsAndWhistles(namespace string, name string) *appsv1.Deployment

func DeploymentWithOptOutLabel

func DeploymentWithOptOutLabel(namespace string, name string) *appsv1.Deployment

func EnsureDash0CustomResourceExists

func EnsureDash0CustomResourceExists(
	ctx context.Context,
	k8sClient client.Client,
) *operatorv1alpha1.Dash0

func EnsureDash0CustomResourceExistsAndIsAvailable

func EnsureDash0CustomResourceExistsAndIsAvailable(
	ctx context.Context,
	k8sClient client.Client,
) *operatorv1alpha1.Dash0

func EnsureDash0CustomResourceExistsAndIsAvailableInNamespace

func EnsureDash0CustomResourceExistsAndIsAvailableInNamespace(
	ctx context.Context,
	k8sClient client.Client,
	namespacedName types.NamespacedName,
) *operatorv1alpha1.Dash0

func EnsureDash0CustomResourceExistsAndIsDegraded

func EnsureDash0CustomResourceExistsAndIsDegraded(
	ctx context.Context,
	k8sClient client.Client,
) *operatorv1alpha1.Dash0

func EnsureDash0CustomResourceExistsWithNamespacedName

func EnsureDash0CustomResourceExistsWithNamespacedName(
	ctx context.Context,
	k8sClient client.Client,
	namespacesName types.NamespacedName,
) *operatorv1alpha1.Dash0

func EnsureKubernetesObjectExists

func EnsureKubernetesObjectExists(
	ctx context.Context,
	k8sClient client.Client,
	qualifiedName types.NamespacedName,
	receiver client.Object,
	blueprint client.Object,
) client.Object

func EnsureNamespaceExists

func EnsureNamespaceExists(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
) *corev1.Namespace

func EnsureTestNamespaceExists

func EnsureTestNamespaceExists(
	ctx context.Context,
	k8sClient client.Client,
) *corev1.Namespace

func GetCronJob

func GetCronJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.CronJob

func GetDaemonSet

func GetDaemonSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.DaemonSet

func GetDeployment

func GetDeployment(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.Deployment

func GetDeploymentEventually

func GetDeploymentEventually(
	ctx context.Context,
	k8sClient client.Client,
	g Gomega,
	namespace string,
	name string,
) *appsv1.Deployment

func GetJob

func GetJob(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *batchv1.Job

func GetPod

func GetPod(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *corev1.Pod

func GetReplicaSet

func GetReplicaSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.ReplicaSet

func GetStatefulSet

func GetStatefulSet(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
) *appsv1.StatefulSet

func InstrumentedCronJob

func InstrumentedCronJob(namespace string, name string) *batchv1.CronJob

func InstrumentedDaemonSet

func InstrumentedDaemonSet(namespace string, name string) *appsv1.DaemonSet

func InstrumentedDeployment

func InstrumentedDeployment(namespace string, name string) *appsv1.Deployment

func InstrumentedDeploymentWithMoreBellsAndWhistles

func InstrumentedDeploymentWithMoreBellsAndWhistles(namespace string, name string) *appsv1.Deployment

func InstrumentedJob

func InstrumentedJob(namespace string, name string) *batchv1.Job

func InstrumentedPod

func InstrumentedPod(namespace string, name string) *corev1.Pod

func InstrumentedReplicaSet

func InstrumentedReplicaSet(namespace string, name string) *appsv1.ReplicaSet

func InstrumentedReplicaSetOwnedByDeployment

func InstrumentedReplicaSetOwnedByDeployment(namespace string, name string) *appsv1.ReplicaSet

func InstrumentedStatefulSet

func InstrumentedStatefulSet(namespace string, name string) *appsv1.StatefulSet

func JobForWhichAnInstrumentationAttemptHasFailed

func JobForWhichAnInstrumentationAttemptHasFailed(namespace string, name string) *batchv1.Job

func JobWithOptOutLabel

func JobWithOptOutLabel(namespace string, name string) *batchv1.Job

func LoadDash0CustomResourceByName

func LoadDash0CustomResourceByName(
	ctx context.Context,
	k8sClient client.Client,
	g Gomega,
	dash0CustomResourceName types.NamespacedName,
	failTestsOnNonExists bool,
) *operatorv1alpha1.Dash0

func LoadDash0CustomResourceByNameIfItExists

func LoadDash0CustomResourceByNameIfItExists(
	ctx context.Context,
	k8sClient client.Client,
	g Gomega,
	dash0CustomResourceName types.NamespacedName,
) *operatorv1alpha1.Dash0

func LoadDash0CustomResourceByNameOrFail

func LoadDash0CustomResourceByNameOrFail(
	ctx context.Context,
	k8sClient client.Client,
	g Gomega,
	dash0CustomResourceName types.NamespacedName,
) *operatorv1alpha1.Dash0

func LoadDash0CustomResourceOrFail

func LoadDash0CustomResourceOrFail(ctx context.Context, k8sClient client.Client, g Gomega) *operatorv1alpha1.Dash0

func MatchEnvVar

func MatchEnvVar(name string, value string, args ...interface{}) gomega.OmegaMatcher

func MatchEvent

func MatchEvent(
	namespace string,
	resourceName string,
	reason util.Reason,
	message string,
	args ...interface{},
) gomega.OmegaMatcher

func MatchVolumeMount

func MatchVolumeMount(name string, mountPath string, args ...interface{}) gomega.OmegaMatcher

func Namespace

func Namespace(name string) *corev1.Namespace

func PodOwnedByReplicaSet

func PodOwnedByReplicaSet(namespace string, name string) *corev1.Pod

func PodWithOptOutLabel

func PodWithOptOutLabel(namespace string, name string) *corev1.Pod

func RemoveDash0CustomResource

func RemoveDash0CustomResource(ctx context.Context, k8sClient client.Client)

func RemoveDash0CustomResourceByName

func RemoveDash0CustomResourceByName(
	ctx context.Context,
	k8sClient client.Client,
	dash0CustomResourceName types.NamespacedName,
	failOnErr bool,
)

func RemoveLabel

func RemoveLabel(meta *metav1.ObjectMeta, key string)

func RemoveOptOutLabel

func RemoveOptOutLabel(meta *metav1.ObjectMeta)

func ReplicaSetOwnedByDeployment

func ReplicaSetOwnedByDeployment(namespace string, name string) *appsv1.ReplicaSet

func ReplicaSetWithOptOutLabel

func ReplicaSetWithOptOutLabel(namespace string, name string) *appsv1.ReplicaSet

func StatefulSetWithOptOutLabel

func StatefulSetWithOptOutLabel(namespace string, name string) *appsv1.StatefulSet

func UniqueName

func UniqueName(prefix string) string

func UpdateLabel

func UpdateLabel(meta *metav1.ObjectMeta, key string, value string)

func UpdateWorkload

func UpdateWorkload(ctx context.Context, k8sClient client.Client, workload client.Object) client.Object

func VerifyCronJobWithOptOutLabel

func VerifyCronJobWithOptOutLabel(resource *batchv1.CronJob)

func VerifyDaemonSetWithOptOutLabel

func VerifyDaemonSetWithOptOutLabel(resource *appsv1.DaemonSet)

func VerifyDash0CustomResourceByNameDoesNotExist

func VerifyDash0CustomResourceByNameDoesNotExist(
	ctx context.Context,
	k8sClient client.Client,
	g Gomega,
	dash0CustomResourceName types.NamespacedName,
)

func VerifyDeploymentWithOptOutLabel

func VerifyDeploymentWithOptOutLabel(resource *appsv1.Deployment)

func VerifyFailedInstrumentationEvent

func VerifyFailedInstrumentationEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	message string,
)

func VerifyFailedUninstrumentationEvent

func VerifyFailedUninstrumentationEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	message string,
)

func VerifyImmutableJobCouldNotBeModified

func VerifyImmutableJobCouldNotBeModified(resource *batchv1.Job)

func VerifyJobWithOptOutLabel

func VerifyJobWithOptOutLabel(resource *batchv1.Job)

func VerifyModifiedCronJob

func VerifyModifiedCronJob(resource *batchv1.CronJob, expectations PodSpecExpectations)

func VerifyModifiedDaemonSet

func VerifyModifiedDaemonSet(resource *appsv1.DaemonSet, expectations PodSpecExpectations)

func VerifyModifiedDeployment

func VerifyModifiedDeployment(resource *appsv1.Deployment, expectations PodSpecExpectations)

func VerifyModifiedJob

func VerifyModifiedJob(resource *batchv1.Job, expectations PodSpecExpectations)

func VerifyModifiedJobAfterUnsuccessfulOptOut

func VerifyModifiedJobAfterUnsuccessfulOptOut(resource *batchv1.Job)

func VerifyModifiedPod

func VerifyModifiedPod(resource *corev1.Pod, expectations PodSpecExpectations)

func VerifyModifiedReplicaSet

func VerifyModifiedReplicaSet(resource *appsv1.ReplicaSet, expectations PodSpecExpectations)

func VerifyModifiedStatefulSet

func VerifyModifiedStatefulSet(resource *appsv1.StatefulSet, expectations PodSpecExpectations)

func VerifyNoEvents

func VerifyNoEvents(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
)

func VerifyNoInstrumentationNecessaryEvent

func VerifyNoInstrumentationNecessaryEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	eventSource string,
)

func VerifyNoUninstrumentationNecessaryEvent

func VerifyNoUninstrumentationNecessaryEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	message string,
)

func VerifyPodWithOptOutLabel

func VerifyPodWithOptOutLabel(resource *corev1.Pod)

func VerifyReplicaSetWithOptOutLabel

func VerifyReplicaSetWithOptOutLabel(resource *appsv1.ReplicaSet)

func VerifyRevertedDeployment

func VerifyRevertedDeployment(resource *appsv1.Deployment, expectations PodSpecExpectations)

func VerifyStatefulSetWithOptOutLabel

func VerifyStatefulSetWithOptOutLabel(resource *appsv1.StatefulSet)

func VerifySuccessfulInstrumentationEvent

func VerifySuccessfulInstrumentationEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	eventSource string,
)

func VerifySuccessfulUninstrumentationEvent

func VerifySuccessfulUninstrumentationEvent(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	namespace string,
	resourceName string,
	eventSource string,
)

func VerifySuccessfulUninstrumentationEventEventually

func VerifySuccessfulUninstrumentationEventEventually(
	ctx context.Context,
	clientset *kubernetes.Clientset,
	g Gomega,
	namespace string,
	resourceName string,
	eventSource string,
)

func VerifyUnmodifiedCronJob

func VerifyUnmodifiedCronJob(resource *batchv1.CronJob)

func VerifyUnmodifiedDaemonSet

func VerifyUnmodifiedDaemonSet(resource *appsv1.DaemonSet)

func VerifyUnmodifiedDeployment

func VerifyUnmodifiedDeployment(resource *appsv1.Deployment)

func VerifyUnmodifiedDeploymentEventually

func VerifyUnmodifiedDeploymentEventually(g Gomega, resource *appsv1.Deployment)

func VerifyUnmodifiedJob

func VerifyUnmodifiedJob(resource *batchv1.Job)

func VerifyUnmodifiedPod

func VerifyUnmodifiedPod(resource *corev1.Pod)

func VerifyUnmodifiedReplicaSet

func VerifyUnmodifiedReplicaSet(resource *appsv1.ReplicaSet)

func VerifyUnmodifiedStatefulSet

func VerifyUnmodifiedStatefulSet(resource *appsv1.StatefulSet)

func VerifyWebhookIgnoreOnceLabelIsAbesent

func VerifyWebhookIgnoreOnceLabelIsAbesent(objectMeta *metav1.ObjectMeta)

func VerifyWebhookIgnoreOnceLabelIsPresent

func VerifyWebhookIgnoreOnceLabelIsPresent(objectMeta *metav1.ObjectMeta)

func VerifyWebhookIgnoreOnceLabelIsPresentEventually

func VerifyWebhookIgnoreOnceLabelIsPresentEventually(g Gomega, objectMeta *metav1.ObjectMeta)

Types

type ContainerExpectations

type ContainerExpectations struct {
	VolumeMounts                             int
	Dash0VolumeMountIdx                      int
	EnvVars                                  int
	NodeOptionsEnvVarIdx                     int
	NodeOptionsValue                         string
	NodeOptionsUsesValueFrom                 bool
	Dash0CollectorBaseUrlEnvVarIdx           int
	Dash0CollectorBaseUrlEnvVarExpectedValue string
}

type MatchEnvVarMatcher

type MatchEnvVarMatcher struct {
	Name  string
	Value string
	Args  []interface{}
}

func (*MatchEnvVarMatcher) FailureMessage

func (matcher *MatchEnvVarMatcher) FailureMessage(actual interface{}) (message string)

func (*MatchEnvVarMatcher) Match

func (matcher *MatchEnvVarMatcher) Match(actual interface{}) (success bool, err error)

func (*MatchEnvVarMatcher) NegatedFailureMessage

func (matcher *MatchEnvVarMatcher) NegatedFailureMessage(actual interface{}) (message string)

type MatchEventMatcher

type MatchEventMatcher struct {
	Namespace    string
	ResourceName string
	Reason       string
	Message      string
	Args         []interface{}
}

func (*MatchEventMatcher) FailureMessage

func (matcher *MatchEventMatcher) FailureMessage(actual interface{}) (message string)

func (*MatchEventMatcher) Match

func (matcher *MatchEventMatcher) Match(actual interface{}) (success bool, err error)

func (*MatchEventMatcher) NegatedFailureMessage

func (matcher *MatchEventMatcher) NegatedFailureMessage(actual interface{}) (message string)

type MatchVolumeMountMatcher

type MatchVolumeMountMatcher struct {
	Name      string
	MountPath string
	Args      []interface{}
}

func (*MatchVolumeMountMatcher) FailureMessage

func (matcher *MatchVolumeMountMatcher) FailureMessage(actual interface{}) (message string)

func (*MatchVolumeMountMatcher) Match

func (matcher *MatchVolumeMountMatcher) Match(actual interface{}) (success bool, err error)

func (*MatchVolumeMountMatcher) NegatedFailureMessage

func (matcher *MatchVolumeMountMatcher) NegatedFailureMessage(actual interface{}) (message string)

type PodSpecExpectations

type PodSpecExpectations struct {
	Volumes               int
	Dash0VolumeIdx        int
	InitContainers        int
	Dash0InitContainerIdx int
	Containers            []ContainerExpectations
}

func BasicInstrumentedPodSpecExpectations

func BasicInstrumentedPodSpecExpectations() PodSpecExpectations

Jump to

Keyboard shortcuts

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