Documentation ¶
Index ¶
- Variables
- func AdmitWorkspaceAccess(t *testing.T, ctx context.Context, ...)
- func ConfigWithToken(token string, cfg *rest.Config) *rest.Config
- func CreateTempDirForTest(t *testing.T, dirName string) (string, error)
- func DirectOrGoRunCommand(executableName string) []string
- func Eventually(t *testing.T, condition func() (success bool, reason string), ...)
- func EventuallyReady(t *testing.T, getter func() (conditions.Getter, error), ...)
- 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 LogToConsoleEnvSet() bool
- func LogicalClusterRawConfig(rawConfig clientcmdapi.Config, logicalClusterName logicalcluster.Name, ...) clientcmdapi.Config
- func NewOrganizationFixture(t *testing.T, server RunningServer, options ...ClusterWorkspaceOption) (orgClusterName logicalcluster.Name)
- func NewSyncerFixture(t *testing.T, server RunningServer, clusterName logicalcluster.Name, ...) *syncerFixture
- func NewWorkspaceFixture(t *testing.T, server RunningServer, orgClusterName logicalcluster.Name, ...) (clusterName logicalcluster.Name)
- func NoGoRunEnvSet() bool
- func Ready(ctx context.Context, t *testing.T, port string) bool
- func RepositoryBinDir() string
- func RepositoryDir() string
- func RunInProcess(o *runOptions)
- func RunKcpCliPlugin(t *testing.T, kubeconfigPath string, subcommand []string) []byte
- func ScratchDirs(t *testing.T) (string, string, error)
- func ShardConfig(t *testing.T, kcpClusterClient kcpclient.Interface, shardName string, ...) *rest.Config
- func StartKcpCommand() []string
- func TestServerArgs() []string
- func TestServerArgsWithTokenAuthFile(tokenAuthFile string) []string
- func UniqueGroup(suffix string) string
- func UserConfig(username string, cfg *rest.Config) *rest.Config
- func WithLogStreaming(o *runOptions)
- func WriteLogicalClusterConfig(t *testing.T, rawConfig clientcmdapi.Config, contextName string, ...) (clientcmd.ClientConfig, string)
- func WriteTokenAuthFile(t *testing.T) string
- type Accessory
- type ArtifactFunc
- type ClusterWorkspaceExpectation
- type ClusterWorkspaceOption
- type Expectation
- type ExpectationController
- type Expecter
- type RegisterClusterWorkspaceExpectation
- type RegisterWorkspaceShardExpectation
- type RunOption
- type RunningServer
- type StartedSyncerFixture
- type SyncTargetOption
- type SyncerOption
- type WorkspaceShardExpectation
Constants ¶
This section is empty.
Variables ¶
var TestConfig *testConfig
Functions ¶
func AdmitWorkspaceAccess ¶ added in v0.6.0
func AdmitWorkspaceAccess(t *testing.T, ctx context.Context, kubeClusterClient kubernetesclient.Interface, orgClusterName logicalcluster.Name, users []string, groups []string, verbs []string)
AdmitWorkspaceAccess create RBAC rules that allow the given users and/or groups to access the given, fully-qualified workspace, i.e. the RBAC objects are create in its parent.
func ConfigWithToken ¶ added in v0.6.0
func CreateTempDirForTest ¶
CreateTempDirForTest creates the named directory with a unique base path derived from the name of the current test.
func DirectOrGoRunCommand ¶ added in v0.6.0
DirectOrGoRunCommand returns the string tokens required to start the given executable in the currently configured mode (direct or via `go run`).
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 raason string value returned by the condition function (eventually after 20% of the wait time) to aid in debugging.
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 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 LogToConsoleEnvSet ¶ added in v0.6.0
func LogToConsoleEnvSet() bool
func LogicalClusterRawConfig ¶ added in v0.6.0
func LogicalClusterRawConfig(rawConfig clientcmdapi.Config, logicalClusterName logicalcluster.Name, contextName string) clientcmdapi.Config
LogicalClusterRawConfig returns the raw cluster config of the given config.
func NewOrganizationFixture ¶ added in v0.6.0
func NewOrganizationFixture(t *testing.T, server RunningServer, options ...ClusterWorkspaceOption) (orgClusterName logicalcluster.Name)
func NewSyncerFixture ¶ added in v0.7.0
func NewSyncerFixture(t *testing.T, server RunningServer, clusterName logicalcluster.Name, opts ...SyncerOption) *syncerFixture
func NewWorkspaceFixture ¶ added in v0.6.0
func NewWorkspaceFixture(t *testing.T, server RunningServer, orgClusterName logicalcluster.Name, options ...ClusterWorkspaceOption) (clusterName logicalcluster.Name)
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 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 ScratchDirs ¶
ScratchDirs determines where artifacts and data should live for a test server.
func ShardConfig ¶ added in v0.6.0
func ShardConfig(t *testing.T, kcpClusterClient kcpclient.Interface, shardName string, cfg *rest.Config) *rest.Config
ShardConfig returns a rest config that talk directly to the given shard.
func StartKcpCommand ¶ added in v0.6.0
func StartKcpCommand() []string
StartKcpCommand returns the string tokens required to start kcp in the currently configured mode (direct or via `go run`).
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 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 WithLogStreaming ¶
func WithLogStreaming(o *runOptions)
func WriteLogicalClusterConfig ¶ added in v0.6.0
func WriteLogicalClusterConfig(t *testing.T, rawConfig clientcmdapi.Config, contextName string, clusterName logicalcluster.Name) (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 ClusterWorkspaceExpectation ¶ added in v0.6.0
type ClusterWorkspaceExpectation func(*tenancyv1alpha1.ClusterWorkspace) error
ClusterWorkspaceExpectation evaluates an expectation about the object.
type ClusterWorkspaceOption ¶ added in v0.6.0
type ClusterWorkspaceOption func(ws *tenancyv1alpha1.ClusterWorkspace)
func WithName ¶ added in v0.6.0
func WithName(s string, formatArgs ...interface{}) ClusterWorkspaceOption
func WithShardConstraints ¶ added in v0.6.0
func WithShardConstraints(c tenancyv1alpha1.ShardConstraints) ClusterWorkspaceOption
func WithType ¶ added in v0.6.0
func WithType(path logicalcluster.Name, name tenancyv1alpha1.ClusterWorkspaceTypeName) ClusterWorkspaceOption
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 RegisterClusterWorkspaceExpectation ¶ added in v0.6.0
type RegisterClusterWorkspaceExpectation func(seed *tenancyv1alpha1.ClusterWorkspace, expectation ClusterWorkspaceExpectation) error
RegisterClusterWorkspaceExpectation registers an expectation about the future state of the seed.
func ExpectClusterWorkspaces ¶ added in v0.6.0
func ExpectClusterWorkspaces(ctx context.Context, t *testing.T, client kcpclient.Interface) (RegisterClusterWorkspaceExpectation, error)
ExpectClusterWorkspaces sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterWorkspaceShardExpectation ¶
type RegisterWorkspaceShardExpectation func(seed *tenancyv1alpha1.ClusterWorkspaceShard, 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 Artifact(t *testing.T, producer func() (runtime.Object, error)) }
func NewFakeWorkloadServer ¶ added in v0.6.0
func NewFakeWorkloadServer(t *testing.T, server RunningServer, org logicalcluster.Name) 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, args ...string) 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 StartedSyncerFixture ¶ added in v0.6.0
type StartedSyncerFixture struct { SyncerConfig *syncer.SyncerConfig // Provide cluster-admin config and client for test purposes. The downstream config in // SyncerConfig will be less privileged. DownstreamConfig *rest.Config DownstreamKubeClient kubernetesclient.Interface }
StartedSyncerFixture contains the configuration used to start a syncer and interact with its downstream cluster.
func (*StartedSyncerFixture) WaitForClusterReady ¶ added in v0.7.0
func (sf *StartedSyncerFixture) WaitForClusterReady(t *testing.T, ctx context.Context)
WaitForClusterReady waits for the cluster to be ready with the given reason.
type SyncTargetOption ¶ added in v0.6.0
type SyncTargetOption func(cluster *workloadv1alpha1.SyncTarget)
type SyncerOption ¶ added in v0.7.0
func WithDownstreamPreparation ¶ added in v0.7.0
func WithDownstreamPreparation(prepare func(config *rest.Config, isFakePCluster bool)) SyncerOption
func WithExtraResources ¶ added in v0.7.0
func WithExtraResources(resources ...string) SyncerOption
func WithSyncTarget ¶ added in v0.7.0
func WithSyncTarget(clusterName logicalcluster.Name, name string) SyncerOption
type WorkspaceShardExpectation ¶
type WorkspaceShardExpectation func(*tenancyv1alpha1.ClusterWorkspaceShard) error
WorkspaceShardExpectation evaluates an expectation about the object.