setup

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package setup implements a real env in which to run tests.

Index

Constants

View Source
const (

	// ModeFile is the file-based mode for node discovery.
	ModeFile = metadata.NodeDiscoveryModeFile
	// ModeProperty is the property-based mode for schema registry.
	ModeProperty = metadata.RegistryModeProperty
	// ModeNone is the none mode for node discovery (standalone).
	ModeNone = metadata.NodeDiscoveryModeNone
)

Variables

View Source
var ErrWatchControlNotImplemented = errors.New("watch control not implemented: landed in Phase 2")

ErrWatchControlNotImplemented is the legacy sentinel from the Step 1.0 stub era. The watch-control helpers below are now wired to a real SchemaRegistry handle, but the sentinel is still returned (wrapped) when the caller passes a node name that the harness has not registered — typically because PauseDataNodeWatch was called before the matching setup.DataNode call completed its health check, or for a liaison node (no SchemaRegistry roster binding).

Functions

func BuildDataNodeFlags added in v0.11.0

func BuildDataNodeFlags(config *ClusterConfig, dataDir string, ports []int) []string

BuildDataNodeFlags assembles the flag list for an external data node WITHOUT the AddSchemaServerAddr side-effect. Use this to capture the flags once for restart scenarios (ExternalDataNode already records the schema address; a second call would duplicate it in the ClusterConfig). The returned slice does NOT include the leading "data" subcommand. ports must contain at least 3 elements: [grpc, gossip, http]; a 4th element enables the schema server (ports[3]) without re-registering its address.

func BuildStandaloneFlags added in v0.11.0

func BuildStandaloneFlags(config *ClusterConfig, path string, ports []int) []string

BuildStandaloneFlags assembles the flag list for an external standalone server WITHOUT the AddSchemaServerAddr side-effect. Use this to capture the flags once for restart scenarios (ExternalStandalone already records the schema address; a second call would duplicate it in the ClusterConfig). The returned slice does NOT include the leading "standalone" subcommand.

func CMD added in v0.5.0

func CMD(flags ...string) func()

CMD runs the command with given flags.

func ClosableStandalone added in v0.5.0

func ClosableStandalone(config *ClusterConfig, path string, ports []int, flags ...string) (string, string, func())

ClosableStandalone wires standalone modules to build a testing ready runtime.

func ClosableStandaloneWithSchemaLoaders added in v0.5.0

func ClosableStandaloneWithSchemaLoaders(config *ClusterConfig, path string, ports []int, schemaLoaders []SchemaLoader, flags ...string) (string, string, func())

ClosableStandaloneWithSchemaLoaders wires standalone modules to build a testing ready runtime.

func DataNode added in v0.5.0

func DataNode(config *ClusterConfig, flags ...string) func()

DataNode runs a data node.

func DataNodeFromDataDir added in v0.9.0

func DataNodeFromDataDir(config *ClusterConfig, dataDir string, flags ...string) (string, string, string, func())

DataNodeFromDataDir runs a data node with a specific data directory and returns the gRPC address, the property-repair-gossip gRPC address, the HTTP URL (Prometheus /metrics), and a close function.

func DataNodeWithAddrAndDir added in v0.8.0

func DataNodeWithAddrAndDir(config *ClusterConfig, flags ...string) (string, string, string, func())

DataNodeWithAddrAndDir runs a data node and returns the gRPC address, the data directory path, the HTTP URL (Prometheus /metrics), and a close fn.

func EmptyClosableStandalone added in v0.5.0

func EmptyClosableStandalone(config *ClusterConfig, path string, ports []int, flags ...string) (string, string, func())

EmptyClosableStandalone wires standalone modules to build a testing ready runtime.

func EmptyStandalone added in v0.5.0

func EmptyStandalone(config *ClusterConfig, flags ...string) (string, string, func())

EmptyStandalone wires standalone modules to build a testing ready runtime.

func EmptyStandaloneWithAuth added in v0.9.0

func EmptyStandaloneWithAuth(config *ClusterConfig, username, password string, flags ...string) (string, string, func())

EmptyStandaloneWithAuth wires standalone modules to build a testing ready runtime with Auth.

