Skip to content

Commit

Permalink
loadtest: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Sep 5, 2024
1 parent 72551b4 commit 553fa54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
15 changes: 7 additions & 8 deletions itest/loadtest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ type BitcoinConfig struct {

// PrometheusGatewayConfig defines exported config options for connecting to the
// Prometheus PushGateway.
//
//nolint:lll
type PrometheusGatewayConfig struct {
// nolint: lll
Enabled bool `long:"enabled" description:"Enable pushing metrics to Prometheus PushGateway"`
// nolint: lll
Enabled bool `long:"enabled" description:"Enable pushing metrics to Prometheus PushGateway"`
Host string `long:"host" description:"Prometheus PushGateway host address"`
Port int `long:"port" description:"Prometheus PushGateway port"`
PushURL string
}

// Config holds the main configuration for the performance testing binary.
//
//nolint:lll
type Config struct {
// TestCases is a comma separated list of test cases that will be
// executed.
Expand Down Expand Up @@ -111,8 +113,6 @@ type Config struct {

// PrometheusGateway is the configuration for the Prometheus
// PushGateway.
//
// nolint: lll
PrometheusGateway *PrometheusGatewayConfig `group:"prometheus-gateway" namespace:"prometheus-gateway" description:"Prometheus PushGateway configuration"`
}

Expand Down Expand Up @@ -185,9 +185,8 @@ func ValidateConfig(cfg Config) (*Config, error) {
gatewayPort := cfg.PrometheusGateway.Port

if gatewayHost == "" {
return nil, fmt.Errorf(
"gateway hostname may not be empty",
)
return nil, fmt.Errorf("gateway hostname may not be " +
"empty")
}

if gatewayPort == 0 {
Expand Down
20 changes: 12 additions & 8 deletions itest/loadtest/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func TestPerformance(t *testing.T) {
t.Fatalf("test case %v failed", tc.name)
}

// Calculate the test duration and push metrics if the test case succeeded.
// Calculate the test duration and push metrics if the test case
// succeeded.
if cfg.PrometheusGateway.Enabled {
duration := time.Since(startTime).Seconds()

Expand All @@ -93,19 +94,22 @@ func TestPerformance(t *testing.T) {
// Update the metric with the test duration.
testDuration.WithLabelValues(label).Set(duration)

t.Logf("Pushing testDuration %v with label %v to gateway", duration, label)
t.Logf("Pushing testDuration %v with label %v to "+
"gateway", duration, label)

// Create a new pusher to push the metrics.
pusher := push.New(cfg.PrometheusGateway.PushURL, "load_test").
Collector(testDuration)
pusher := push.New(
cfg.PrometheusGateway.PushURL, "load_test",
).Collector(testDuration)

// Push the metrics to Prometheus PushGateway.
if err := pusher.Add(); err != nil {
t.Logf("Could not push metrics to Prometheus PushGateway: %v",
err)
t.Logf("Could not push metrics to Prometheus "+
"PushGateway: %v", err)
} else {
t.Logf("Metrics pushed for test case '%s': duration = %v seconds",
tc.name, duration)
t.Logf("Metrics pushed for test case '%s': "+
"duration = %v seconds", tc.name,
duration)
}
}
}
Expand Down

0 comments on commit 553fa54

Please sign in to comment.