From 061636aba2498a7015dd2ce57effc7f7474e6754 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Mon, 11 Dec 2023 01:40:56 +0100 Subject: [PATCH] change logic for jmeter so that SLAVES_COUNT == zero or undefined works in standalone mode, and > 0 runs in distributed mode --- contrib/executor/jmeterd/pkg/runner/runner.go | 2 +- contrib/executor/jmeterd/pkg/slaves/utils.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/executor/jmeterd/pkg/runner/runner.go b/contrib/executor/jmeterd/pkg/runner/runner.go index 7518fda0793..7d4195c6756 100644 --- a/contrib/executor/jmeterd/pkg/runner/runner.go +++ b/contrib/executor/jmeterd/pkg/runner/runner.go @@ -92,7 +92,7 @@ func (r *JMeterDRunner) Run(ctx context.Context, execution testkube.Execution) ( } mode := jmeterModeStandalone jmeterParamFlag := standaloneJMeterParamPrefix - if slavesCount > 1 { + if slavesCount > 0 { mode = jmeterModeDistributed jmeterParamFlag = globalJMeterParamPrefix } diff --git a/contrib/executor/jmeterd/pkg/slaves/utils.go b/contrib/executor/jmeterd/pkg/slaves/utils.go index 5f9e8b17573..5b936ed0aea 100644 --- a/contrib/executor/jmeterd/pkg/slaves/utils.go +++ b/contrib/executor/jmeterd/pkg/slaves/utils.go @@ -16,7 +16,7 @@ import ( ) const ( - defaultSlavesCount = 1 + defaultSlavesCount = 0 serverPort = 1099 localPort = 60001 ) @@ -90,14 +90,14 @@ func GetSlavesCount(vars map[string]testkube.Variable) (int, error) { return defaultSlavesCount, nil } - replicaCount, err := strconv.Atoi(count.Value) + slavesCount, err := strconv.Atoi(count.Value) if err != nil { return 0, errors.Errorf("invalid SLAVES_COUNT value, expected integer, got: %v", count.Value) } - if replicaCount < 1 { - return 0, errors.Errorf("SLAVES_COUNT must be at least 1") + if slavesCount < 0 { + return 0, errors.Errorf("SLAVES_COUNT cannot be less than 0, got: %v", count.Value) } - return replicaCount, err + return slavesCount, err } func validateAndGetSlavePodName(testName string, executionId string, currentSlaveCount int) string {