Documentation
¶
Index ¶
- Variables
- func AdmitWorkspaceAccess(t *testing.T, ctx context.Context, ...)
- func CompareWithFixture(t *testing.T, output interface{}, opts ...Option)
- func CreateTempDirForTest(t *testing.T, dirName string) (string, error)
- func CreateWorkloadCluster(t *testing.T, artifacts ArtifactFunc, kcpClient kcpclientset.Interface, ...) (*workloadv1alpha1.WorkloadCluster, error)
- func DirectOrGoRunCommand(executableName string) []string
- func GetFreePort(t *testing.T) (string, error)
- func InProcessEnvSet() bool
- func LogToConsoleEnvSet() bool
- func LogicalClusterConfig(rawConfig *clientcmdapi.Config, ...) clientcmd.ClientConfig
- func NewExpecter(informer cache.SharedIndexInformer) *expectationController
- func NewOrganizationFixture(t *testing.T, server RunningServer) (orgClusterName logicalcluster.LogicalCluster)
- func NewPollingExpecter(interval time.Duration) *expectationController
- func NewWorkspaceFixture(t *testing.T, server RunningServer, ...) (clusterName logicalcluster.LogicalCluster)
- func NewWorkspaceWithWorkloads(t *testing.T, server RunningServer, ...) (clusterName logicalcluster.LogicalCluster)
- func NoGoRunEnvSet() bool
- func ReadFromFixture(t *testing.T, identifier string) []byte
- func Ready(ctx context.Context, t *testing.T, port string) bool
- func RepositoryBinDir() string
- func RepositoryDir() string
- func RequireDiff(t *testing.T, x, y interface{}, msgAndArgs ...interface{})
- func RequireNoDiff(t *testing.T, x, y interface{}, msgAndArgs ...interface{})
- func RunInProcess(o *runOptions)
- func ScratchDirs(t *testing.T) (string, string, error)
- func StartKcpCommand() []string
- func StartWorkspaceSyncer(t *testing.T, ctx context.Context, resources sets.String, ...)
- func TestServerArgs() []string
- func TestServerArgsWithTokenAuthFile(tokenAuthFile string) []string
- func WithLogStreaming(o *runOptions)
- func WriteToFixture(t *testing.T, identifier string, data []byte)
- func WriteTokenAuthFile(t *testing.T) string
- type Accessory
- type ArtifactFunc
- type ClusterWorkspaceExpectation
- type ClusterWorkspaceListExpectation
- type Expectation
- type Expecter
- type Option
- type Options
- type RegisterClusterWorkspaceExpectation
- type RegisterClusterWorkspaceListExpectation
- type RegisterWorkspaceExpectation
- type RegisterWorkspaceListExpectation
- type RegisterWorkspaceShardExpectation
- type RunOption
- type RunningServer
- type User
- type WorkspaceExpectation
- type WorkspaceListExpectation
- 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 kubernetes.ClusterInterface, orgClusterName logicalcluster.LogicalCluster, 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 CompareWithFixture ¶
CompareWithFixture will compare output with a test fixture and allows to automatically update them by setting the UPDATE env var. If output is not a []byte or string, it will get serialized as yaml prior to the comparison. The fixtures are stored in $PWD/testdata/prefix${testName}.yaml
func CreateTempDirForTest ¶
createTempDirForTest creates the named directory with a unique base path derived from the name of the current test.
func CreateWorkloadCluster ¶
func CreateWorkloadCluster(t *testing.T, artifacts ArtifactFunc, kcpClient kcpclientset.Interface, pcluster RunningServer) (*workloadv1alpha1.WorkloadCluster, error)
CreateWorkloadCluster creates a new WorkloadCluster resource with the desired name on a given server.
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 GetFreePort ¶
GetFreePort asks the kernel for a free open port that is ready to use.
func InProcessEnvSet ¶
func InProcessEnvSet() bool
func LogToConsoleEnvSet ¶ added in v0.6.0
func LogToConsoleEnvSet() bool
func LogicalClusterConfig ¶
func LogicalClusterConfig(rawConfig *clientcmdapi.Config, logicalClusterName logicalcluster.LogicalCluster) clientcmd.ClientConfig
LogicalClusterConfig returns the logical cluster context of the given config.
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 NewOrganizationFixture ¶ added in v0.6.0
func NewOrganizationFixture(t *testing.T, server RunningServer) (orgClusterName logicalcluster.LogicalCluster)
func NewPollingExpecter ¶
NewPollingExpecter creates a poll-driven registry of expectations, which will be triggered on every tick that the controller experiences. This is useful for resources which do not support WATCH and cannot use the expectationController
func NewWorkspaceFixture ¶ added in v0.6.0
func NewWorkspaceFixture(t *testing.T, server RunningServer, orgClusterName logicalcluster.LogicalCluster, workspaceType string) (clusterName logicalcluster.LogicalCluster)
func NewWorkspaceWithWorkloads ¶
func NewWorkspaceWithWorkloads(t *testing.T, server RunningServer, orgClusterName logicalcluster.LogicalCluster, workspaceType string, schedulable bool) (clusterName logicalcluster.LogicalCluster)
func NoGoRunEnvSet ¶ added in v0.6.0
func NoGoRunEnvSet() bool
func ReadFromFixture ¶
ReadFromFixture reads an input fixture file and returns the data
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 RequireDiff ¶
func RequireNoDiff ¶
func RunInProcess ¶
func RunInProcess(o *runOptions)
func ScratchDirs ¶
ScratchDirs determines where artifacts and data should live for a test server.
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 StartWorkspaceSyncer ¶
func StartWorkspaceSyncer( t *testing.T, ctx context.Context, resources sets.String, workloadCluster *workloadv1alpha1.WorkloadCluster, upstream, downstream RunningServer, )
StartWorkspaceSyncer starts a new syncer to synchronize the identified set of resource types scheduled for the given workload cluster from the upstream server to the downstream server.
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 WithLogStreaming ¶
func WithLogStreaming(o *runOptions)
func WriteToFixture ¶
WriteToFixture reads an input fixture file and returns the data
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 ClusterWorkspaceListExpectation ¶
type ClusterWorkspaceListExpectation func(*tenancyv1alpha1.ClusterWorkspaceList) error
ClusterWorkspaceListExpectation evaluates an expectation about the object.
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 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 kcpclientset.Interface) (RegisterClusterWorkspaceExpectation, error)
ExpectClusterWorkspaces sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterClusterWorkspaceListExpectation ¶
type RegisterClusterWorkspaceListExpectation func(expectation ClusterWorkspaceListExpectation) error
RegisterClusterWorkspaceListExpectation registers an expectation about the future state of the system.
func ExpectClusterWorkspaceListPolling ¶
func ExpectClusterWorkspaceListPolling(ctx context.Context, t *testing.T, client kcpclientset.Interface) (RegisterClusterWorkspaceListExpectation, error)
ExpectClusterWorkspaceListPolling sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterWorkspaceExpectation ¶
type RegisterWorkspaceExpectation func(seed *tenancyv1beta1.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 kcpclientset.Interface) (RegisterWorkspaceExpectation, error)
ExpectWorkspaces sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterWorkspaceListExpectation ¶
type RegisterWorkspaceListExpectation func(expectation WorkspaceListExpectation) error
RegisterWorkspaceListExpectation registers an expectation about the future state of the system.
func ExpectWorkspaceListPolling ¶
func ExpectWorkspaceListPolling(ctx context.Context, t *testing.T, client kcpclientset.Interface) (RegisterWorkspaceListExpectation, error)
ExpectWorkspaceListPolling sets up an Expecter in order to allow registering expectations in tests with minimal setup.
type RegisterWorkspaceShardExpectation ¶
type RegisterWorkspaceShardExpectation func(seed *tenancyv1alpha1.WorkspaceShard, 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 kcpclientset.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)
DefaultConfig(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.LogicalCluster) 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 `--kubeconfig` or `--use-default-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 WorkspaceExpectation ¶
type WorkspaceExpectation func(*tenancyv1beta1.Workspace) error
WorkspaceExpectation evaluates an expectation about the object.
type WorkspaceListExpectation ¶
type WorkspaceListExpectation func(*tenancyv1beta1.WorkspaceList) error
WorkspaceListExpectation evaluates an expectation about the object.
type WorkspaceShardExpectation ¶
type WorkspaceShardExpectation func(*tenancyv1alpha1.WorkspaceShard) error
WorkspaceShardExpectation evaluates an expectation about the object.