Skip to content

Commit

Permalink
Insert continuous-test as a module (#7747)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaratliff authored Apr 1, 2024
1 parent cd13a1b commit 63865eb
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [CHANGE] Querier: the CLI flag `-querier.minimize-ingester-requests` has been moved from "experimental" to "advanced". #7638
* [CHANGE] Ingester: `/ingester/flush` endpoint is now only allowed to execute only while the ingester is in `Running` state. The 503 status code is returned if the endpoint is called while the ingester is not in `Running` state. #7486
* [CHANGE] Distributor: Include label name in `err-mimir-label-value-too-long` error message: #7740
* [FEATURE] Continuous-test: now runable as a module with `mimir -target=continuous-test`. #7747
* [FEATURE] Store-gateway: Allow specific tenants to be enabled or disabled via `-store-gateway.enabled-tenants` or `-store-gateway.disabled-tenants` CLI flags or their corresponding YAML settings. #7653
* [FEATURE] New `-<prefix>.s3.bucket-lookup-type` flag configures lookup style type, used to access bucket in s3 compatible providers. #7684
* [ENHANCEMENT] Store-gateway: merge series from different blocks concurrently. #7456
Expand Down
28 changes: 9 additions & 19 deletions cmd/mimir-continuous-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,23 @@ import (
"github.com/grafana/mimir/pkg/util/version"
)

type Config struct {
ServerMetricsPort int
LogLevel log.Level
Client continuoustest.ClientConfig
Manager continuoustest.ManagerConfig
WriteReadSeriesTest continuoustest.WriteReadSeriesTestConfig
}

func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.IntVar(&cfg.ServerMetricsPort, "server.metrics-port", 9900, "The port where metrics are exposed.")
cfg.LogLevel.RegisterFlags(f)
cfg.Client.RegisterFlags(f)
cfg.Manager.RegisterFlags(f)
cfg.WriteReadSeriesTest.RegisterFlags(f)
}

