Documentation
¶
Index ¶
- Variables
- func Command(executableName, identity string) []string
- func GetFreePort(t TestingT) (string, error)
- func MonitorEndpoints(t TestingT, client *rest.Config, endpoints ...string)
- func RunInProcess(o *runOptions)
- func ScrapeMetrics(ctx context.Context, cfg *rest.Config, ...) error
- func ScratchDirs(t TestingT) (string, string, error)
- func StartKcpCommand(identity string) []string
- func WaitForReady(ctx context.Context, cfg *rest.Config) error
- func WithLogStreaming(o *runOptions)
- type Config
- type Fixture
- type Option
- type RunOption
- type RunningServer
- type TestingT
Constants ¶
This section is empty.
Variables ¶
var RunInProcessFunc func(t TestingT, dataDir string, args []string) (<-chan struct{}, error)
RunInProcessFunc instantiates the kcp server in process for easier debugging. It is here to decouple the rest of the code from kcp core dependencies.
Functions ¶
func Command ¶
Command 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 MonitorEndpoints ¶
MonitorEndpoints keeps watching the given endpoints and fails t on error.
func RunInProcess ¶
func RunInProcess(o *runOptions)
func ScrapeMetrics ¶
func ScratchDirs ¶
ScratchDirs determines where artifacts and data should live for a test server. The passed subDir is appended to the artifact directory and should be unique to the test.
func StartKcpCommand ¶
StartKcpCommand returns the string tokens required to start kcp in the currently configured mode (direct or via `go run`).
func WaitForReady ¶
WaitForReady waits for /livez and then /readyz to return success.
func WithLogStreaming ¶
func WithLogStreaming(o *runOptions)
Types ¶
type Config ¶
type Config struct { Name string Args []string ArtifactDir string DataDir string ClientCADir string LogToConsole bool RunInProcess bool }
Config qualify a kcp server to start
Deprecated for use outside this package. Prefer PrivateKcpServer().
type Fixture ¶
type Fixture = map[string]RunningServer
Fixture manages the lifecycle of a set of kcp servers.
Deprecated for use outside this package. Prefer PrivateKcpServer().
func NewFixture ¶
NewFixture returns a new kcp server fixture.
type Option ¶
type Option func(*Config)
Option a function that wish to modify a given kcp configuration.
func WithClientCA ¶
WithClientCA sets the client CA directory for a given kcp configuration. A client CA will automatically created and the --client-ca configured.
func WithCustomArguments ¶
WithCustomArguments applies provided arguments to a given kcp configuration.
func WithLogToConsole ¶
func WithLogToConsole() Option
WithLogToConsole sets the kcp server to log to console.
func WithRunInProcess ¶
func WithRunInProcess() Option
WithRunInProcess sets the kcp server to run in process. This requires extra setup of the RunInProcessFunc variable and will only work inside of the kcp repository.
func WithScratchDirectories ¶
WithScratchDirectories adds custom scratch directories to a kcp configuration.
type RunningServer ¶
type RunningServer interface { Name() string KubeconfigPath() string RawConfig() (clientcmdapi.Config, error) BaseConfig(t TestingT) *rest.Config RootShardSystemMasterBaseConfig(t TestingT) *rest.Config ShardSystemMasterBaseConfig(t TestingT, shard string) *rest.Config ShardNames() []string Artifact(t TestingT, producer func() (runtime.Object, error)) ClientCAUserConfig(t TestingT, config *rest.Config, name string, groups ...string) *rest.Config CADirectory() string }
func NewExternalKCPServer ¶
func NewExternalKCPServer(name, kubeconfigPath string, shardKubeconfigPaths map[string]string, clientCADir string) (RunningServer, error)
NewExternalKCPServer returns a RunningServer for a kubeconfig pointing to a kcp instance not managed by the test run. Since the kubeconfig is expected to exist prior to running tests against it, the configuration can be loaded synchronously and no locking is required to subsequently access it.
type TestingT ¶
type TestingT interface { Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) Name() string TempDir() string }
TestingT is implemented by *testing.T and potentially other test frameworks.