launcher

package
v2.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 89 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BoltStore stores all REST resources in boltdb.
	BoltStore = "bolt"
	// MemoryStore stores all REST resources in memory (useful for testing).
	MemoryStore = "memory"

	// LogTracing enables tracing via zap logs
	LogTracing = "log"
	// JaegerTracing enables tracing via the Jaeger client library
	JaegerTracing = "jaeger"
	// Max Integer
	MaxInt = 1<<uint(strconv.IntSize-1) - 1
)

Variables

This section is empty.

Functions

func NewInfluxdCommand

func NewInfluxdCommand(ctx context.Context, subCommands ...*cobra.Command) *cobra.Command

Types

type Engine

type Engine interface {
	influxdb.DeleteService
	storage.PointsWriter
	storage.EngineSchema
	prom.PrometheusCollector
	influxdb.BackupService

	SeriesCardinality(orgID, bucketID influxdb.ID) int64

	TSDBStore() storage.TSDBStore
	MetaClient() storage.MetaClient

	WithLogger(log *zap.Logger)
	Open(context.Context) error
	Close() error
}

Engine defines the time-series storage engine. Wraps *storage.Engine to facilitate testing.

type Launcher

type Launcher struct {
	StorageConfig storage.Config

	// InfluxQL query engine
	CoordinatorConfig iqlcoordinator.Config

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

Launcher represents the main program execution.

func NewLauncher

func NewLauncher() *Launcher

NewLauncher returns a new instance of Launcher connected to standard in/out/err.

func (*Launcher) AuthorizationService

func (m *Launcher) AuthorizationService() platform.AuthorizationService

AuthorizationService returns the internal authorization service.

func (*Launcher) BucketService

func (m *Launcher) BucketService() platform.BucketService

BucketService returns the internal bucket service.

func (*Launcher) Cancel

func (m *Launcher) Cancel()

Cancel executes the context cancel on the program. Used for testing.

func (*Launcher) Engine

func (m *Launcher) Engine() Engine

Engine returns a reference to the storage engine. It should only be called for end-to-end testing purposes.

func (*Launcher) KeyValueService

func (m *Launcher) KeyValueService() *kv.Service

KeyValueService returns the internal key-value service.

func (*Launcher) Log

func (m *Launcher) Log() *zap.Logger

Log returns the launchers logger.

func (*Launcher) NatsURL

func (m *Launcher) NatsURL() string

NatsURL returns the URL to connection to the NATS server.

func (*Launcher) OrganizationService

func (m *Launcher) OrganizationService() platform.OrganizationService

OrganizationService returns the internal organization service.

func (*Launcher) QueryController

func (m *Launcher) QueryController() *control.Controller

QueryController returns the internal query service.

func (*Launcher) Registry

func (m *Launcher) Registry() *prom.Registry

Registry returns the prometheus metrics registry.

func (*Launcher) ReportingDisabled

func (m *Launcher) ReportingDisabled() bool

ReportingDisabled is true if opted out of usage stats.

func (*Launcher) Run

func (m *Launcher) Run(ctx context.Context, args ...string) error

Run executes the program with the given CLI arguments.

func (*Launcher) Running

func (m *Launcher) Running() bool

Running returns true if the main Launcher has started running.

func (*Launcher) SecretService

func (m *Launcher) SecretService() platform.SecretService

SecretService returns the internal secret service.

func (*Launcher) Shutdown

func (m *Launcher) Shutdown(ctx context.Context)

Shutdown shuts down the HTTP server and waits for all services to clean up.

func (*Launcher) TaskControlService

func (m *Launcher) TaskControlService() taskbackend.TaskControlService

TaskControlService returns the internal store service.

func (*Launcher) TaskService

func (m *Launcher) TaskService() platform.TaskService

TaskService returns the internal task service.

func (*Launcher) URL

func (m *Launcher) URL() string

URL returns the URL to connect to the HTTP server.

func (*Launcher) UserResourceMappingService

func (m *Launcher) UserResourceMappingService() platform.UserResourceMappingService

UserResourceMappingService returns the internal user resource mapping service.

func (*Launcher) UserService

func (m *Launcher) UserService() platform.UserService

UserService returns the internal user service.

type QueryResult

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

QueryResult wraps a single flux.Result with some helper methods.

func (*QueryResult) HasTablesWithCols

func (r *QueryResult) HasTablesWithCols(want []int)

HasTableWithCols checks if the desired number of tables and columns exist, ignoring any system columns.

If the result is not as expected then the testing.T fails.

func (*QueryResult) TablesN

func (r *QueryResult) TablesN() int

TablesN returns the number of tables for the result.

type QueryResults

type QueryResults struct {
	Results []flux.Result
	Query   flux.Query
}

QueryResults wraps a set of query results with some helper methods.

func (*QueryResults) Done

func (r *QueryResults) Done()

func (*QueryResults) First

func (r *QueryResults) First(t *testing.T) *QueryResult

First returns the first QueryResult. When there are not exactly 1 table First will fail.

func (*QueryResults) HasTableCount

func (r *QueryResults) HasTableCount(t *testing.T, n int)

HasTableCount asserts that there are n tables in the result.

func (*QueryResults) Names

func (r *QueryResults) Names() []string

Names returns the sorted set of result names for the query results.

func (*QueryResults) SortedNames

func (r *QueryResults) SortedNames() []string

SortedNames returns the sorted set of table names for the query results.

type TemporaryEngine

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

TemporaryEngine creates a time-series storage engine backed by a temporary directory that is removed on Close.

func NewTemporaryEngine

func NewTemporaryEngine(c storage.Config, options ...storage.Option) *TemporaryEngine

NewTemporaryEngine creates a new engine that places the storage engine files into a temporary directory; used for testing.

func (*TemporaryEngine) Close

func (t *TemporaryEngine) Close() error

Close will remove the directory containing the time-series files.

func (*TemporaryEngine) CreateBackup

func (t *TemporaryEngine) CreateBackup(ctx context.Context) (int, []string, error)

func (*TemporaryEngine) CreateBucket

func (t *TemporaryEngine) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

func (*TemporaryEngine) DeleteBucket

func (t *TemporaryEngine) DeleteBucket(ctx context.Context, orgID, bucketID influxdb.ID) error

DeleteBucket deletes a bucket from the time-series data.

func (*TemporaryEngine) DeleteBucketRangePredicate

func (t *TemporaryEngine) DeleteBucketRangePredicate(ctx context.Context, orgID, bucketID influxdb.ID, min, max int64, pred influxdb.Predicate) error

DeleteBucketRangePredicate will delete a bucket from the range and predicate.

func (*TemporaryEngine) FetchBackupFile

func (t *TemporaryEngine) FetchBackupFile(ctx context.Context, backupID int, backupFile string, w io.Writer) error

func (*TemporaryEngine) Flush

func (t *TemporaryEngine) Flush(ctx context.Context)

Flush will remove the time-series files and re-open the engine.

func (*TemporaryEngine) InternalBackupPath

func (t *TemporaryEngine) InternalBackupPath(backupID int) string

func (*TemporaryEngine) MetaClient

func (t *TemporaryEngine) MetaClient() storage.MetaClient

func (*TemporaryEngine) Open

func (t *TemporaryEngine) Open(ctx context.Context) error

Open creates a temporary directory and opens the engine.

func (*TemporaryEngine) PrometheusCollectors

func (t *TemporaryEngine) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors returns all the prometheus collectors associated with the engine and its components.

func (*TemporaryEngine) SeriesCardinality

func (t *TemporaryEngine) SeriesCardinality(orgID, bucketID influxdb.ID) int64

SeriesCardinality returns the number of series in the engine.

func (*TemporaryEngine) TSDBStore

func (t *TemporaryEngine) TSDBStore() storage.TSDBStore

func (*TemporaryEngine) UpdateBucketRetentionPeriod

func (t *TemporaryEngine) UpdateBucketRetentionPeriod(ctx context.Context, bucketID influxdb.ID, d time.Duration) error

func (*TemporaryEngine) WithLogger

func (t *TemporaryEngine) WithLogger(log *zap.Logger)

WithLogger sets the logger on the engine. It must be called before Open.

func (*TemporaryEngine) WritePoints

func (t *TemporaryEngine) WritePoints(ctx context.Context, orgID influxdb.ID, bucketID influxdb.ID, points []models.Point) error

WritePoints stores points into the storage engine.

type TestLauncher

type TestLauncher struct {
	*Launcher

	// Root temporary directory for all data.
	Path string

	// Initialized after calling the Setup() helper.
	User   *platform.User
	Org    *platform.Organization
	Bucket *platform.Bucket
	Auth   *platform.Authorization

	// Standard in/out/err buffers.
	Stdin  bytes.Buffer
	Stdout bytes.Buffer
	Stderr bytes.Buffer
	// contains filtered or unexported fields
}

TestLauncher is a test wrapper for launcher.Launcher.

func NewTestLauncher

func NewTestLauncher(flagger feature.Flagger) *TestLauncher

NewTestLauncher returns a new instance of TestLauncher.

func NewTestLauncherServer

func NewTestLauncherServer(flagger feature.Flagger) *TestLauncher

NewTestLauncherServer returns a new instance of TestLauncher configured as real server (disk store, no e2e flag).

func RunTestLauncherOrFail

func RunTestLauncherOrFail(tb testing.TB, ctx context.Context, flagger feature.Flagger, args ...string) *TestLauncher

RunTestLauncherOrFail initializes and starts the server.

func (*TestLauncher) AuthorizationService

func (tl *TestLauncher) AuthorizationService(tb testing.TB) *http.AuthorizationService

func (*TestLauncher) BucketService

func (tl *TestLauncher) BucketService(tb testing.TB) *http.BucketService

func (*TestLauncher) CheckService

func (tl *TestLauncher) CheckService() platform.CheckService

func (*TestLauncher) DashboardService

func (tl *TestLauncher) DashboardService(tb testing.TB) *http.DashboardService

func (*TestLauncher) ExecuteQuery

func (tl *TestLauncher) ExecuteQuery(q string) (*QueryResults, error)

ExecuteQuery executes the provided query against the ith query node. Callers of ExecuteQuery must call Done on the returned QueryResults.

func (*TestLauncher) FluxQueryOrFail

func (tl *TestLauncher) FluxQueryOrFail(tb testing.TB, org *platform.Organization, token string, query string) string

FluxQueryOrFail performs a query to the specified organization and returns the results or fails if there is an error.

func (*TestLauncher) FluxQueryService

func (tl *TestLauncher) FluxQueryService() *http.FluxQueryService

func (*TestLauncher) FluxService

func (tl *TestLauncher) FluxService() *http.FluxService

func (*TestLauncher) HTTPClient

func (tl *TestLauncher) HTTPClient(tb testing.TB) *httpc.Client

func (*TestLauncher) LabelService

func (tl *TestLauncher) LabelService(tb testing.TB) *http.LabelService

func (*TestLauncher) Metrics

func (tl *TestLauncher) Metrics(tb testing.TB) (metrics map[string]*dto.MetricFamily)

func (*TestLauncher) MustExecuteQuery

func (tl *TestLauncher) MustExecuteQuery(query string) *QueryResults

MustExecuteQuery executes the provided query panicking if an error is encountered. Callers of MustExecuteQuery must call Done on the returned QueryResults.

func (*TestLauncher) MustNewHTTPRequest

func (tl *TestLauncher) MustNewHTTPRequest(method, rawurl, body string) *nethttp.Request

MustNewHTTPRequest returns a new nethttp.Request with base URL and auth attached. Fail on error.

func (*TestLauncher) NewHTTPRequest

func (tl *TestLauncher) NewHTTPRequest(method, rawurl, token string, body string) (*nethttp.Request, error)

NewHTTPRequest returns a new nethttp.Request with base URL and auth attached.

func (*TestLauncher) NewHTTPRequestOrFail

func (tl *TestLauncher) NewHTTPRequestOrFail(tb testing.TB, method, rawurl, token string, body string) *nethttp.Request

NewHTTPRequestOrFail returns a new nethttp.Request with base URL and auth attached. Fail on error.

func (*TestLauncher) NotificationEndpointService

func (tl *TestLauncher) NotificationEndpointService(tb testing.TB) *http.NotificationEndpointService

func (*TestLauncher) NotificationRuleService

func (tl *TestLauncher) NotificationRuleService() platform.NotificationRuleStore

func (*TestLauncher) NumReads

func (tl *TestLauncher) NumReads(tb testing.TB, op string) uint64

func (*TestLauncher) OnBoard

OnBoard attempts an on-boarding request. The on-boarding status is also reset to allow multiple user/org/buckets to be created.

func (*TestLauncher) OnBoardOrFail

OnBoardOrFail attempts an on-boarding request or fails on error. The on-boarding status is also reset to allow multiple user/org/buckets to be created.

func (*TestLauncher) OrgService

func (tl *TestLauncher) OrgService(tb testing.TB) platform.OrganizationService

func (*TestLauncher) PkgerService

func (tl *TestLauncher) PkgerService(tb testing.TB) pkger.SVC

func (*TestLauncher) QueryAndConsume

func (tl *TestLauncher) QueryAndConsume(ctx context.Context, req *query.Request, fn func(r flux.Result) error) error

QueryAndConsume queries InfluxDB using the request provided. It uses a function to consume the results obtained. It returns the first error encountered when requesting the query, consuming the results, or executing the query.

func (*TestLauncher) QueryAndNopConsume

func (tl *TestLauncher) QueryAndNopConsume(ctx context.Context, req *query.Request) error

QueryAndNopConsume does the same as QueryAndConsume but consumes results with a nop function.

func (*TestLauncher) QueryFlux

func (tl *TestLauncher) QueryFlux(tb testing.TB, org *platform.Organization, token, query string) string

QueryFlux returns the csv response from a flux query. It also removes all the \r to make it easier to write tests.

func (*TestLauncher) Run

func (tl *TestLauncher) Run(ctx context.Context, args ...string) error

Run executes the program with additional arguments to set paths and ports. Passed arguments will overwrite/add to the default ones.

func (*TestLauncher) Setup

func (tl *TestLauncher) Setup() error

Setup creates a new user, bucket, org, and auth token.

func (*TestLauncher) SetupOrFail

func (tl *TestLauncher) SetupOrFail(tb testing.TB)

SetupOrFail creates a new user, bucket, org, and auth token. Fail on error.

func (*TestLauncher) Shutdown

func (tl *TestLauncher) Shutdown(ctx context.Context) error

Shutdown stops the program and cleans up temporary paths.

func (*TestLauncher) ShutdownOrFail

func (tl *TestLauncher) ShutdownOrFail(tb testing.TB, ctx context.Context)

ShutdownOrFail stops the program and cleans up temporary paths. Fail on error.

func (*TestLauncher) TaskService

func (tl *TestLauncher) TaskService(tb testing.TB) *http.TaskService

func (*TestLauncher) TaskServiceKV

func (tl *TestLauncher) TaskServiceKV() platform.TaskService

func (*TestLauncher) TelegrafService

func (tl *TestLauncher) TelegrafService(tb testing.TB) *http.TelegrafService

func (*TestLauncher) VariableService

func (tl *TestLauncher) VariableService(tb testing.TB) *http.VariableService

func (*TestLauncher) WriteOrFail

func (tl *TestLauncher) WriteOrFail(tb testing.TB, to *platform.OnboardingResults, data string)

WriteOrFail attempts a write to the organization and bucket identified by to or fails if there is an error.

func (*TestLauncher) WritePoints

func (tl *TestLauncher) WritePoints(data string) error

WritePoints attempts a write to the organization and bucket used during setup.

func (*TestLauncher) WritePointsOrFail

func (tl *TestLauncher) WritePointsOrFail(tb testing.TB, data string)

WritePointsOrFail attempts a write to the organization and bucket used during setup or fails if there is an error.

Jump to

Keyboard shortcuts

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