func main() {
// Parse CLI arguments.
cfg := &Config{}
cfg := &continuoustest.Config{}
var (
serverMetricsPort int
logLevel log.Level
)
flag.CommandLine.IntVar(&serverMetricsPort, "server.metrics-port", 9900, "The port where metrics are exposed.")
cfg.RegisterFlags(flag.CommandLine)
logLevel.RegisterFlags(flag.CommandLine)

if err := flagext.ParseFlagsWithoutArguments(flag.CommandLine); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

util_log.InitLogger(log.LogfmtFormat, cfg.LogLevel, false, util_log.RateLimitedLoggerCfg{})
util_log.InitLogger(log.LogfmtFormat, logLevel, false, util_log.RateLimitedLoggerCfg{})

// Setting the environment variable JAEGER_AGENT_HOST enables tracing.
if trace, err := tracing.NewFromEnv("mimir-continuous-test", jaegercfg.MaxTagValueLength(16e3)); err != nil {
Expand All @@ -64,7 +54,7 @@ func main() {
registry.MustRegister(version.NewCollector("mimir_continuous_test"))
registry.MustRegister(collectors.NewGoCollector())

i := instrumentation.NewMetricsServer(cfg.ServerMetricsPort, registry)
i := instrumentation.NewMetricsServer(serverMetricsPort, registry)
if err := i.Start(); err != nil {
level.Error(logger).Log("msg", "Unable to start instrumentation server", "err", err.Error())
util_log.Flush()
Expand Down
32 changes: 32 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,38 @@ Usage of ./cmd/mimir/mimir:
[experimental] The number of workers used for each tenant federated query. This setting limits the maximum number of per-tenant queries executed at a time for a tenant federated query. (default 16)
-tenant-federation.max-tenants int
[experimental] The max number of tenant IDs that may be supplied for a federated query if enabled. 0 to disable the limit.
-tests.basic-auth-password string
The password to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags)
-tests.basic-auth-user string
The username to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags)
-tests.bearer-token string
The bearer token to use for HTTP bearer authentication. (mutually exclusive with tenant-id flag or basic-auth flags)
-tests.read-endpoint string
The base endpoint on the read path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/query_range for range query API, so the configured URL must not include it.
-tests.read-timeout duration
The timeout for a single read request. (default 1m0s)
-tests.run-interval duration
How frequently tests should run. (default 5m0s)
-tests.smoke-test
Run a smoke test, i.e. run all tests once and exit.
-tests.tenant-id string
The tenant ID to use to write and read metrics in tests. (mutually exclusive with basic-auth or bearer-token flags) (default "anonymous")
-tests.write-batch-size int
The maximum number of series to write in a single request. (default 1000)
-tests.write-endpoint string
The base endpoint on the write path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/push for the remote write API endpoint, so the configured URL must not include it.
-tests.write-protocol string
The protocol to use to write series data. Supported values are: prometheus, otlp-http (default "prometheus")
-tests.write-read-series-test.float-samples-enabled
Set to true to use float samples (default true)
-tests.write-read-series-test.histogram-samples-enabled
Set to true to use native histogram samples
-tests.write-read-series-test.max-query-age duration
How back in the past metrics can be queried at most. (default 168h0m0s)
-tests.write-read-series-test.num-series int
Number of series used for the test. (default 10000)
-tests.write-timeout duration
The timeout for a single write request. (default 5s)
-timeseries-unmarshal-caching-optimization-enabled
[experimental] Enables optimized marshaling of timeseries. (default true)
-usage-stats.enabled
Expand Down
32 changes: 32 additions & 0 deletions cmd/mimir/help.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,38 @@ Usage of ./cmd/mimir/mimir:
Comma-separated list of components to include in the instantiated process. The default value 'all' includes all components that are required to form a functional Grafana Mimir instance in single-binary mode. Use the '-modules' command line flag to get a list of available components, and to see which components are included with 'all'. (default all)
-tenant-federation.enabled
If enabled on all services, queries can be federated across multiple tenants. The tenant IDs involved need to be specified separated by a '|' character in the 'X-Scope-OrgID' header.
-tests.basic-auth-password string
The password to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags)
-tests.basic-auth-user string
The username to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags)
-tests.bearer-token string
The bearer token to use for HTTP bearer authentication. (mutually exclusive with tenant-id flag or basic-auth flags)
-tests.read-endpoint string
The base endpoint on the read path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/query_range for range query API, so the configured URL must not include it.
-tests.read-timeout duration
The timeout for a single read request. (default 1m0s)
-tests.run-interval duration
How frequently tests should run. (default 5m0s)
-tests.smoke-test
Run a smoke test, i.e. run all tests once and exit.
-tests.tenant-id string
The tenant ID to use to write and read metrics in tests. (mutually exclusive with basic-auth or bearer-token flags) (default "anonymous")
-tests.write-batch-size int
The maximum number of series to write in a single request. (default 1000)
-tests.write-endpoint string
The base endpoint on the write path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/push for the remote write API endpoint, so the configured URL must not include it.
-tests.write-protocol string
The protocol to use to write series data. Supported values are: prometheus, otlp-http (default "prometheus")
-tests.write-read-series-test.float-samples-enabled
Set to true to use float samples (default true)
-tests.write-read-series-test.histogram-samples-enabled
Set to true to use native histogram samples
-tests.write-read-series-test.max-query-age duration
How back in the past metrics can be queried at most. (default 168h0m0s)
-tests.write-read-series-test.num-series int
Number of series used for the test. (default 10000)
-tests.write-timeout duration
The timeout for a single write request. (default 5s)
-usage-stats.enabled
Enable anonymous usage reporting. (default true)
-usage-stats.installation-mode string
Expand Down
19 changes: 19 additions & 0 deletions pkg/continuoustest/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: AGPL-3.0-only

package continuoustest

import (
"flag"
)

type Config struct {
Client ClientConfig `yaml:"-"`
Manager ManagerConfig `yaml:"-"`
WriteReadSeriesTest WriteReadSeriesTestConfig `yaml:"-"`
}

