Documentation ¶
Index ¶
- Variables
- func AdmitWorkspaceAccess(ctx context.Context, t *testing.T, ...)
- func ClientCAUserConfig(t *testing.T, cfg *rest.Config, clientCAConfigDirectory, username string, ...) *rest.Config
- func Command(executableName, identity string) []string
- func ConfigWithToken(token string, cfg *rest.Config) *rest.Config
- func CreateClientCA(t *testing.T) (string, string)
- func CreateResources(ctx context.Context, fs embed.FS, upstreamConfig *rest.Config, ...) error
- func CreateTempDirForTest(t *testing.T, dirName string) (string, error)
- func Eventually(t *testing.T, condition func() (success bool, reason string), ...)
- func EventuallyCondition(t *testing.T, getter func() (conditions.Getter, error), ...)
- func EventuallyReady(t *testing.T, getter func() (conditions.Getter, error), ...)
- func ExportVirtualWorkspaceURLs(export *apisv1alpha1.APIExport) []string
- func GatherMetrics(ctx context.Context, t *testing.T, server RunningServer, directory string)
- func GetFreePort(t *testing.T) (string, error)
- func InProcessEnvSet() bool
- func KcpCliPluginCommand() []string
- func Kubectl(t *testing.T, kubeconfigPath string, args ...string) []byte
- func KubectlApply(t *testing.T, kubeconfigPath string, input []byte) []byte
- func LoadKubeConfig(kubeconfigPath, contextName string) (clientcmd.ClientConfig, error)
- func LogToConsoleEnvSet() bool
- func LogicalClusterRawConfig(rawConfig clientcmdapi.Config, logicalClusterName logicalcluster.Path, ...) clientcmdapi.Config
- func NewBindCompute(t *testing.T, path logicalcluster.Path, server RunningServer, ...) *bindCompute
- func NewOrganizationFixture(t *testing.T, server RunningServer, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func NewPrivilegedOrganizationFixture[O WorkspaceOption](t *testing.T, server RunningServer, options ...O) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func NewWorkspaceFixture(t *testing.T, server RunningServer, parent logicalcluster.Path, ...) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func NoGoRunEnvSet() bool
- func RepositoryBinDir() string
- func RepositoryDir() string
- func RunDelveEnvSet() bool
- func RunInProcess(o *runOptions)
- func RunKcpCliPlugin(t *testing.T, kubeconfigPath string, subcommand []string) []byte
- func ScrapeMetrics(ctx context.Context, cfg *rest.Config, ...) error
- func ScrapeMetricsForServer(t *testing.T, srv RunningServer)
- func ScratchDirs(t *testing.T) (string, string, error)
- func StartKcpCommand(identity string) []string
- func StaticTokenUserConfig(username string, cfg *rest.Config) *rest.Config
- func Suite(t *testing.T, suite string)
- func TestServerArgs() []string
- func TestServerArgsWithTokenAuthFile(tokenAuthFile string) []string
- func TestServerWithAuditPolicyFile(auditPolicyFile string) []string
- func TestServerWithClientCAFile(clientCAFile string) []string
- func UniqueGroup(suffix string) string
- func VirtualWorkspaceURL(ctx context.Context, kcpClusterClient kcpclientset.ClusterInterface, ...) (string, bool, error)
- func VirtualWorkspaceURLOrDie(t *testing.T, kcpClusterClient kcpclientset.ClusterInterface, ...) string
- func WaitForReady(ctx context.Context, t *testing.T, cfg *rest.Config, keepMonitoring bool) error
- func WithLogStreaming(o *runOptions)
- func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ...) (*corev1alpha1.Shard, error)
- func WorkspaceShardOrDie(t *testing.T, kcpClient kcpclientset.ClusterInterface, ...) *corev1alpha1.Shard
- func WriteEmbedFile(t *testing.T, source string) string
- func WriteLogicalClusterConfig(t *testing.T, rawConfig clientcmdapi.Config, contextName string, ...) (clientcmd.ClientConfig, string)
- func WriteTokenAuthFile(t *testing.T) string
- type Accessory
- type ArtifactFunc
- type BindComputeOption
- func WithAPIExportsWorkloadBindOption(apiexports ...string) BindComputeOption
- func WithLocationSelectorWorkloadBindOption(selectors ...metav1.LabelSelector) BindComputeOption
- func WithLocationWorkspaceWorkloadBindOption(clusterName logicalcluster.Path) BindComputeOption
- func WithNSSelectorWorkloadBindOption(selector metav1.LabelSelector) BindComputeOption
- func WithPlacementNameBindOption(placementName string) BindComputeOption
- type ConditionEvaluator
- type Expectation
- type ExpectationController
- type Expecter
- type KcpConfigOption
- type PrivilegedWorkspaceOption
- type RegisterWorkspaceExpectation
- type RegisterWorkspaceShardExpectation
- type RunOption
- type RunningServer
- type UnprivilegedWorkspaceOption
- func TODO_WithoutMultiShardSupport() UnprivilegedWorkspaceOption
- func WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
- func WithName(s string, formatArgs ...interface{}) UnprivilegedWorkspaceOption
- func WithNameSuffix(suffix string) UnprivilegedWorkspaceOption
- func WithRootShard() UnprivilegedWorkspaceOption
- func WithShard(name string) UnprivilegedWorkspaceOption
- func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption
- type WorkspaceExpectation
- type WorkspaceOption
- type WorkspaceShardExpectation
Constants ¶
This section is empty.
Variables ¶
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 ClientCAUserConfig ¶ added in v0.11.0
func ClientCAUserConfig(t *testing.T, cfg *rest.Config, clientCAConfigDirectory, username string, groups ...string) *rest.Config
ClientCAUserConfig returns a config based on a dynamically created client certificate. The returned client CA is signed by "test/e2e/framework/client-ca.crt".
func Command ¶ added in v0.25.0
Command returns the string tokens required to start the given executable in the currently configured mode (direct or via `go run`).
func ConfigWithToken ¶ added in v0.6.0
func CreateResources ¶ added in v0.11.0
func CreateResources(ctx context.Context, fs embed.FS, upstreamConfig *rest.Config, clusterName logicalcluster.Path, transformers ...helpers.TransformFileFunc) error
CreateResources creates all resources from a filesystem in the given workspace identified by upstreamConfig.
func CreateTempDirForTest ¶
CreateTempDirForTest creates the named directory with a unique base path derived from the name of the current test.
func Eventually ¶ added in v0.6.0
func Eventually(t *testing.T, condition func() (success bool, reason string), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{})
Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick. In addition to require.Eventually, this function t.Logs the reason string value returned by the condition function (eventually after 20% of the wait time) to aid in debugging.
func EventuallyCondition ¶ added in v0.11.0
func EventuallyCondition(t *testing.T, getter func() (conditions.Getter, error), evaluator *ConditionEvaluator, msgAndArgs ...interface{})
EventuallyCondition asserts that the object returned by getter() eventually has a condition that matches the evaluator.
func EventuallyReady ¶ added in v0.6.0
func EventuallyReady(t *testing.T, getter func() (conditions.Getter, error), msgAndArgs ...interface{})
EventuallyReady asserts that the object returned by getter() eventually has a ready condition.
func ExportVirtualWorkspaceURLs ¶ added in v0.11.0
func ExportVirtualWorkspaceURLs(export *apisv1alpha1.APIExport) []string
func GatherMetrics ¶ added in v0.11.0
func GetFreePort ¶
GetFreePort asks the kernel for a free open port that is ready to use.
func InProcessEnvSet ¶
func InProcessEnvSet() bool
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
Kubectl runs kubectl with the given arguments and returns the combined stderr and stdout.
func KubectlApply ¶ added in v0.6.0
KubectlApply runs kubectl apply -f with the supplied input piped to stdin and returns the combined stderr and stdout output.
func LoadKubeConfig ¶ added in v0.11.0
func LoadKubeConfig(kubeconfigPath, contextName string) (clientcmd.ClientConfig, error)
LoadKubeConfig loads a kubeconfig from disk. This method is intended to be common between fixture for servers whose lifecycle is test-managed and fixture for servers whose lifecycle is managed separately from a test run.
func LogToConsoleEnvSet ¶ added in v0.6.0
func LogToConsoleEnvSet() bool
func LogicalClusterRawConfig ¶ added in v0.6.0
func LogicalClusterRawConfig(rawConfig clientcmdapi.Config, logicalClusterName logicalcluster.Path, contextName string) clientcmdapi.Config
LogicalClusterRawConfig returns the raw cluster config of the given config.
func NewBindCompute ¶ added in v0.10.0
func NewBindCompute(t *testing.T, path logicalcluster.Path, server RunningServer, opts ...BindComputeOption) *bindCompute
func NewOrganizationFixture ¶ added in v0.6.0
func NewOrganizationFixture(t *testing.T, server RunningServer, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func NewPrivilegedOrganizationFixture ¶ added in v0.11.0
func NewPrivilegedOrganizationFixture[O WorkspaceOption](t *testing.T, server RunningServer, options ...O) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func NewWorkspaceFixture ¶ added in v0.6.0
func NewWorkspaceFixture(t *testing.T, server RunningServer, parent logicalcluster.Path, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func NoGoRunEnvSet ¶ added in v0.6.0
func NoGoRunEnvSet() bool
func RepositoryBinDir ¶ added in v0.6.0
func RepositoryBinDir() string
RepositoryBinDir returns the absolute path of <repo-dir>/bin. That's where `make build` produces our binaries.
func RepositoryDir ¶ added in v0.6.0
func RepositoryDir() string
RepositoryDir returns the absolute path of <repo-dir>.
func RunDelveEnvSet ¶ added in v0.25.0
func RunDelveEnvSet() bool
func RunInProcess ¶
func RunInProcess(o *runOptions)
func RunKcpCliPlugin ¶ added in v0.6.0
RunKcpCliPlugin runs the kcp workspace plugin with the provided subcommand and returns the combined stderr and stdout output.
func ScrapeMetrics ¶ added in v0.11.0
func ScrapeMetricsForServer ¶ added in v0.11.0
func ScrapeMetricsForServer(t *testing.T, srv RunningServer)
func ScratchDirs ¶
ScratchDirs determines where artifacts and data should live for a test server.
func StartKcpCommand ¶ added in v0.6.0
StartKcpCommand returns the string tokens required to start kcp in the currently configured mode (direct or via `go run`).
func StaticTokenUserConfig ¶ added in v0.11.0
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
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
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
TestServerWithAuditPolicyFile returns the set of kcp args used to start a test server with the given audit policy file.
func TestServerWithClientCAFile ¶ added in v0.11.0
func UniqueGroup ¶ added in v0.7.0
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 WaitForReady ¶ added in v0.11.0
func WithLogStreaming ¶
func WithLogStreaming(o *runOptions)
func WorkspaceShard ¶ added in v0.11.0
func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) (*corev1alpha1.Shard, error)
func WorkspaceShardOrDie ¶ added in v0.11.0
func WorkspaceShardOrDie(t *testing.T, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) *corev1alpha1.Shard
func WriteLogicalClusterConfig ¶ added in v0.6.0
func WriteLogicalClusterConfig(t *testing.T, rawConfig clientcmdapi.Config, contextName string, clusterName logicalcluster.Path) (clientcmd.ClientConfig, string)
WriteLogicalClusterConfig creates a logical cluster config for the given config and cluster name and writes it to the test's artifact path. Useful for configuring the workspace plugin with --kubeconfig.
func WriteTokenAuthFile ¶ added in v0.6.0
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 Accessory ¶
type Accessory struct {
// contains filtered or unexported fields
}
Accessory knows how to run an executable with arguments for the duration of the context.
func NewAccessory ¶
NewAccessory creates a new accessory process.
type ArtifactFunc ¶ added in v0.6.0
type BindComputeOption ¶ added in v0.10.0
func WithAPIExportsWorkloadBindOption ¶ added in v0.10.0
func WithAPIExportsWorkloadBindOption(apiexports ...string) BindComputeOption
func WithLocationSelectorWorkloadBindOption ¶ added in v0.10.0
func WithLocationSelectorWorkloadBindOption(selectors ...metav1.LabelSelector) BindComputeOption
func WithLocationWorkspaceWorkloadBindOption ¶ added in v0.10.0
func WithLocationWorkspaceWorkloadBindOption(clusterName logicalcluster.Path) BindComputeOption
func WithNSSelectorWorkloadBindOption ¶ added in v0.10.0
func WithNSSelectorWorkloadBindOption(selector metav1.LabelSelector) BindComputeOption
func WithPlacementNameBindOption ¶ added in v0.10.0
func WithPlacementNameBindOption(placementName string) BindComputeOption
type ConditionEvaluator ¶ added in v0.11.0
type ConditionEvaluator struct {
// contains filtered or unexported fields
}
func Is ¶ added in v0.11.0
func Is(conditionType conditionsv1alpha1.ConditionType) *ConditionEvaluator
func IsNot ¶ added in v0.11.0
func IsNot(conditionType conditionsv1alpha1.ConditionType) *ConditionEvaluator
func (*ConditionEvaluator) WithReason ¶ added in v0.11.0
func (c *ConditionEvaluator) WithReason(reason string) *ConditionEvaluator
type Expectation ¶
Expectation closes over a statement of intent, allowing the caller to accumulate errors and determine when the expectation should cease to be evaluated.
type ExpectationController ¶ added in v0.6.0
type ExpectationController struct {
// contains filtered or unexported fields
}
ExpectationController knows how to register expectations and trigger them.
func NewExpecter ¶
func NewExpecter(informer cache.SharedIndexInformer) *ExpectationController
NewExpecter creates a informer-driven registry of expectations, which will be triggered on every event that the informer ingests.
func (*ExpectationController) ExpectBefore ¶ added in v0.6.0
func (c *ExpectationController) ExpectBefore(ctx context.Context, expectation Expectation, duration time.Duration) error
type Expecter ¶
type Expecter interface { // ExpectBefore will result in the Expectation being evaluated whenever // state changes, up until the desired timeout is reached. ExpectBefore(context.Context, Expectation, time.Duration) error }
Expecter allows callers to register expectations.
type KcpConfigOption ¶ added in v0.10.0
type KcpConfigOption func(*kcpConfig) *kcpConfig
KcpConfigOption a function that wish to modify a given kcp configuration.
func WithCustomArguments ¶ added in v0.10.0
func WithCustomArguments(args ...string) KcpConfigOption
WithCustomArguments applies provided arguments to a given kcp configuration.
func WithScratchDirectories ¶ added in v0.10.0
func WithScratchDirectories(artifactDir, dataDir string) KcpConfigOption
WithScratchDirectories adds custom scratch directories to a kcp configuration.
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 RegisterWorkspaceExpectation ¶
type RegisterWorkspaceExpectation func(seed *tenancyv1alpha1.Workspace, expectation WorkspaceExpectation) error
RegisterWorkspaceExpectation registers an expectation about the future state of the seed.
func ExpectWorkspaces ¶
func ExpectWorkspaces( ctx context.Context, t *testing.T, client kcpclient.Interface, ) (RegisterWorkspaceExpectation, error)
ExpectWorkspaces sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterWorkspaceShardExpectation ¶
type RegisterWorkspaceShardExpectation func(seed *corev1alpha1.Shard, expectation WorkspaceShardExpectation) error
RegisterWorkspaceShardExpectation registers an expectation about the future state of the seed.
func ExpectWorkspaceShards ¶
func ExpectWorkspaceShards(ctx context.Context, t *testing.T, client kcpclient.Interface) (RegisterWorkspaceShardExpectation, error)
ExpectWorkspaceShards sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RunningServer ¶
type RunningServer interface { Name() string KubeconfigPath() string RawConfig() (clientcmdapi.Config, error) BaseConfig(t *testing.T) *rest.Config RootShardSystemMasterBaseConfig(t *testing.T) *rest.Config ShardSystemMasterBaseConfig(t *testing.T, shard string) *rest.Config ShardNames() []string Artifact(t *testing.T, producer func() (runtime.Object, error)) ClientCAUserConfig(t *testing.T, config *rest.Config, name string, groups ...string) *rest.Config CADirectory() string }
func NewFakeWorkloadServer ¶ added in v0.6.0
func NewFakeWorkloadServer(t *testing.T, server RunningServer, org logicalcluster.Path, syncTargetName string) RunningServer
NewFakeWorkloadServer creates a workspace in the provided server and org and creates a server fixture for the logical cluster that results.
func PrivateKcpServer ¶ added in v0.6.0
func PrivateKcpServer(t *testing.T, options ...KcpConfigOption) RunningServer
PrivateKcpServer returns a new kcp server fixture managing a new server process that is not intended to be shared between tests.
func SharedKcpServer ¶ added in v0.6.0
func SharedKcpServer(t *testing.T) 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.
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 WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
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
func WithType ¶ added in v0.6.0
func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption
type WorkspaceExpectation ¶
type WorkspaceExpectation func(*tenancyv1alpha1.Workspace) error
WorkspaceExpectation evaluates an expectation about the object.
type WorkspaceOption ¶ added in v0.11.0
type WorkspaceOption interface { PrivilegedWorkspaceOption | UnprivilegedWorkspaceOption }
type WorkspaceShardExpectation ¶
type WorkspaceShardExpectation func(*corev1alpha1.Shard) error
WorkspaceShardExpectation evaluates an expectation about the object.