resources

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package resources contains integration test resources for spinning up M3 components.

Index

Constants

View Source
const (

	// AggName is the name of the aggregated namespace.
	AggName = "aggregated"
	// UnaggName is the name of the unaggregated namespace.
	UnaggName = "default"
	// ColdWriteNsName is the name for cold write namespace.
	ColdWriteNsName = "coldWritesRepairAndNoIndex"
)

Variables

This section is empty.

Functions

func SetupCluster

func SetupCluster(cluster M3Resources, opts *ClusterOptions) error

SetupCluster setups m3 cluster on provided docker containers.

Types

type Admin

type Admin interface {
	// GetNamespace gets namespaces.
	GetNamespace() (admin.NamespaceGetResponse, error)
	// WaitForNamespace blocks until the given namespace is enabled.
	// NB: if the name string is empty, this will instead
	// check for a successful response.
	WaitForNamespace(name string) error
	// AddNamespace adds a namespace.
	AddNamespace(admin.NamespaceAddRequest) (admin.NamespaceGetResponse, error)
	// UpdateNamespace updates the namespace.
	UpdateNamespace(admin.NamespaceUpdateRequest) (admin.NamespaceGetResponse, error)
	// DeleteNamespace removes the namespace.
	DeleteNamespace(namespaceID string) error
	// CreateDatabase creates a database.
	CreateDatabase(admin.DatabaseCreateRequest) (admin.DatabaseCreateResponse, error)
	// GetPlacement gets placements.
	GetPlacement() (admin.PlacementGetResponse, error)
	// WaitForInstances blocks until the given instance is available.
	WaitForInstances(ids []string) error
	// WaitForShardsReady waits until all shards gets ready.
	WaitForShardsReady() error
	// Close closes the wrapper and releases any held resources, including
	// deleting docker containers.
	Close() error
}

Admin is a wrapper for admin functions.

type ClusterOptions

type ClusterOptions struct {
	ReplicationFactor int32
	NumShards         int32
}

ClusterOptions represents a set of options for a cluster setup.

type Coordinator

type Coordinator interface {
	Admin

	// ApplyKVUpdate applies a KV update.
	ApplyKVUpdate(update string) error
	// WriteCarbon writes a carbon metric datapoint at a given time.
	WriteCarbon(port int, metric string, v float64, t time.Time) error
	// WriteProm writes a prometheus metric.
	WriteProm(name string, tags map[string]string, samples []prompb.Sample) error
	// RunQuery runs the given query with a given verification function.
	RunQuery(verifier ResponseVerifier, query string, headers map[string][]string) error
}

Coordinator is a wrapper for a coordinator. It provides a wrapper on HTTP endpoints that expose cluster management APIs as well as read and write endpoints for series data. TODO: consider having this work on underlying structures.

type GoalStateVerifier

type GoalStateVerifier func(string, error) error

GoalStateVerifier verifies that the given results are valid.

type M3Resources

type M3Resources interface {
	// Cleanup cleans up after each started component.
	Cleanup() error
	// Nodes returns all node resources.
	Nodes() Nodes
	// Coordinator returns the coordinator resource.
	Coordinator() Coordinator
}

M3Resources represents a set of test M3 components.

type Node

type Node interface {
	// HostDetails returns this node's host details on the given port.
	HostDetails(port int) (*admin.Host, error)
	// Health gives this node's health.
	Health() (*rpc.NodeHealthResult_, error)
	// WaitForBootstrap blocks until the node has bootstrapped.
	WaitForBootstrap() error
	// WritePoint writes a datapoint to the node directly.
	WritePoint(req *rpc.WriteRequest) error
	// WriteTaggedPoint writes a datapoint with tags to the node directly.
	WriteTaggedPoint(req *rpc.WriteTaggedRequest) error
	// AggregateTiles starts tiles aggregation, waits until it will complete
	// and returns the amount of aggregated tiles.
	AggregateTiles(req *rpc.AggregateTilesRequest) (int64, error)
	// Fetch fetches datapoints.
	Fetch(req *rpc.FetchRequest) (*rpc.FetchResult_, error)
	// FetchTagged fetches datapoints by tag.
	FetchTagged(req *rpc.FetchTaggedRequest) (*rpc.FetchTaggedResult_, error)
	// Exec executes the given commands on the node container, returning
	// stdout and stderr from the container.
	Exec(commands ...string) (string, error)
	// GoalStateExec executes the given commands on the node container, retrying
	// until applying the verifier returns no error or the default timeout.
	GoalStateExec(verifier GoalStateVerifier, commands ...string) error
	// Restart restarts this container.
	Restart() error
	// Close closes the wrapper and releases any held resources, including
	// deleting docker containers.
	Close() error
}

Node is a wrapper for a db node. It provides a wrapper on HTTP endpoints that expose cluster management APIs as well as read and write endpoints for series data. TODO: consider having this work on underlying structures.

type Nodes

type Nodes []Node

Nodes is a slice of nodes.

func (Nodes) WaitForHealthy

func (n Nodes) WaitForHealthy() error

WaitForHealthy waits for each Node in Nodes to be healthy and bootstrapped before returning.

type ResponseVerifier

type ResponseVerifier func(int, map[string][]string, string, error) error

ResponseVerifier is a function that checks if the query response is valid.

Directories

Path Synopsis
Package docker contains resources needed to setup docker containers for M3 tests.
Package docker contains resources needed to setup docker containers for M3 tests.

Jump to

Keyboard shortcuts

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