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 ¶
- func InitExternalServer(fn func() (kubeconfigPath string, shardKubeconfigPaths map[string]string))
- func InitSharedKcpServer(opts ...kcptestingserver.Option)
- func NewLowLevelWorkspaceFixture[O WorkspaceOption](t TestingT, createClusterClient, clusterClient kcpclientset.ClusterInterface, ...) *tenancyv1alpha1.Workspace
- func NewWorkspaceFixture(t TestingT, server kcptestingserver.RunningServer, parent logicalcluster.Path, ...) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func PrivateKcpServer(t TestingT, options ...kcptestingserver.Option) kcptestingserver.RunningServer
- func SharedKcpServer(t TestingT) kcptestingserver.RunningServer
- func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ...) (*corev1alpha1.Shard, error)
- func WorkspaceShardOrDie(t TestingT, kcpClient kcpclientset.ClusterInterface, ...) *corev1alpha1.Shard
- type PrivilegedWorkspaceOption
- type SharedKcpOption
- type TestingT
- type UnprivilegedWorkspaceOption
- func WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
- func WithName(s string, formatArgs ...interface{}) UnprivilegedWorkspaceOption
- func WithNamePrefix(prefix string) UnprivilegedWorkspaceOption
- func WithRootShard() UnprivilegedWorkspaceOption
- func WithShard(name string) UnprivilegedWorkspaceOption
- func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption
- type WorkspaceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitExternalServer ¶
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 ¶
func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) (*corev1alpha1.Shard, error)
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 ¶
func WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
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. |