launcher

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 72 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"
)

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand creates the command to run influxdb.

Types

type Engine

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

type Launcher

type Launcher struct {
	StorageConfig storage.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) 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) CreateCursorIterator

func (t *TemporaryEngine) CreateCursorIterator(ctx context.Context) (tsdb.CursorIterator, error)

CreateCursorIterator calls into the underlying engines CreateCurorIterator.

func (*TemporaryEngine) CreateSeriesCursor

CreateSeriesCursor calls into the underlying engines CreateSeriesCursor.

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) 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() int64

SeriesCardinality returns the number of series in the engine.

func (*TemporaryEngine) TagKeys

func (t *TemporaryEngine) TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error)

TagKeys calls into the underlying engines TagKeys.

func (*TemporaryEngine) TagValues

func (t *TemporaryEngine) TagValues(ctx context.Context, orgID, bucketID influxdb.ID, tagKey string, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error)

TagValues calls into the underlying engines TagValues.

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, 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() *TestLauncher

NewTestLauncher returns a new instance of TestLauncher.

func RunTestLauncherOrFail

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

RunLauncherOrFail 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) 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) 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) 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) Run

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

Run executes the program with additional arguments to set paths and ports.

func (*TestLauncher) Setup

func (tl *TestLauncher) Setup() error

SetupOrFail 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() *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