func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
cfg.Client.RegisterFlags(f)
cfg.Manager.RegisterFlags(f)
cfg.WriteReadSeriesTest.RegisterFlags(f)
}
4 changes: 4 additions & 0 deletions pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
alertstorelocal "github.com/grafana/mimir/pkg/alertmanager/alertstore/local"
"github.com/grafana/mimir/pkg/api"
"github.com/grafana/mimir/pkg/compactor"
"github.com/grafana/mimir/pkg/continuoustest"
"github.com/grafana/mimir/pkg/distributor"
"github.com/grafana/mimir/pkg/flusher"
"github.com/grafana/mimir/pkg/frontend"
Expand Down Expand Up @@ -135,6 +136,7 @@ type Config struct {
MemberlistKV memberlist.KVConfig `yaml:"memberlist"`
QueryScheduler scheduler.Config `yaml:"query_scheduler"`
UsageStats usagestats.Config `yaml:"usage_stats"`
ContinuousTest continuoustest.Config `yaml:"-"`
OverridesExporter exporter.Config `yaml:"overrides_exporter"`

Common CommonConfig `yaml:"common"`
Expand Down Expand Up @@ -192,6 +194,7 @@ func (c *Config) RegisterFlags(f *flag.FlagSet, logger log.Logger) {
c.ActivityTracker.RegisterFlags(f)
c.QueryScheduler.RegisterFlags(f, logger)
c.UsageStats.RegisterFlags(f)
c.ContinuousTest.RegisterFlags(f)
c.OverridesExporter.RegisterFlags(f, logger)

c.Common.RegisterFlags(f)
Expand Down Expand Up @@ -720,6 +723,7 @@ type Mimir struct {
ActivityTracker *activitytracker.ActivityTracker
Vault *vault.Vault
UsageStatsReporter *usagestats.Reporter
ContinuousTestManager *continuoustest.Manager
BuildInfoHandler http.Handler
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/mimir/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/grafana/mimir/pkg/alertmanager/alertstore"
"github.com/grafana/mimir/pkg/api"
"github.com/grafana/mimir/pkg/compactor"
"github.com/grafana/mimir/pkg/continuoustest"
"github.com/grafana/mimir/pkg/distributor"
"github.com/grafana/mimir/pkg/flusher"
"github.com/grafana/mimir/pkg/frontend"
Expand Down Expand Up @@ -97,6 +98,7 @@ const (
Vault string = "vault"
TenantFederation string = "tenant-federation"
UsageStats string = "usage-stats"
ContinuousTest string = "continuous-test"
All string = "all"

// Write Read and Backend are the targets used when using the read-write deployment mode.
Expand Down Expand Up @@ -1034,6 +1036,20 @@ func (t *Mimir) initUsageStats() (services.Service, error) {
return t.UsageStatsReporter, nil
}

func (t *Mimir) initContinuousTest() (services.Service, error) {
client, err := continuoustest.NewClient(t.Cfg.ContinuousTest.Client, util_log.Logger)
if err != nil {
return nil, errors.Wrap(err, "Failed to initialize continuous-test client")
}

t.ContinuousTestManager = continuoustest.NewManager(t.Cfg.ContinuousTest.Manager, util_log.Logger)
t.ContinuousTestManager.AddTest(continuoustest.NewWriteReadSeriesTest(t.Cfg.ContinuousTest.WriteReadSeriesTest, client, util_log.Logger, t.Registerer))

return services.NewBasicService(nil, func(ctx context.Context) error {
return t.ContinuousTestManager.Run(ctx)
}, nil), nil
}

func (t *Mimir) setupModuleManager() error {
mm := modules.NewManager(util_log.Logger)

Expand Down Expand Up @@ -1069,6 +1085,7 @@ func (t *Mimir) setupModuleManager() error {
mm.RegisterModule(QueryScheduler, t.initQueryScheduler)
mm.RegisterModule(TenantFederation, t.initTenantFederation, modules.UserInvisibleModule)
mm.RegisterModule(UsageStats, t.initUsageStats, modules.UserInvisibleModule)
mm.RegisterModule(ContinuousTest, t.initContinuousTest)
mm.RegisterModule(Vault, t.initVault, modules.UserInvisibleModule)
mm.RegisterModule(Write, nil)
mm.RegisterModule(Read, nil)
Expand Down Expand Up @@ -1102,6 +1119,7 @@ func (t *Mimir) setupModuleManager() error {
Compactor: {API, MemberlistKV, Overrides, Vault},
StoreGateway: {API, Overrides, MemberlistKV, Vault},
TenantFederation: {Queryable},
ContinuousTest: {API},
Write: {Distributor, Ingester},
Read: {QueryFrontend, Querier},
Backend: {QueryScheduler, Ruler, StoreGateway, Compactor, AlertManager, OverridesExporter},
Expand Down

0 comments on commit 63865eb

Please sign in to comment.