framework

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 39 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTokenAuthFile string

DefaultTokenAuthFile returns the default auth tokens file.

Functions

func AdmitWorkspaceAccess added in v0.6.0

func AdmitWorkspaceAccess(ctx context.Context, t *testing.T, kubeClusterClient kcpkubernetesclientset.ClusterInterface, clusterName logicalcluster.Path, users []string, groups []string, admin bool)

AdmitWorkspaceAccess create RBAC rules that allow the given users and/or groups to access the given workspace, optionally as admin.

func ConfigWithToken added in v0.6.0

func ConfigWithToken(token string, cfg *rest.Config) *rest.Config

ConfigWithToken returns a copy of the given rest.Config with the given token set.

func ExportVirtualWorkspaceURLs added in v0.11.0

func ExportVirtualWorkspaceURLs(export *apisv1alpha1.APIExportEndpointSlice) []string

ExportVirtualWorkspaceURLs returns the URLs of the virtual workspaces of the given APIExportEndpointSlice.

func KcpCliPluginCommand added in v0.6.0

func KcpCliPluginCommand(plugin string) (string, []string, error)

KcpCliPluginCommand returns the expected workdir and cli args to run a plugin via go run.

func NewOrganizationFixture deprecated added in v0.6.0

NewOrganizationFixture creates a workspace under root.

Deprecated: use NewWorkspaceFixture with WithType(core.RootCluster.Path(), "organization") instead. There is no organization concept in kcp.

func NewRootShardOrganizationFixture added in v0.27.0

func NewRootShardOrganizationFixture[O kcptesting.WorkspaceOption](t *testing.T, server kcptestingserver.RunningServer, options ...O) (logicalcluster.Path, *tenancyv1alpha1.Workspace)

NewRootShardOrganizationFixture creates an organization workspace on the root shard.

func ReplicationVirtualWorkspaceURLs added in v0.28.0

func ReplicationVirtualWorkspaceURLs(slice *cachev1alpha1.CachedResourceEndpointSlice) []string

ReplicationVirtualWorkspaceURLs returns the URLs of the virtual workspaces of the given CachedResourceEndpointSlice.

func RunKcpCliPlugin added in v0.6.0

func RunKcpCliPlugin(t kcptesting.TestingT, kubeconfigPath string, plugin string, args []string) (*bytes.Buffer, *bytes.Buffer, error)

RunKcpCliPlugin runs the kcp plugin with the provided args and returns stdout and stderr as bytes.Buffer and an error if any. The exitcode can be retreived from the error if it is of type *exec.ExitError.

func StaticTokenUserConfig added in v0.11.0

func StaticTokenUserConfig(username string, cfg *rest.Config) *rest.Config

StaticTokenUserConfig returns a user config based on static user tokens defined in "test/e2e/framework/auth-tokens.csv". The token being used is "[username]-token".

func Suite added in v0.10.0

func Suite(t *testing.T, suite string)

Suite should be called at the very beginning of a test case, to ensure that a test is only run when the suite containing it is selected by the user running tests.

func UniqueGroup added in v0.7.0

func UniqueGroup(suffix string) string

UniqueGroup returns a unique API group with the given suffix by prefixing some random 8 character base36 string. suffix must start with a dot if the random string should be dot-separated.

func VirtualWorkspaceURL added in v0.11.0

func VirtualWorkspaceURL(ctx context.Context, kcpClusterClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace, urls []string) (string, bool, error)

VirtualWorkspaceURL returns the virtual workspace URL base URL of the shard the workspace is scheduled on.

func WithRequiredGroups added in v0.11.0

func WithRequiredGroups(groups ...string) testing2.PrivilegedWorkspaceOption

WithRequiredGroups is a privileged action, so we return a privileged option type, and only the helpers that use the system:master config can consume this. However, workspace initialization requires a valid user annotation on the workspace object to impersonate during initialization, and system:master bypasses setting that, so we end up needing to hard-code something conceivable.

Types

type ArtifactFunc added in v0.6.0

type ArtifactFunc func(*testing.T, func() (runtime.Object, error))

type TestCli added in v0.31.0

type TestCli struct {
	Server         kcptestingserver.RunningServer
	KubeconfigPath string
}

func NewCli added in v0.31.0

func NewCli(t *testing.T) *TestCli

func (*TestCli) RunPlugin added in v0.31.0

func (tc *TestCli) RunPlugin(t *testing.T, plugin string, args ...string) (*bytes.Buffer, *bytes.Buffer, error)

Jump to

Keyboard shortcuts

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