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 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, ...) clientcmdapi.Config
- func NewOrganizationFixture(t *testing.T, server RunningServer) (orgClusterName logicalcluster.LogicalCluster)
- 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 RunKcpCliPlugin(t *testing.T, kubeconfigPath string, subcommand []string) []byte
- func ScratchDirs(t *testing.T) (string, string, error)
- func StartKcpCommand() []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 ExpectationController
- type Expecter
- type Option
- type Options
- type RegisterClusterWorkspaceExpectation
- type RegisterClusterWorkspaceListExpectation
- type RegisterWorkspaceExpectation
- type RegisterWorkspaceListExpectation
- type RegisterWorkspaceShardExpectation
- type RunOption
- type RunningServer
- type StartedSyncerFixture
- type SyncerFixture
- type User
- type WorkloadClusterOption
- 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, opts ...WorkloadClusterOption) (*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 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.LogicalCluster) 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) (orgClusterName logicalcluster.LogicalCluster)
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 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 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 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 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 NewPollingExpecter ¶
func NewPollingExpecter(interval time.Duration) *ExpectationController
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 (*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 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.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 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 `--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 kubernetes.Interface
}
StartedSyncerFixture contains the configuration used to start a syncer and interact with its downstream cluster.
func (*StartedSyncerFixture) WaitForClusterReadyReason ¶ added in v0.6.0
func (sf *StartedSyncerFixture) WaitForClusterReadyReason(t *testing.T, ctx context.Context, reason string)
WaitForClusterReadyReason waits for the cluster to be ready with the given reason.
type SyncerFixture ¶ added in v0.6.0
type SyncerFixture struct {
ResourcesToSync sets.String
UpstreamServer RunningServer
WorkspaceClusterName logicalcluster.LogicalCluster
WorkloadClusterName string
InstallCRDs func(config *rest.Config, isLogicalCluster bool)
}
SyncerFixture configures a syncer fixture. Its `Start` method does the work of starting a syncer.
func (SyncerFixture) Start ¶ added in v0.6.0
func (sf SyncerFixture) Start(t *testing.T) *StartedSyncerFixture
Start starts a new syncer against the given upstream kcp workspace. Whether the syncer run in-process or deployed on a pcluster will depend whether --pcluster-kubeconfig and --syncer-image are supplied to the test invocation.
type WorkloadClusterOption ¶
type WorkloadClusterOption func(cluster *workloadv1alpha1.WorkloadCluster)
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.ClusterWorkspaceShard) error
WorkspaceShardExpectation evaluates an expectation about the object.