setup

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 35 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
)
View Source
const FastSchemaSync = "--schema-property-client-sync-interval=1s"

FastSchemaSync shortens schema convergence. A native log producer creates the log group after the other nodes have started, and a node that does not know a group fails the whole distributed query rather than returning what the others hold (apache/skywalking#14104). With the default 30s interval the full reconcile that repairs it is 150s away.

View Source
const ReceiverFlag = "--logging-native-receiver-enabled"

ReceiverFlag makes a server keep the native log schema for the producers that write to it, while it collects nothing of its own.

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).

View Source
var NativeLogFlags = []string{"--logging-native-enabled", "--logging-native-level=info", "--logging-level=error"}

NativeLogFlags turns native logging on with the thresholds the native log cases assume: the console at error and native storage at info, so an info line is stored and not printed.

Functions

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 LiaisonID added in v0.12.0

func LiaisonID(conn *grpclib.ClientConn) string

LiaisonID returns the id of the only liaison of the cluster that conn reaches, which is the identity the liaison stamps on its native log events. The id is the liaison's host and internal port, which the launcher does not return; the liaison lists itself in its own tier-1 route table.

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 LiaisonNodeWithHTTPAuth added in v0.12.0

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

LiaisonNodeWithHTTPAuth runs a liaison node with HTTP enabled and uses the supplied credentials for its readiness and cluster synchronization calls.

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 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 SetLiaisonMemoryHigh added in v0.12.0

func SetLiaisonMemoryHigh(nodeAddr string, high bool) error

SetLiaisonMemoryHigh forces the named liaison's memory protector into (or out of) the high-pressure state, so a test can make the liaison's trace write listener report STATUS_SERVER_BUSY. The liaison's Write handler and that listener share the protector, and a liaison in high pressure also sheds new streams. nodeAddr is the gRPC address returned from LiaisonNode or LiaisonNodeWithHTTP.

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.

func StartNativeLogProducer added in v0.12.0

func StartNativeLogProducer(nodeType string, dest nativelog.Destination) (nodeID string, stop func())

StartNativeLogProducer stores this process's logs as a producer of nodeType, such as backup or an FODC agent, writing to dest, with the thresholds of NativeLogFlags. It returns the producer's node_id and the function that stops it.

Call it after the servers it writes to have started: the native sink is process-global, and a server configures the logger when it starts.

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
	// KeepStoppedNodes leaves a closed data node's address in the discovery file, so the
	// liaison keeps the stopped node registered and has to report it as unreachable.
	KeepStoppedNodes bool
}

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