framework

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 43 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ParallelSuite = "parallel-suite"

ParallelSuite is the suite of the tests that run against the server brought up by the e2e targets (SharedKcpServer), in parallel with each other. Tests that start a server of their own belong to the SerialSuite instead. It is selected by default together with the cli suite; the SerialSuite is not.

View Source
const SerialSuite = "serial"

SerialSuite is the suite of tests that do not run against the shared server: they start a server of their own, with PrivateKcpServer when a single shard with specific flags is enough, or with PrivateShardedKcpServer when they need several shards, e.g. because they rotate the identities of kcp's core APIs, migrate logical clusters or otherwise disrupt every workspace. The suite runs one test at a time: the e2e targets run it with -p 1 -parallel 1 after the parallel suites, once the shared server is stopped (make test-e2e-serial).

View Source
const TestFeatureGates = "WorkspaceMounts=true,CacheAPIs=true,WorkspaceAuthentication=true,LogicalClusterMigration=true"

TestFeatureGates are the feature gates the e2e servers run with: the shared server, private servers and private sharded servers alike.

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 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 PrivateShardedKcpServer added in v0.34.0

func PrivateShardedKcpServer(t *testing.T, shards int) kcptestingserver.RunningServer

PrivateShardedKcpServer starts a sharded-test-server, i.e. a cache server, the given number of shards and a front-proxy, for this test alone and stops it when the test ends. Shards are named like the e2e targets name them: "root", "shard-1", ... The returned server is addressed through the front-proxy; ShardSystemMasterBaseConfig reaches the individual shards.

sharded-test-server listens on fixed ports, so only one can run at a time: this is for tests of the SerialSuite. Tests using it must not call t.Parallel(): -parallel 1 does not keep them apart, because a parallel test with parallel subtests hands its slot to the next test while its server is still running. Sequential tests are isolated, including their subtests and cleanups. A second server in the same test binary fails the test instead of waiting, which would deadlock; across packages the serial e2e target runs with -p 1.

func ReplicationVirtualWorkspaceURLs added in v0.28.0

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

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

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, cfg *rest.Config, 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.

func WriteWorkspaceKubeconfig added in v0.34.0

func WriteWorkspaceKubeconfig(t *testing.T, server kcptestingserver.RunningServer, wsPath logicalcluster.Path, dir string) string

WriteWorkspaceKubeconfig writes a kubeconfig for wsPath to dir and returns its path.

Types

type ArtifactFunc added in v0.6.0

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

type AuthzWebhook added in v0.34.0

type AuthzWebhook struct {
	// Handler is the decision handler. Can be swapped at runtime.
	Handler *server.AuthzHandler
	// Args are the kcp shard arguments wiring this webhook in.
	Args []string
}

AuthzWebhook is an in-process authorization webhook.

func StartAuthzWebhook added in v0.34.0

func StartAuthzWebhook(ctx context.Context, t kcptesting.TestingT, fn server.AuthzHandlerFunc) *AuthzWebhook

StartAuthzWebhook serves fn as an authorization webhook over TLS on an ephemeral port.

Jump to

Keyboard shortcuts

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