#201 Bug in StatisticsIndexMap - Grinder 3.7.1

closed
Philip Aston
5
2012-09-29
2012-03-15
Fei
No

As I explore the user defined statistics for Grinder, I found some problem. The “userLong4” value is not set correctly during the test.

In data log file, userLong4 has the same value as Test Time. After some investigation, I think the problem is with StatisticsIndexMap. When initializing the longIndexMap, prefix of ++ is used, which leaves out the index 0; but afterwards, when creating the sampleIndex, postfix of ++ is used which causes index collision: timedTests.sum overwrites the index of userLong4.

for (String longName : longNames) {
m_longMap.put(longName, new LongIndex(++nextLongIndex));
}

createLongSampleIndex("timedTests",
new LongIndex(nextLongIndex++), //collision occurs
new LongIndex(nextLongIndex++),
new DoubleIndex(nextDoubleIndex++));

Sample Script

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest

test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())

grinder.statistics.registerDataLogExpression("userLong0", "userLong0");
grinder.statistics.registerDataLogExpression("userLong1", "userLong1");
grinder.statistics.registerDataLogExpression("userLong2", "userLong2");
grinder.statistics.registerDataLogExpression("userLong3", "userLong3");
grinder.statistics.registerDataLogExpression("userLong4", "userLong4");

class TestRunner:
def call(self):
grinder.statistics.delayReports = 1
request1.GET("http://www.google.com")
runNumber = grinder.getRunNumber()
if(0 == (runNumber % 3)):
grinder.statistics.forLastTest.success = 0
grinder.statistics.forLastTest.setLong("userLong0",1000)
grinder.statistics.forLastTest.setLong("userLong1",1001)
grinder.statistics.forLastTest.setLong("userLong2",1002)
grinder.statistics.forLastTest.setLong("userLong3",1003)
grinder.statistics.forLastTest.setLong("userLong4",1004)
grinder.statistics.report()
grinder.statistics.delayReports = 0

Discussion