You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jmeter.apache.org by bu...@apache.org on 2017/02/13 18:45:58 UTC

[Bug 60729] New: RandomVariableConfig should allow minimum==maximum

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.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #2 from Rainer Jung <ra...@kippdata.de> ---
Thanks. I'm in the middle of preparing tests. I'll include the fixes fpor the
other two comparisons.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #7 from Rainer Jung <ra...@kippdata.de> ---
Author: rjung
Date: Mon Feb 13 21:23:23 2017
New Revision: 1782880

URL: http://svn.apache.org/viewvc?rev=1782880&view=rev
Log:
Add info about BZ 60729 (the Random Variable
Config Element should allow minimum==maximum)
to changes.

Modified:
    jmeter/trunk/xdocs/changes.xml

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #3 from Rainer Jung <ra...@kippdata.de> ---
Actzually these do not need changing. range comes from rangeL which was set to
rangeL=maximum-minimum+1, so for minimum==maximum range is and should be 1. So
comparing against 0 (which is used as a special marker value) is fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #6 from Rainer Jung <ra...@kippdata.de> ---
> Hi Rainer, 
> Can't this fix break existing test plans ? I don't think so but you've
> investigated it more than me.
> Maybe a note in incompatible changes would be useful in this case.
> Thanks for patch and fix.

Behavior before that change: when minimum==maximum you got an error in the log,
but the test plan proceeded without the defined variable being set to any
value.

So yes, it can break plans and I will add a note, but I think just not setting
the variable when minimum==maximum is wrong. Thus the fix.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

Rainer Jung <ra...@kippdata.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Rainer Jung <ra...@kippdata.de> ---
Will be part of version 3.2:

Author: rjung
Date: Mon Feb 13 20:07:52 2017
New Revision: 1782848

URL: http://svn.apache.org/viewvc?rev=1782848&view=rev
Log:
Allow minimum == maximum in Random Variable Config Element.

Bugzilla Id: 60729

Modified:
   
jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #5 from UbikLoadPack support <su...@ubikloadpack.com> ---
(In reply to Rainer Jung from comment #4)
> Will be part of version 3.2:
> 
> Author: rjung
> Date: Mon Feb 13 20:07:52 2017
> New Revision: 1782848
> 
> URL: http://svn.apache.org/viewvc?rev=1782848&view=rev
> Log:
> Allow minimum == maximum in Random Variable Config Element.
> 
> Bugzilla Id: 60729
> 
> Modified:
>    
> jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.
> java

Hi Rainer, 
Can't this fix break existing test plans ? I don't think so but you've
investigated it more than me.
Maybe a note in incompatible changes would be useful in this case.
Thanks for patch and fix.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 60729] RandomVariableConfig should allow minimum==maximum

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60729

--- Comment #1 from Vladimir Sitnikov <si...@gmail.com> ---
Have you tried that patch?

It looks other uses of range should be corrected as well:
https://github.com/vlsi/jmeter/blob/7ebfa083afd0b4e2be069b2a8a654bc33fe761cf/src/components/org/apache/jmeter/config/RandomVariableConfig.java#L99-L99
and
https://github.com/vlsi/jmeter/blob/7ebfa083afd0b4e2be069b2a8a654bc33fe761cf/src/components/org/apache/jmeter/config/RandomVariableConfig.java#L121.

-- 
You are receiving this mail because:
You are the assignee for the bug.