launcher

package
Version: v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 116 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DiskStore stores all REST resources to disk in boltdb and sqlite.
	DiskStore = "disk"
	// BoltStore also stores all REST resources to disk in boltdb and sqlite. Kept for backwards-compatibility.
	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 NewInfluxdCommand

func NewInfluxdCommand(ctx context.Context, v *viper.Viper) (*cobra.Command, error)

NewInfluxdCommand constructs the root of the influxd CLI, along with a `run` subcommand. The `run` subcommand is set as the default to execute.

func NewInfluxdPrintConfigCommand added in v2.0.4

func NewInfluxdPrintConfigCommand(v *viper.Viper, influxdOpts []cli.Opt) (*cobra.Command, error)

Types

type Engine

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

	SeriesCardinality(ctx context.Context, bucketID platform.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 InfluxdOpts added in v2.0.4

type InfluxdOpts struct {
	Testing                 bool
	TestingAlwaysAllowSetup bool

	LogLevel          zapcore.Level
	FluxLogEnabled    bool
	TracingType       string
	ReportingDisabled bool

	AssetsPath string
	BoltPath   string
	SqLitePath string
	EnginePath string

	StoreType   string
	SecretStore string
	VaultConfig vault.Config

	HttpBindAddress       string
	HttpReadHeaderTimeout time.Duration
	HttpReadTimeout       time.Duration
	HttpWriteTimeout      time.Duration
	HttpIdleTimeout       time.Duration
	HttpTLSCert           string
	HttpTLSKey            string
	HttpTLSMinVersion     string
	HttpTLSStrictCiphers  bool
	SessionLength         int // in minutes
	SessionRenewDisabled  bool

	ProfilingDisabled bool
	MetricsDisabled   bool
	UIDisabled        bool

	NatsPort            int
	NatsMaxPayloadBytes int

	NoTasks      bool
	FeatureFlags map[string]string

	// Query options.
	ConcurrencyQuota                int32
	InitialMemoryBytesQuotaPerQuery int64
	MemoryBytesQuotaPerQuery        int64
	MaxMemoryBytes                  int64
	QueueSize                       int32
	CoordinatorConfig               coordinator.Config

	// Storage options.
	StorageConfig storage.Config

	Viper *viper.Viper

	HardeningEnabled bool
}

InfluxdOpts captures all arguments for running the InfluxDB server.

func NewOpts added in v2.0.6

func NewOpts(viper *viper.Viper) *InfluxdOpts

NewOpts constructs options with default values.

func (*InfluxdOpts) BindCliOpts added in v2.0.6

func (o *InfluxdOpts) BindCliOpts() []cli.Opt

BindCliOpts returns a list of options which can be added to a cobra command in order to set options over the CLI.

type Launcher

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

Launcher represents the main program execution.

func NewLauncher

func NewLauncher() *Launcher

NewLauncher returns a new instance of Launcher with a no-op logger.

func (*Launcher) AuthorizationService

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

AuthorizationService returns the internal authorization service.

func (*Launcher) AuthorizationV1Service added in v2.0.6

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

func (*Launcher) BucketService

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

BucketService returns the internal bucket service.

func (*Launcher) CheckService

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

CheckService returns the internal check service.

func (*Launcher) DBRPMappingService added in v2.1.0

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

func (*Launcher) Done added in v2.0.5

func (m *Launcher) Done() <-chan struct{}

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

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

SecretService returns the internal secret service.

func (*Launcher) SessionService added in v2.0.2

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

func (*Launcher) Shutdown

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

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

func (*Launcher) UserService

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

UserService returns the internal user service.

type OptSetter added in v2.0.4

type OptSetter = func(o *InfluxdOpts)

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

func (t *TemporaryEngine) BackupKVStore(ctx context.Context, w io.Writer) error

func (*TemporaryEngine) BackupShard

func (t *TemporaryEngine) BackupShard(ctx context.Context, w io.Writer, shardID uint64, since time.Time) error

func (*TemporaryEngine) Close

func (t *TemporaryEngine) Close() error

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

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 platform.ID) error

DeleteBucket deletes a bucket from the time-series data.

func (*TemporaryEngine) DeleteBucketRangePredicate

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

DeleteBucketRangePredicate will delete a bucket from the range and predicate.

func (*TemporaryEngine) Flush

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

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

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) RLockKVStore added in v2.1.0

func (t *TemporaryEngine) RLockKVStore()

func (*TemporaryEngine) RUnlockKVStore added in v2.1.0

func (t *TemporaryEngine) RUnlockKVStore()

func (*TemporaryEngine) RestoreBucket

