testhelpers

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeBuildId

func MakeBuildId(twdName, imageName string, podSpec *corev1.PodTemplateSpec) string

MakeBuildId computes a build id based on the image and If no podSpec is provided, defaults to HelloWorldPodSpec with the given image name. If you provide your own podSpec, make sure to give the first container your desired image name if success is expected.

func MakeCurrentVersion

func MakeCurrentVersion(namespace, twdName, imageName string, healthy, createDeployment bool) *temporaliov1alpha1.CurrentWorkerDeploymentVersion

func MakeHelloWorldPodSpec

func MakeHelloWorldPodSpec(imageName string) corev1.PodTemplateSpec

MakeHelloWorldPodSpec creates a pod spec with hello_world task queue and one container with the given image name.

func MakePodSpec

func MakePodSpec(containers []corev1.Container, labels map[string]string, taskQueue string) corev1.PodTemplateSpec

MakePodSpec creates a pod spec. Feel free to add parameters as needed.

func MakeTWDWithImage

func MakeTWDWithImage(name, namespace, imageName string) *temporaliov1alpha1.TemporalWorkerDeployment

func MakeTWDWithName

func MakeTWDWithName(name, namespace string) *temporaliov1alpha1.TemporalWorkerDeployment

func MakeTargetVersion

func MakeTargetVersion(namespace, twdName, imageName string, rampPercentage float32, healthy, createDeployment bool) temporaliov1alpha1.TargetWorkerDeploymentVersion

func MakeVersionId

func MakeVersionId(k8sNamespace, twdName, imageName string) string

MakeVersionId computes a version id based on the image, HelloWorldPodSpec, and k8s namespace.

func ModifyObj

func ModifyObj[T any](obj T, callback func(obj T) T) T

func ProgressiveStep

func ProgressiveStep(rampPercentage float32, pauseDuration time.Duration) temporaliov1alpha1.RolloutStep

ProgressiveStep creates a progressive rollout step

func RunHelloWorldWorker

func RunHelloWorldWorker(ctx context.Context, podTemplateSpec corev1.PodTemplateSpec, callback func(stopFunc func(), err error))

RunHelloWorldWorker runs one worker per replica in the pod spec. callback is a function that can be called multiple times.

Types

type DeprecatedVersionInfo

type DeprecatedVersionInfo struct {
	// contains filtered or unexported fields
}

DeprecatedVersionInfo defines the necessary information about a deprecated worker version, so that tests can recreate state that is not visible in the TemporalWorkerDeployment status

func NewDeprecatedVersionInfo

func NewDeprecatedVersionInfo(image string, replicas int32) DeprecatedVersionInfo

type StatusBuilder

type StatusBuilder struct {
	// contains filtered or unexported fields
}

StatusBuilder provides a fluent interface for building expected status objects Versions will be built based on the TWD name and k8s namespace

func NewStatusBuilder

func NewStatusBuilder() *StatusBuilder

NewStatusBuilder creates a new status builder

func (*StatusBuilder) Build

Build returns the constructed status

func (*StatusBuilder) WithCurrentVersion

func (sb *StatusBuilder) WithCurrentVersion(imageName string, healthy, createDeployment bool) *StatusBuilder

WithCurrentVersion sets the current version in the status

func (*StatusBuilder) WithName

func (sb *StatusBuilder) WithName(name string) *StatusBuilder

WithName sets the name

func (*StatusBuilder) WithNamespace

func (sb *StatusBuilder) WithNamespace(k8sNamespace string) *StatusBuilder

WithNamespace sets the namespace

func (*StatusBuilder) WithTargetVersion

func (sb *StatusBuilder) WithTargetVersion(imageName string, rampPercentage float32, healthy bool, createDeployment bool) *StatusBuilder

WithTargetVersion sets the target version in the status. Target Version is required.

type TemporalWorkerDeploymentBuilder

type TemporalWorkerDeploymentBuilder struct {
	// contains filtered or unexported fields
}

TemporalWorkerDeploymentBuilder provides a fluent interface for building test TWD objects

func NewTemporalWorkerDeploymentBuilder

func NewTemporalWorkerDeploymentBuilder() *TemporalWorkerDeploymentBuilder

NewTemporalWorkerDeploymentBuilder creates a new builder with sensible defaults

func (*TemporalWorkerDeploymentBuilder) Build

Build returns the constructed TemporalWorkerDeployment

func (*TemporalWorkerDeploymentBuilder) WithAllAtOnceStrategy

