framework

package
v0.27.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 44 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestConfig *testConfig

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

func ExportVirtualWorkspaceURLs added in v0.11.0

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

func KcpCliPluginCommand added in v0.6.0

func KcpCliPluginCommand() []string

KcpCliPluginCommand returns the cli args to run the workspace plugin directly or via go run (depending on whether NO_GORUN is set).

func Kubectl added in v0.6.0

func Kubectl(t *testing.T, kubeconfigPath string, args ...string) []byte

Kubectl runs kubectl with the given arguments and returns the combined stderr and stdout.

func KubectlApply added in v0.6.0

func KubectlApply(t *testing.T, kubeconfigPath string, input []byte) []byte

KubectlApply runs kubectl apply -f with the supplied input piped to stdin and returns the combined stderr and stdout output.

func NewOrganizationFixture added in v0.6.0

func NewPrivilegedOrganizationFixture added in v0.11.0

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

func NewWorkspaceFixture added in v0.6.0

func PrivateKcpServer added in v0.6.0

func PrivateKcpServer(t *testing.T, options ...frameworkserver.Option) frameworkserver.RunningServer

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

func RunKcpCliPlugin added in v0.6.0

func RunKcpCliPlugin(t *testing.T, kubeconfigPath string, subcommand []string) []byte

RunKcpCliPlugin runs the kcp workspace plugin with the provided subcommand and returns the combined stderr and stdout output.

func SharedKcpServer added in v0.6.0

func SharedKcpServer(t *testing.T) frameworkserver.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 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 TestServerArgs added in v0.6.0

func TestServerArgs() []string

TestServerArgs returns the set of kcp args used to start a test server using the token auth file from the working tree.

func TestServerArgsWithTokenAuthFile added in v0.6.0

func TestServerArgsWithTokenAuthFile(tokenAuthFile string) []string

TestServerArgsWithTokenAuthFile returns the set of kcp args used to start a test server with the given token auth file.

func TestServerWithAuditPolicyFile added in v0.9.0

func TestServerWithAuditPolicyFile(auditPolicyFile string) []string

TestServerWithAuditPolicyFile returns the set of kcp args used to start a test server with the given audit policy file.

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)

func VirtualWorkspaceURLOrDie added in v0.11.0

func VirtualWorkspaceURLOrDie(t *testing.T, kcpClusterClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace, urls []string) string

func WorkspaceShard added in v0.11.0

func WorkspaceShardOrDie added in v0.11.0

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

func WriteEmbedFile added in v0.9.0

func WriteEmbedFile(t *testing.T, source string) string

func WriteTokenAuthFile added in v0.6.0

func WriteTokenAuthFile(t *testing.T) string

WriteTokenAuthFile writes the embedded token file to the current test's data dir.

Persistent servers can target the file in the source tree with `--token-auth-file` and test-managed servers can target a file written to a temp path. This avoids requiring a test to know the location of the token file.

TODO(marun) Is there a way to avoid embedding by determining the path to the file during test execution?

Types

type ArtifactFunc added in v0.6.0

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

type PrivilegedWorkspaceOption added in v0.11.0

type PrivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)

func WithRequiredGroups added in v0.11.0

func WithRequiredGroups(groups ...string) 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.

type UnprivilegedWorkspaceOption added in v0.11.0

type UnprivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)

func TODO_WithoutMultiShardSupport added in v0.11.0

func TODO_WithoutMultiShardSupport() UnprivilegedWorkspaceOption

func WithLocation added in v0.11.0

func WithName added in v0.6.0

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

func WithNameSuffix added in v0.11.0

func WithNameSuffix(suffix string) UnprivilegedWorkspaceOption

func WithRootShard added in v0.11.0

func WithRootShard() UnprivilegedWorkspaceOption

func WithShard added in v0.11.0

func WithShard(name string) UnprivilegedWorkspaceOption

type WorkspaceOption added in v0.11.0

type WorkspaceOption interface {
	PrivilegedWorkspaceOption | UnprivilegedWorkspaceOption
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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