server

package
v0.27.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func Command(executableName, identity string) []string

Command returns the string tokens required to start the given executable in the currently configured mode (direct or via `go run`).

func GetFreePort

func GetFreePort(t TestingT) (string, error)

GetFreePort asks the kernel for a free open port that is ready to use.

func MonitorEndpoints

func MonitorEndpoints(t TestingT, client *rest.Config, endpoints ...string)

MonitorEndpoints keeps watching the given endpoints and fails t on error.

func RunInProcess

func RunInProcess(o *runOptions)

func ScrapeMetrics

func ScrapeMetrics(ctx context.Context, cfg *rest.Config, promUrl, promCfgDir, jobName, caFile string, labels map[string]string) error

func ScratchDirs

func ScratchDirs(t TestingT) (string, string, error)

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

func StartKcpCommand(identity string) []string

StartKcpCommand returns the string tokens required to start kcp in the currently configured mode (direct or via `go run`).

func WaitForReady

func WaitForReady(ctx context.Context, cfg *rest.Config) error

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

func NewFixture(t TestingT, cfgs ...Config) Fixture

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

func WithClientCA(clientCADir string) Option

WithClientCA sets the client CA directory for a given kcp configuration. A client CA will automatically created and the --client-ca configured.

func WithCustomArguments

func WithCustomArguments(args ...string) Option

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

func WithScratchDirectories(artifactDir, dataDir string) Option

WithScratchDirectories adds custom scratch directories to a kcp configuration.

type RunOption

type RunOption func(o *runOptions)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL