tests

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceNamespace = "default"
)

Variables

View Source
var (
	UnitNWorkers     = 1
	NWorkers         = 5
	TestWaitDuration = time.Second * 20
)
View Source
var SampleConfigMap = apicorev1.ConfigMap{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-configmap",
		Namespace: ResourceNamespace,
	},
	Immutable: nil,
	Data: map[string]string{
		"a": "A",
		"b": "B",
		"c": "C",
	},
	BinaryData: nil,
}
View Source
var SampleDeployment = apiappsv1.Deployment{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-deployment",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			"app": "test-deployment",
		},
	},
	Spec: apiappsv1.DeploymentSpec{
		Selector: &apimetav1.LabelSelector{
			MatchLabels: map[string]string{
				"app": "test-deployment",
			},
			MatchExpressions: nil,
		},
		Template: apicorev1.PodTemplateSpec{
			ObjectMeta: apimetav1.ObjectMeta{
				Namespace: ResourceNamespace,
				Labels: map[string]string{
					"app": "test-deployment",
				},
			},
			Spec: apicorev1.PodSpec{
				Containers: []apicorev1.Container{
					{
						Name:            "test-container",
						Image:           "alpine:latest",
						Command:         []string{"sh", "-c", "while :; do date '+%F %T %z'; sleep 5; done"},
						ImagePullPolicy: "",
					},
				},
			},
		},
	},
}
View Source
var SampleJob = apibatchv1.Job{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-job",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			// contains filtered or unexported fields
		},
	},
	Spec: apibatchv1.JobSpec{
		Template: apicorev1.PodTemplateSpec{
			ObjectMeta: apimetav1.ObjectMeta{
				Namespace: ResourceNamespace,
			},
			Spec: SamplePodSpec,
		},
	},
}
View Source
var SamplePod = apicorev1.Pod{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-pod",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			// contains filtered or unexported fields
		},
	},
	Spec: SamplePodSpec,
}
View Source
var SamplePodSpec = apicorev1.PodSpec{
	Containers: []apicorev1.Container{
		{
			Name:            "test-container",
			Image:           "alpine:latest",
			Command:         []string{"sh", "-c", "while :; do date '+%F %T %z'; sleep 1; done"},
			ImagePullPolicy: "",
		},
	},
	RestartPolicy: "Never",
}
View Source
var SamplePodWithConfigMapVolume = apicorev1.Pod{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-pod-with-configmap",
		Namespace: ResourceNamespace,
	},
	Spec: apicorev1.PodSpec{
		Containers: []apicorev1.Container{
			{
				Name:            "test-container",
				Image:           "alpine:latest",
				Command:         []string{"sh", "-c", "while :; do date '+%F %T %z'; sleep 1; done"},
				ImagePullPolicy: "",
			},
		},
		RestartPolicy: "Never",
		Volumes: []apicorev1.Volume{
			{
				Name: "sample-config-map",
				VolumeSource: apicorev1.VolumeSource{
					ConfigMap: &apicorev1.ConfigMapVolumeSource{
						LocalObjectReference: apicorev1.LocalObjectReference{
							Name: SampleConfigMap.Name,
						},
						Items: []apicorev1.KeyToPath{
							{
								Key:  "a",
								Path: "a.txt",
							},
						},
					},
				},
			},
		},
	},
}
View Source
var SamplePodWithSecretVolume = apicorev1.Pod{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-pod-with-secret",
		Namespace: ResourceNamespace,
	},
	Spec: apicorev1.PodSpec{
		Containers: []apicorev1.Container{
			{
				Name:            "test-container",
				Image:           "alpine:latest",
				Command:         []string{"sh", "-c", "while :; do date '+%F %T %z'; sleep 1; done"},
				ImagePullPolicy: "",
			},
		},
		RestartPolicy: "Never",
		Volumes: []apicorev1.Volume{
			{
				Name: "sample-config-map",
				VolumeSource: apicorev1.VolumeSource{
					Secret: &apicorev1.SecretVolumeSource{
						SecretName: SampleSecret.Name,
						Items: []apicorev1.KeyToPath{
							{
								Key:  "password",
								Path: "password.txt",
							},
							{
								Key:  "username",
								Path: "username.txt",
							},
						},
					},
				},
			},
		},
	},
}
View Source
var SampleReplicaSet = apiappsv1.ReplicaSet{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-replicaset",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			// contains filtered or unexported fields
		},
	},
	Spec: apiappsv1.ReplicaSetSpec{
		Selector: &apimetav1.LabelSelector{
			MatchLabels: map[string]string{
				"app": "test-replicaset",
			},
			MatchExpressions: nil,
		},
		Template: apicorev1.PodTemplateSpec{
			ObjectMeta: apimetav1.ObjectMeta{
				Namespace: ResourceNamespace,
				Labels: map[string]string{
					"app": "test-replicaset",
				},
			},
			Spec: apicorev1.PodSpec{
				Containers: []apicorev1.Container{
					{
						Name:            "test-container",
						Image:           "alpine:latest",
						Command:         []string{"sh", "-c", "while :; do date '+%F %T %z'; sleep 5; done"},
						ImagePullPolicy: "",
					},
				},
			},
		},
	},
}
View Source
var SampleSecret = apicorev1.Secret{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-secret",
		Namespace: ResourceNamespace,
	},
	StringData: map[string]string{
		"username": "gandalf",
		"password": "mellon",
	},
	Type: apicorev1.SecretTypeOpaque,
}
View Source
var SampleService = apicorev1.Service{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-service",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			"app": "test-service",
			// contains filtered or unexported fields
		},
	},
	Spec: apicorev1.ServiceSpec{
		Ports: []apicorev1.ServicePort{
			{
				Protocol: "TCP",
				Port:     80,
			},
		},
		Selector: map[string]string{
			"app": "test-service",
		},
	},
}
View Source
var SampleServicePod = apicorev1.Pod{
	ObjectMeta: apimetav1.ObjectMeta{
		Name:      "test-service-pod",
		Namespace: ResourceNamespace,
		Labels: map[string]string{
			"app": "test-service",
		},
	},
	Spec: SamplePodSpec,
}

Functions

func AssertLinkGlob

func AssertLinkGlob(t *testing.T, parent string, pattern glob.Glob)

func AssertResource

func AssertResource(t *testing.T, basePath string, resource kubedump.Resource, hasEvents bool)

func AssertResourceIsLinked

func AssertResourceIsLinked(t *testing.T, basePath string, parent kubedump.Resource, linked kubedump.Resource)

func CopyTree

func CopyTree(target string, destination string) error

CopyTree will copy the target directory to the destination directory.

func DeleteOptions

func DeleteOptions() apimetav1.DeleteOptions

func WaitForPath

func WaitForPath(parentContext context.Context, timeout time.Duration, path string) error

WaitForPath will block until a file at the given path exists.

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