func (t *TemporaryEngine) RestoreBucket(ctx context.Context, id platform.ID, dbi []byte) (map[uint64]uint64, error)

func (*TemporaryEngine) RestoreKVStore

func (t *TemporaryEngine) RestoreKVStore(ctx context.Context, r io.Reader) error

func (*TemporaryEngine) RestoreShard

func (t *TemporaryEngine) RestoreShard(ctx context.Context, shardID uint64, r io.Reader) error

func (*TemporaryEngine) SeriesCardinality

func (t *TemporaryEngine) SeriesCardinality(ctx context.Context, bucketID platform.ID) int64

SeriesCardinality returns the number of series in the engine.

func (*TemporaryEngine) TSDBStore

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

func (*TemporaryEngine) UpdateBucketRetentionPolicy added in v2.0.5

func (t *TemporaryEngine) UpdateBucketRetentionPolicy(ctx context.Context, bucketID platform.ID, upd *influxdb.BucketUpdate) 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 platform.ID, bucketID platform.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   *influxdb.User
	Org    *influxdb.Organization
	Bucket *influxdb.Bucket
	Auth   *influxdb.Authorization
	// 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 NewTestLauncherServer

func NewTestLauncherServer() *TestLauncher

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

func RunAndSetupNewLauncherOrFail added in v2.0.4

func RunAndSetupNewLauncherOrFail(ctx context.Context, tb testing.TB, setters ...OptSetter) *TestLauncher

RunAndSetupNewLauncherOrFail shorcuts the most common pattern used in testing, building a new TestLauncher, running it, and setting it up with an initial user.

func (*TestLauncher) APIClient added in v2.1.0

func (tl *TestLauncher) APIClient(tb testing.TB) *api.APIClient

func (*TestLauncher) AuthorizationService

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

func (*TestLauncher) Backup added in v2.0.5

func (tl *TestLauncher) Backup(tb testing.TB, ctx context.Context, req clibackup.Params) error

func (*TestLauncher) BackupOrFail added in v2.0.5

func (tl *TestLauncher) BackupOrFail(tb testing.TB, ctx context.Context, req clibackup.Params)

func (*TestLauncher) BackupService added in v2.0.5

func (tl *TestLauncher) BackupService(tb testing.TB) *clibackup.Client

func (*TestLauncher) BucketService

func (tl *TestLauncher) BucketService(tb testing.TB) *tenant.BucketClientService

func (*TestLauncher) DashboardService

func (tl *TestLauncher) DashboardService(tb testing.TB) influxdb.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 *influxdb.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) influxdb.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(tb testing.TB) influxdb.NotificationRuleStore

func (*TestLauncher) NumReads

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

func (*TestLauncher) OnBoard

func (tl *TestLauncher) OnBoard(req *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error)

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

func (tl *TestLauncher) OnBoardOrFail(tb testing.TB, req *influxdb.OnboardingRequest) *influxdb.OnboardingResults

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) influxdb.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 *influxdb.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) ResetHTTPCLient added in v2.1.0

func (tl *TestLauncher) ResetHTTPCLient()

func (*TestLauncher) Restore added in v2.0.5

func (tl *TestLauncher) Restore(tb testing.TB, ctx context.Context, req clirestore.Params) error

func (*TestLauncher) RestoreOrFail added in v2.0.5

func (tl *TestLauncher) RestoreOrFail(tb testing.TB, ctx context.Context, req clirestore.Params)

func (*TestLauncher) RestoreService added in v2.0.5

func (tl *TestLauncher) RestoreService(tb testing.TB) *clirestore.Client

func (*TestLauncher) Run

func (tl *TestLauncher) Run(tb zaptest.TestingT, ctx context.Context, setters ...OptSetter) error

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

func (*TestLauncher) RunOrFail added in v2.0.4

func (tl *TestLauncher) RunOrFail(tb testing.TB, ctx context.Context, setters ...OptSetter)

Run executes the program, failing the test if the launcher fails to start.

func (*TestLauncher) SetFlagger added in v2.0.4

func (tl *TestLauncher) SetFlagger(flagger feature.Flagger)

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

func (*TestLauncher) TaskServiceKV

func (tl *TestLauncher) TaskServiceKV(tb testing.TB) taskmodel.TaskService

func (*TestLauncher) TelegrafService

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

func (*TestLauncher) URL added in v2.0.5

func (tl *TestLauncher) URL() *url.URL

URL returns the URL to connect to the HTTP server.

func (*TestLauncher) VariableService

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

func (*TestLauncher) WriteOrFail

func (tl *TestLauncher) WriteOrFail(tb testing.TB, to *influxdb.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