testing

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package testing provides utilities for testing of and against KCP. This code to be used outside of the KCP repository is experimental and subject to change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitExternalServer

func InitExternalServer(fn func() (kubeconfigPath string, shardKubeconfigPaths map[string]string))

InitExternalServer configures a potentially pre-existing shared external kcp server. It must be called before SharedKcpServer is called. The shard kubeconfigs are optional, but the kubeconfigPath must be provided.

func InitSharedKcpServer

func InitSharedKcpServer(opts ...kcptestingserver.Option)

InitSharedKcpServer initializes a shared kcp server fixture. It must be called before SharedKcpServer is called.

func NewLowLevelWorkspaceFixture

func NewLowLevelWorkspaceFixture[O WorkspaceOption](t TestingT, createClusterClient, clusterClient kcpclientset.ClusterInterface, parent logicalcluster.Path, options ...O) *tenancyv1alpha1.Workspace

NewLowLevelWorkspaceFixture creates a new workspace under the given parent using the given client. Don't use this if NewWorkspaceFixture can be used.

func NewWorkspaceFixture

func NewWorkspaceFixture(t TestingT, server kcptestingserver.RunningServer, parent logicalcluster.Path, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)

NewWorkspaceFixture creates a new workspace under the given parent.

func PrivateKcpServer

func PrivateKcpServer(t TestingT, options ...kcptestingserver.Option) kcptestingserver.RunningServer

PrivateKcpServer returns a new kcp server fixture managing a new server process that is not intended to be shared between tests.

func SharedKcpServer

func SharedKcpServer(t TestingT) kcptestingserver.RunningServer

SharedKcpServer returns a kcp server fixture intended to be shared between tests. A persistent server will be configured if `--kcp-kubeconfig` or `--use-default-kcp-server` is supplied to the test runner. Otherwise a test-managed server will be started. Only tests that are known to be hermetic are compatible with shared fixture.

func WorkspaceShard

WorkspaceShard returns the shard that a workspace is scheduled on.

func WorkspaceShardOrDie

func WorkspaceShardOrDie(t TestingT, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) *corev1alpha1.Shard

WorkspaceShardOrDie returns the shard that a workspace is scheduled on, or fails the test on error.

Types

type PrivilegedWorkspaceOption

type PrivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)

PrivilegedWorkspaceOption is an option that requires system:master permissions.

type SharedKcpOption

type SharedKcpOption func()

SharedKcpOption is a function that can be used to configure the shared kcp server.

type TestingT

type TestingT interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
	Name() string
	TempDir() string
}

TestingT is implemented by *testing.T and potentially other test frameworks.

type UnprivilegedWorkspaceOption

type UnprivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)

UnprivilegedWorkspaceOption is an option that does not require system:master permissions.

func WithLocation

WithLocation sets the location of the workspace.

func WithName

func WithName(s string, formatArgs ...interface{}) UnprivilegedWorkspaceOption

WithName sets the name of the workspace.

func WithNamePrefix

func WithNamePrefix(prefix string) UnprivilegedWorkspaceOption

WithNamePrefix make the workspace be named with the given prefix plus "-".

func WithRootShard

func WithRootShard() UnprivilegedWorkspaceOption

WithRootShard schedules the workspace on the root shard.

func WithShard

func WithShard(name string) UnprivilegedWorkspaceOption

WithShard schedules the workspace on the given shard.

func WithType

func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption

WithType sets the type of the workspace.

type WorkspaceOption

type WorkspaceOption interface {
	PrivilegedWorkspaceOption | UnprivilegedWorkspaceOption
}

WorkspaceOption is an option for creating a workspace.

Directories

Path Synopsis
third_party
library-go/crypto
this is copied from https://github.com/openshift/library-go/tree/master/pkg/crypto.
this is copied from https://github.com/openshift/library-go/tree/master/pkg/crypto.

Jump to

Keyboard shortcuts

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