jmeter-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 60729] New: RandomVariableConfig should allow minimum==maximum
Date Mon, 13 Feb 2017 18:45:58 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

            Bug ID: 60729
           Summary: RandomVariableConfig should allow minimum==maximum
           Product: JMeter
           Version: 3.1
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
          Assignee: issues@jmeter.apache.org
          Reporter: rainer.jung@kippdata.de
  Target Milestone: ---

Currently RandomVariableConfig checks for maximum > minimum and complains
otherwise. I have a situation where I create random values using
RandomVariableConfig in some given range and sometimes I need that range to be
exactly one number.

E.g. the random value could be the number of products you want to buy but for a
simple base test you always want only one product. I retrieve minimum and
maximum from JMeter variables and it would be trivial to set both to "1" to get
that behavior.

Unfortunately RandomVariableConfig only accepts minimum < maximum, not minimum
== maximum. Note that the Random math still works for minimum == maximum,
because range = maximum - minimum + 1 would be 1 and we would generate minimum
+ randGen.nextInt(range) = minimum + randGen.nextInt(1) = minimum + 0 = minimum
(== maximum), which would be the expected result.

The docs do not mention the condition on minimum and maximum, so there's no
docs change involved.

I'm going to apply the following (trivial) patch unless someone opposes:

Index: components/org/apache/jmeter/config/RandomVariableConfig.java
===================================================================
--- components/org/apache/jmeter/config/RandomVariableConfig.java      
(revision 1782826)
+++ components/org/apache/jmeter/config/RandomVariableConfig.java      
(working copy)
@@ -91,8 +91,8 @@
         final String maxAsString = getMaximumValue();
         long maximum = NumberUtils.toLong(maxAsString);
         long rangeL=maximum-minimum+1; // This can overflow
-        if (minimum >= maximum){
-            log.error("maximum({}) must be > minimum({})", maxAsString,
minAsString);
+        if (minimum > maximum){
+            log.error("maximum({}) must be >= minimum({})", maxAsString,
minAsString);
             range=0;// This is used as an error indicator
             return;
         }

Regards,

Rainer

-- 
You are receiving this mail because:
You are the assignee for the bug.
Mime
View raw message