func ExternalCMD added in v0.11.0

func ExternalCMD(binPath, logPath string, flags ...string) (func(), error)

ExternalCMD launches binPath as a separate OS process with the given flags, writing its combined stdout+stderr to a file at logPath. It returns a teardown closure that sends SIGTERM to the process and waits up to 30 seconds for it to exit, then SIGKILLs any survivor. The closure is safe to call exactly once.

func ExternalDataNode added in v0.11.0

func ExternalDataNode(config *ClusterConfig, binPath, dataDir, logDir string, ports []int, flags ...string) (grpcAddr string, closeFn func())

ExternalDataNode launches an external banyand data node, waits for it to pass the gRPC readiness gate, and returns the gRPC address and teardown closure. ports must contain at least 3 elements: [grpc, gossip, http]; pass 4 to also start the schema server (ports[3]). Additional flags are appended after the assembled flag block.

func ExternalLiaisonNode added in v0.11.0

func ExternalLiaisonNode(config *ClusterConfig, binPath, path, logDir string, ports []int, flags ...string) (grpcAddr string, closeFn func())

ExternalLiaisonNode launches an external banyand liaison node, waits for it to pass the HTTP readiness gate, and returns the gRPC address and teardown closure. ports must contain at least 3 elements: [grpc, http, liaison-server]. Additional flags are appended after the assembled flag block.

func ExternalStandalone added in v0.11.0

func ExternalStandalone(config *ClusterConfig, binPath, path, logDir string, ports []int, flags ...string) (grpcAddr, httpAddr string, closeFn func())

ExternalStandalone launches an external standalone banyand server, waits for it to pass the gRPC and HTTP readiness gates, and returns the gRPC address, HTTP address, and a teardown closure. ports must contain at least 5 elements: [grpc, http, unused, unused, schema]. Additional flags are appended after the assembled flag block.

func LiaisonNode added in v0.5.0

func LiaisonNode(config *ClusterConfig, flags ...string) (grpcAddr string, closeFn func())

LiaisonNode runs a liaison node.

func LiaisonNodeWithAddrAndDir added in v0.10.0

func LiaisonNodeWithAddrAndDir(config *ClusterConfig, flags ...string) (string, string, func())

LiaisonNodeWithAddrAndDir runs a liaison node and returns the gRPC address, root data path, and closer.

func LiaisonNodeWithHTTP added in v0.9.0

func LiaisonNodeWithHTTP(config *ClusterConfig, flags ...string) (string, string, func())

LiaisonNodeWithHTTP runs a liaison node with HTTP enabled and returns the gRPC and HTTP addresses.

func PauseDataNodeWatch added in v0.11.0

func PauseDataNodeWatch(nodeAddr string) error

PauseDataNodeWatch suspends the named data node's schema-watch loop so a test can observe behavior while the node is missing schema events. nodeAddr is the gRPC address returned from setup.DataNodeFromDataDir (e.g. "127.0.0.1:31921"); pkg/test/setup binds the address during node startup. Returns ErrWatchControlNotImplemented (wrapped) when the address is not registered — typically because the node is a liaison or because PauseDataNodeWatch was called before the matching setup.DataNode invocation completed its health check.

func PreloadSchemaViaProperty added in v0.10.0

func PreloadSchemaViaProperty(config *ClusterConfig, loaders ...func(ctx context.Context, registry schema.Registry) error)

PreloadSchemaViaProperty connects to property schema servers and runs the provided schema loader functions.

func QueryNodeGroups added in v0.10.0

func QueryNodeGroups(config *ClusterConfig) map[string][]string

QueryNodeGroups returns active group names from each schema server.

func ResolveBanyandBinary added in v0.11.0

func ResolveBanyandBinary() (string, error)

ResolveBanyandBinary returns the path to the banyand server binary. It returns the value of the BANYAND_BIN environment variable if set and the file exists. Otherwise it resolves a path relative to this source file's location: two directories up from pkg/test/setup reaches the module root, and then descends into banyand/build/bin/dev/banyand-server. An error is returned when neither source can produce an existing file; callers should treat the error as a signal to skip the test.

