From 9c491a0fd57558be8eb7ab2900750955c9d05f2e Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 21 Jan 2020 16:08:11 -0500 Subject: [PATCH 1/4] Add --load-test-id param for master, exposed through Prometheus --- pkg/loadtest/cli.go | 1 + pkg/loadtest/config.go | 4 ++++ pkg/loadtest/master.go | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/pkg/loadtest/cli.go b/pkg/loadtest/cli.go index a9541dc..f90394f 100644 --- a/pkg/loadtest/cli.go +++ b/pkg/loadtest/cli.go @@ -91,6 +91,7 @@ func buildCLI(cli *CLIConfig, logger logging.Logger) *cobra.Command { masterCmd.PersistentFlags().IntVar(&masterCfg.ExpectSlaves, "expect-slaves", 2, "The number of slaves to expect to connect to the master before starting load testing") masterCmd.PersistentFlags().IntVar(&masterCfg.SlaveConnectTimeout, "connect-timeout", 180, "The maximum number of seconds to wait for all slaves to connect") masterCmd.PersistentFlags().IntVar(&masterCfg.ShutdownWait, "shutdown-wait", 0, "The number of seconds to wait after testing completes prior to shutting down the web server") + masterCmd.PersistentFlags().IntVar(&masterCfg.LoadTestID, "load-test-id", 0, "The ID of the load test currently underway") var slaveCfg SlaveConfig slaveCmd := &cobra.Command{ diff --git a/pkg/loadtest/config.go b/pkg/loadtest/config.go index 54162b5..dbbee2d 100644 --- a/pkg/loadtest/config.go +++ b/pkg/loadtest/config.go @@ -44,6 +44,7 @@ type MasterConfig struct { ExpectSlaves int `json:"expect_slaves"` // The number of slaves to expect before starting the load test. SlaveConnectTimeout int `json:"connect_timeout"` // The number of seconds to wait for all slaves to connect. ShutdownWait int `json:"shutdown_wait"` // The number of seconds to wait at shutdown (while keeping the HTTP server running - primarily to allow Prometheus to keep polling). + LoadTestID int `json:"load_test_id"` // An integer greater than 0 that will be exposed via a Prometheus gauge while the load test is underway. } // SlaveConfig is the configuration options specific to a slave node. @@ -126,6 +127,9 @@ func (c MasterConfig) Validate() error { if c.SlaveConnectTimeout < 1 { return fmt.Errorf("master connect-timeout must be at least 1 second") } + if c.LoadTestID < 0 { + return fmt.Errorf("master load-test-id must be 0 or greater") + } return nil } diff --git a/pkg/loadtest/master.go b/pkg/loadtest/master.go index 695573c..506f666 100644 --- a/pkg/loadtest/master.go +++ b/pkg/loadtest/master.go @@ -60,6 +60,7 @@ type Master struct { txRateMetric prometheus.Gauge // The transaction throughput rate (tx/sec) as measured by the master since the last metrics update. overallTxRateMetric prometheus.Gauge // The overall transaction throughput rate (tx/sec) as measured by the master since the beginning of the load test. slavesCompletedMetric prometheus.Gauge // The total number of slaves that have completed their testing. + testUnderwayMetric prometheus.Gauge // The ID of the load test currently underway (-1 if none). mtx sync.Mutex cancelled bool @@ -113,6 +114,10 @@ func NewMaster(cfg *Config, masterCfg *MasterConfig) *Master { Name: "tmloadtest_master_slaves_completed", Help: "The total number of slaves that have completed their testing so far", }), + testUnderwayMetric: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "tmloadtest_master_test_underway", + Help: "The ID of the load test currently underway (-1 if none)", + }), } mux := http.NewServeMux() mux.HandleFunc("/", master.newWebSocketHandler()) @@ -123,6 +128,7 @@ func NewMaster(cfg *Config, masterCfg *MasterConfig) *Master { } master.svr = svr master.stateMetric.Set(masterStarting) + master.testUnderwayMetric.Set(-1) return master } @@ -229,6 +235,12 @@ func (m *Master) receiveTestingUpdates() error { m.logger.Info("Watching for slave updates") m.stateMetric.Set(masterTesting) + // we set the current test underway ID to our configured load test ID for + // the duration of the test + m.testUnderwayMetric.Set(float64(m.masterCfg.LoadTestID)) + // and we set it to -1 the moment all slaves are done + defer m.testUnderwayMetric.Set(-1) + completed := 0 progressTicker := time.NewTicker(masterProgressUpdateInterval) From e9441694333d4f3bf7684f97f0422f30d4f04253 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 21 Jan 2020 16:08:33 -0500 Subject: [PATCH 2/4] Update README for new --load-test-id param --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 514be2f..3100c3a 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,8 @@ The following kinds of metrics are made available here: * 5 = Slave completed load testing successfully * Standard Prometheus-provided metrics about the garbage collector in `tm-load-test` +* The ID of the load test currently underway (defaults to 0), set by way of the + `--load-test-id` flag on the master ## Aggregate Statistics As of `tm-load-test` v0.7.0, one can now write simple aggregate statistics to From 531dc048371153002a622b66b945fd7ab9a675c4 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 21 Jan 2020 16:11:26 -0500 Subject: [PATCH 3/4] Bump version to v0.8.0 for new feature release --- pkg/loadtest/cli.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/loadtest/cli.go b/pkg/loadtest/cli.go index f90394f..028ed6b 100644 --- a/pkg/loadtest/cli.go +++ b/pkg/loadtest/cli.go @@ -12,7 +12,7 @@ import ( ) // CLIVersion must be manually updated as new versions are released. -const CLIVersion = "v0.7.0" +const CLIVersion = "v0.8.0" // cliVersionCommitID must be set through linker settings. See // https://stackoverflow.com/a/11355611/1156132 for details. From b471d20e8651dc31e6fe7d14f2baef95c70c3134 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 21 Jan 2020 16:12:37 -0500 Subject: [PATCH 4/4] Add CHANGELOG entry for v0.8.0 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b48148..dfc368d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ # Changelog +## v0.8.0 +* [\#42](https://github.com/interchainio/tm-load-test/pull/42) - Add Prometheus + gauge for when load test is underway. This indicator exposes a customizable + load test ID. + +## v0.7.1 +* Re-released due to v0.7.0 being incorrectly tagged + ## v0.7.0 -* [\#39](https://github.com/interchainio/tm-load-test/issues/39) - Add basic +* [\#39](https://github.com/interchainio/tm-load-test/pull/40) - Add basic aggregate statistics output to CSV file. * Added integration test for standalone execution happy path.