WithAllAtOnceStrategy sets the rollout strategy to all-at-once

func (*TemporalWorkerDeploymentBuilder) WithCurrentVersionStatus

func (b *TemporalWorkerDeploymentBuilder) WithCurrentVersionStatus(imageName string, healthy, createDeployment bool) *TemporalWorkerDeploymentBuilder

WithCurrentVersionStatus sets the status to have a current version

func (*TemporalWorkerDeploymentBuilder) WithGate

WithGate sets the rollout strategy have a gate workflow

func (*TemporalWorkerDeploymentBuilder) WithLabels

WithLabels sets the labels

func (*TemporalWorkerDeploymentBuilder) WithName

WithName sets the name

func (*TemporalWorkerDeploymentBuilder) WithNamespace

WithNamespace sets the namespace

func (*TemporalWorkerDeploymentBuilder) WithProgressiveStrategy

WithProgressiveStrategy sets the rollout strategy to progressive with given steps

func (*TemporalWorkerDeploymentBuilder) WithReplicas

WithReplicas sets the number of replicas

func (*TemporalWorkerDeploymentBuilder) WithTargetVersionStatus

func (b *TemporalWorkerDeploymentBuilder) WithTargetVersionStatus(imageName string, rampPercentage float32, healthy, createDeployment bool) *TemporalWorkerDeploymentBuilder

WithTargetVersionStatus sets the status to have a target version

func (*TemporalWorkerDeploymentBuilder) WithTemporalConnection

func (b *TemporalWorkerDeploymentBuilder) WithTemporalConnection(connectionName string) *TemporalWorkerDeploymentBuilder

WithTemporalConnection sets the temporal connection name

func (*TemporalWorkerDeploymentBuilder) WithTemporalNamespace

func (b *TemporalWorkerDeploymentBuilder) WithTemporalNamespace(temporalNamespace string) *TemporalWorkerDeploymentBuilder

WithTemporalNamespace sets the temporal namespace

func (*TemporalWorkerDeploymentBuilder) WithVersion

WithVersion sets the worker version (creates HelloWorld pod spec)

type TestCase

type TestCase struct {
	// contains filtered or unexported fields
}

func (*TestCase) GetDeprecatedBuildImages

func (tc *TestCase) GetDeprecatedBuildImages() map[string]string

func (*TestCase) GetDeprecatedBuildReplicas

func (tc *TestCase) GetDeprecatedBuildReplicas() map[string]int32

func (*TestCase) GetExpectedStatus

func (*TestCase) GetTWD

func (*TestCase) GetWaitTime

func (tc *TestCase) GetWaitTime() *time.Duration

type TestCaseBuilder

type TestCaseBuilder struct {
	// contains filtered or unexported fields
}

TestCaseBuilder provides a fluent interface for building test cases

func NewTestCase

func NewTestCase() *TestCaseBuilder

NewTestCase creates a new test case builder

func NewTestCaseWithValues

func NewTestCaseWithValues(name, k8sNamespace, temporalNamespace string) *TestCaseBuilder

NewTestCaseWithValues creates a new test case builder with the given values

func (*TestCaseBuilder) Build

func (tcb *TestCaseBuilder) Build() TestCase

Build returns the constructed test case

func (*TestCaseBuilder) BuildWithValues

func (tcb *TestCaseBuilder) BuildWithValues(name, k8sNamespace, temporalNamespace string) TestCase

BuildWithValues populates all fields affected by test name, k8s namespace, and temporal namespace and returns the constructed test case

func (*TestCaseBuilder) WithDeprecatedBuilds

func (tcb *TestCaseBuilder) WithDeprecatedBuilds(deprecatedVersionInfos ...DeprecatedVersionInfo) *TestCaseBuilder

WithDeprecatedBuilds adds deprecated build replicas and images, indexed by the build id that the given image would result in

func (*TestCaseBuilder) WithExpectedStatus

func (tcb *TestCaseBuilder) WithExpectedStatus(statusBuilder *StatusBuilder) *TestCaseBuilder

WithExpectedStatus sets the expected status

func (*TestCaseBuilder) WithInput

WithInput sets the input TWD

func (*TestCaseBuilder) WithWaitTime

func (tcb *TestCaseBuilder) WithWaitTime(waitTime time.Duration) *TestCaseBuilder

WithWaitTime sets the wait time. Use this if you are expecting no change to the initial status and want to ensure that after some time, there is still no change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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