Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

continuous-test as module #7747

Merged
merged 22 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6614cb5
Break out config
johannaratliff Mar 15, 2024
fd184d4
Convert continuousTestManager to service
johannaratliff Mar 15, 2024
4f20f22
Use continuousTest as a module
johannaratliff Mar 15, 2024
fbea9ff
Not private
johannaratliff Mar 15, 2024
5dfcfe2
WIP + broken
johannaratliff Mar 26, 2024
0a75513
super advanced debugging with log statements
johannaratliff Mar 26, 2024
222b5f0
WIP
johannaratliff Mar 27, 2024
fe999f9
Clean up reinstantiating unnecessary parts of the module
johannaratliff Mar 28, 2024
4219c9d
Unnecessary since it's only used in the independent continuous-test a…
johannaratliff Mar 28, 2024
8263e32
Pulling out config file abilities because it didn't exist before so i…
johannaratliff Mar 28, 2024
0f582e2
continuous-test does not need to be in development docker-compose
johannaratliff Mar 28, 2024
5fe76b1
make reference-help
johannaratliff Mar 29, 2024
50b16c3
make reference-help
johannaratliff Mar 29, 2024
654c6d5
Get rid of any config file abilities for continuous-test: unnecessary
johannaratliff Mar 29, 2024
574a045
make reference-help
johannaratliff Mar 29, 2024
095a137
CHANGELOG entry
johannaratliff Mar 29, 2024
56b41c2
Merge branch 'main' into continuous-test-subcommand
johannaratliff Mar 29, 2024
30470f3
start function redundant in an init
johannaratliff Mar 29, 2024
6c43b47
Remove TODO comment
johannaratliff Mar 29, 2024
b4a650f
Remove config parts only applicable to main binary backward compatibi…
johannaratliff Mar 29, 2024
578d527
Change to use other module approach of Manager as services.Service
johannaratliff Mar 29, 2024
900c0d8
Revert "Change to use other module approach of Manager as services.Se…
johannaratliff Mar 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should add a YAML section if this is going to be a standard part of Mimir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree as it doesn't run as a default startup piece of Mimir with target=all. It's currently usable as a standalone docker image with flags passed and doesn't take a config file and I think keeping it as close to current usage as possible is the best approach. I was including config for it originally and decided that passing config via file isn't something currently anyone has asked for so to hold off

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other components of Mimir that have CLI flags have a corresponding YAML configuration. That makes this particular feature inconsistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree re consistency. Adding YAML support will also expose all the continuous-test flags in reference documentation, which would be quite ugly, but now that continuous-test is part of Mimir, I think we should do it.

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
Loading