testutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	Timeout  = 30 * time.Second
	Interval = time.Millisecond * 250
)

Variables

This section is empty.

Functions

func CheckLeaderWorkerSetHasCondition

func CheckLeaderWorkerSetHasCondition(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, condition metav1.Condition) (bool, error)

func CheckTPUContainerHasCorrectEnvVars

func CheckTPUContainerHasCorrectEnvVars(pod corev1.Pod, envVal string) error

func CreateLeaderPods

func CreateLeaderPods(ctx context.Context, leaderSts appsv1.StatefulSet, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, start int, end int) error

func CreateWorkerPodsForLeaderPod

func CreateWorkerPodsForLeaderPod(ctx context.Context, leaderPod corev1.Pod, k8sClient client.Client, lws leaderworkerset.LeaderWorkerSet)

func DeleteLeaderPods

func DeleteLeaderPods(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet)

func DeleteNamespace added in v0.2.0

func DeleteNamespace(ctx context.Context, c client.Client, ns *corev1.Namespace) error

DeleteNamespace deletes all objects the tests typically create in the namespace.

func ExpectLeaderSetExist

func ExpectLeaderSetExist(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, k8sClient client.Client)

func ExpectLeaderWorkerSetAvailable

func ExpectLeaderWorkerSetAvailable(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, message string)

func ExpectLeaderWorkerSetNotProgressing

func ExpectLeaderWorkerSetNotProgressing(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, message string)

func ExpectLeaderWorkerSetProgressing

func ExpectLeaderWorkerSetProgressing(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, message string)

func ExpectLeaderWorkerSetStatusReplicas added in v0.2.0

func ExpectLeaderWorkerSetStatusReplicas(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, readyReplicas, updatedReplicas int)

func ExpectLeaderWorkerSetUnavailable added in v0.2.0

func ExpectLeaderWorkerSetUnavailable(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, message string)

func ExpectStatefulsetPartitionEqualTo added in v0.2.0

func ExpectStatefulsetPartitionEqualTo(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, partition int32)

func ExpectValidLeaderStatefulSet

func ExpectValidLeaderStatefulSet(ctx context.Context, leaderWorkerSet *leaderworkerset.LeaderWorkerSet, k8sClient client.Client)

func ExpectValidPods added in v0.2.0

func ExpectValidPods(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, podList *corev1.PodList)

This should only be used in e2e test, since integration test will not automatically create worker pods.

func ExpectValidReplicasCount

func ExpectValidReplicasCount(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, count int, k8sClient client.Client)

func ExpectValidServices

func ExpectValidServices(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet)

func ExpectValidWorkerStatefulSets

func ExpectValidWorkerStatefulSets(ctx context.Context, leaderWorkerSet *leaderworkerset.LeaderWorkerSet, k8sClient client.Client, leaderPodScheduled bool)

func GetLeaderStatefulset added in v0.2.0

func GetLeaderStatefulset(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, k8sClient client.Client, sts *appsv1.StatefulSet)

func GetStatefulSets added in v0.2.0

func GetStatefulSets(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, k8sClient client.Client, stsl *appsv1.StatefulSetList)

func HasTPUEnvVarsPopulated

func HasTPUEnvVarsPopulated(pod corev1.Pod) bool

func MakeLeaderPodSpec

func MakeLeaderPodSpec() corev1.PodSpec

func MakeLeaderPodSpecWithTPUResource

func MakeLeaderPodSpecWithTPUResource() corev1.PodSpec

func MakeWorkerPodSpec

func MakeWorkerPodSpec() corev1.PodSpec

func MakeWorkerPodSpecWithTPUResource

func MakeWorkerPodSpecWithTPUResource() corev1.PodSpec

func MustCreateLws added in v0.2.0

func MustCreateLws(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet)

func SetPodGroupToReady added in v0.2.0

func SetPodGroupToReady(ctx context.Context, k8sClient client.Client, statefulsetName string, lws *leaderworkerset.LeaderWorkerSet)

SetPodGroupToReady set one podGroup(leaderPod+workerStatefulset) of leaderWorkerSet to ready state, workerPods not included.

func SetPodGroupsToReady

func SetPodGroupsToReady(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet)

SetPodGroupsToReady set all podGroups of the leaderWorkerSet to ready state.

func SetStatefulsetToUnReady added in v0.2.0

func SetStatefulsetToUnReady(ctx context.Context, k8sClient client.Client, sts *appsv1.StatefulSet)

SetStatefulsetToUnReady set statefulset to unready.

func UpdateLeaderTemplate added in v0.2.0

func UpdateLeaderTemplate(ctx context.Context, k8sClient client.Client, leaderWorkerSet *leaderworkerset.LeaderWorkerSet)

func UpdateReplicaCount

func UpdateReplicaCount(ctx context.Context, k8sClient client.Client, lws *leaderworkerset.LeaderWorkerSet, count int32)

func UpdateWorkerTemplate added in v0.2.0

func UpdateWorkerTemplate(ctx context.Context, k8sClient client.Client, leaderWorkerSet *leaderworkerset.LeaderWorkerSet)

func ValidateLatestEvent

func ValidateLatestEvent(ctx context.Context, k8sClient client.Client, eventReason string, eventType string, eventNote string, namespace string)

ValidateLatestEvent will return true if the latest event is as you want.

func ValidatePodExclusivePlacementTerms

func ValidatePodExclusivePlacementTerms(pod corev1.Pod) bool

Types

type LeaderWorkerSetWrapper

type LeaderWorkerSetWrapper struct {
	leaderworkerset.LeaderWorkerSet
}

func BuildBasicLeaderWorkerSet

func BuildBasicLeaderWorkerSet(name, ns string) *LeaderWorkerSetWrapper

func BuildLeaderWorkerSet

func BuildLeaderWorkerSet(nsName string) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) Annotation

func (lwsWrapper *LeaderWorkerSetWrapper) Annotation(annotations map[string]string) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) Conditions

func (lwsWrapper *LeaderWorkerSetWrapper) Conditions(conditions []metav1.Condition) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) ExclusivePlacement

func (lwsWrapper *LeaderWorkerSetWrapper) ExclusivePlacement() *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) LeaderTemplateSpec

func (lwsWrapper *LeaderWorkerSetWrapper) LeaderTemplateSpec(spec corev1.PodSpec) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) MaxUnavailable added in v0.2.0

func (lwsWrapper *LeaderWorkerSetWrapper) MaxUnavailable(value int) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) Obj

func (*LeaderWorkerSetWrapper) Replica

func (lwsWrapper *LeaderWorkerSetWrapper) Replica(count int) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) RestartPolicy

func (*LeaderWorkerSetWrapper) RolloutStrategy added in v0.2.0

func (lwsWrapper *LeaderWorkerSetWrapper) RolloutStrategy(strategy leaderworkerset.RolloutStrategy) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) Size

func (lwsWrapper *LeaderWorkerSetWrapper) Size(count int) *LeaderWorkerSetWrapper

func (*LeaderWorkerSetWrapper) WorkerTemplateSpec

func (lwsWrapper *LeaderWorkerSetWrapper) WorkerTemplateSpec(spec corev1.PodSpec) *LeaderWorkerSetWrapper

Jump to

Keyboard shortcuts

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