func ResumeDataNodeWatch added in v0.11.0

func ResumeDataNodeWatch(nodeAddr string) error

ResumeDataNodeWatch resumes a previously paused data-node watch loop and drains any events that arrived during the pause window. Same lookup semantics as PauseDataNodeWatch.

func Standalone added in v0.5.0

func Standalone(config *ClusterConfig, flags ...string) (string, string, func())

Standalone wires standalone modules to build a testing ready runtime.

func StandaloneWithAuth added in v0.9.0

func StandaloneWithAuth(config *ClusterConfig, username, password string, flags ...string) (string, string, func())

StandaloneWithAuth wires standalone modules to build a testing ready runtime with Auth.

func StandaloneWithSchemaLoaders added in v0.5.0

func StandaloneWithSchemaLoaders(config *ClusterConfig, schemaLoaders []SchemaLoader,
	certFile, keyFile string, username, password string, flags ...string,
) (string, string, func())

StandaloneWithSchemaLoaders wires standalone modules to build a testing ready runtime. It also allows to preload schema.

func StandaloneWithTLS added in v0.5.0

func StandaloneWithTLS(config *ClusterConfig, certFile, keyFile string, flags ...string) (string, string, func())

StandaloneWithTLS wires standalone modules to build a testing ready runtime with TLS enabled.

Types

type ClusterConfig added in v0.10.0

type ClusterConfig struct {
	NodeDiscovery  NodeDiscoveryConfig
	SchemaRegistry SchemaRegistryConfig
	// contains filtered or unexported fields
}

ClusterConfig configures node discovery and schema registry for test clusters.

func PropertyClusterConfig added in v0.10.0

func PropertyClusterConfig(fileWriter *DiscoveryFileWriter) *ClusterConfig

PropertyClusterConfig creates a ClusterConfig that uses file-based discovery and property-based schema.

func (*ClusterConfig) AddLoadedKinds added in v0.10.0

func (c *ClusterConfig) AddLoadedKinds(kinds ...schema.Kind)

AddLoadedKinds records which schema kinds have been preloaded.

func (*ClusterConfig) AddSchemaServerAddr added in v0.11.0

func (c *ClusterConfig) AddSchemaServerAddr(addr string)

AddSchemaServerAddr adds a schema server address to the cluster config.

func (*ClusterConfig) SchemaServerAddrs added in v0.10.0

func (c *ClusterConfig) SchemaServerAddrs() []string

SchemaServerAddrs returns the accumulated schema server addresses.

type DiscoveryFileWriter added in v0.10.0

type DiscoveryFileWriter struct {
	// contains filtered or unexported fields
}

DiscoveryFileWriter manages a dynamic YAML file for file-based node discovery.

func NewDiscoveryFileWriter added in v0.10.0

func NewDiscoveryFileWriter(dir string) *DiscoveryFileWriter

NewDiscoveryFileWriter creates a new DiscoveryFileWriter in the given directory.

func (*DiscoveryFileWriter) AddNode added in v0.10.0

func (w *DiscoveryFileWriter) AddNode(name, address string)

AddNode adds a node to the discovery file and writes it.

func (*DiscoveryFileWriter) Path added in v0.10.0

func (w *DiscoveryFileWriter) Path() string

Path returns the path to the discovery YAML file.

func (*DiscoveryFileWriter) RemoveNode added in v0.11.0

func (w *DiscoveryFileWriter) RemoveNode(address string)

RemoveNode removes a node from the discovery file by address and writes it.

type NodeDiscoveryConfig added in v0.10.0

type NodeDiscoveryConfig struct {
	FileWriter *DiscoveryFileWriter
	Mode       string // ModeFile or ModeNone
}

NodeDiscoveryConfig configures node discovery mode.

type SchemaLoader added in v0.4.0

type SchemaLoader interface {
	run.Unit
	SetRegistry(registry schema.Registry)
}

SchemaLoader is a service that can preload schema.

type SchemaRegistryConfig added in v0.10.0

type SchemaRegistryConfig struct {
	Mode string // ModeProperty
}

SchemaRegistryConfig configures schema registry mode.

Jump to

Keyboard shortcuts

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