You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Shmuel Krakower <sh...@gmail.com> on 2013/04/15 11:23:15 UTC

CSV dataset to refresh value with every reference

Hi all,
The normal behavior of CSV dataset is to give us the next value with each
iteration on the local thread. I.e. single thread test will get new value
as new iteration begins.

I have a need that with each time I reference the variable from the CSV
config element, I'll get the next value.
Maybe that's something silly easy, but I cannot find how to do that.

Best,

Shmuel Krakower.
www.Beatsoo.org - re-use your jmeter scripts for application performance
monitoring from worldwide locations for free.

Re: CSV dataset to refresh value with every reference

Posted by Shmuel Krakower <sh...@gmail.com>.
Yeah! Exactly what I need.
Thanks for the simple solution.
On Apr 15, 2013 9:22 PM, "Deepak Shetty" <sh...@gmail.com> wrote:

> if you want to control when you read the CSV why not use CSVRead function
> or StringFromFile ?
>
>
> On Mon, Apr 15, 2013 at 8:42 AM, Shmuel Krakower <sh...@gmail.com>
> wrote:
>
> > Thanks for the response.
> > I'd guess I can give it a try in a bit different way.
> >
> > The only problem is that in my case I need ten different values out of
> the
> > file with each sample (I am sending 10 different user IDs to get their
> data
> > with specific API call).
> > The cleanest solution is to add another option to the CSV Dataset Config
> > Element, so it will support such case.
> > Adding another config option like: Refresh value on: Every reference,
> Every
> > iteration.
> >
> > Another option I have in mind is if the CSV config create an array of all
> > items in CSV file, I can randomly generate the item I wanna get out of
> the
> > array of items. Something similar to the way the regex extractor can
> create
> > arrays.
> >
> > Shmuel Krakower.
> > www.Beatsoo.org - re-use your jmeter scripts for application performance
> > monitoring from worldwide locations for free.
> >
> >
> > On Mon, Apr 15, 2013 at 6:00 PM, Flavio Cysne <fl...@gmail.com>
> > wrote:
> >
> > > AFAIK, there isn't a method to do a "readNext" on the CSV file.
> > >
> > > Maybe using a BeanShell Post-Processor to simulate part of
> > > the iterationStart method in CSVDataSet class is a way to solve it.
> > >
> > >
> > > Code extracted from iterationStart method that is relevant to the
> > question:
> > >
> > > 103        FileServer server = FileServer.getFileServer();
> > > ...
> > > 113            String _fileName = getFilename();
> > > 114            String mode = getShareMode();
> > > 115            int modeInt =
> CSVDataSetBeanInfo.getShareModeAsInt(mode);
> > > 116            switch(modeInt){
> > > 117                case CSVDataSetBeanInfo.SHARE_ALL:
> > > 118                    alias = _fileName;
> > > 119                    break;
> > > 120                case CSVDataSetBeanInfo.SHARE_GROUP:
> > > 121                    alias =
> > > _fileName+"@"+System.identityHashCode(context.getThreadGroup());
> > > 122                    break;
> > > 123                case CSVDataSetBeanInfo.SHARE_THREAD:
> > > 124                    alias =
> > > _fileName+"@"+System.identityHashCode(context.getThread());
> > > 125                    break;
> > > 126                default:
> > > 127                    alias = _fileName+"@"+mode; // user-specified
> key
> > > 128                    break;
> > > 129            }
> > > ...
> > > 149               if (getQuotedData()) {
> > > 150                lineValues = server.getParsedLine(alias, recycle,
> > > firstLineIsNames, delim.charAt(0));
> > > 151            } else {
> > > 152                String line = server.readLine(alias, recycle,
> > > firstLineIsNames);
> > > 153                lineValues = JOrphanUtils.split(line, delim, false);
> > > 154            }
> > >
> > >
> > > With some aspects already known from CSV Dataset Config you could
> > restrict
> > > the code executed in BeanShell to a few lines.
> > >
> > >
> > >
> > >
> > > 2013/4/15 Shmuel Krakower <sh...@gmail.com>
> > >
> > > > Hi all,
> > > > The normal behavior of CSV dataset is to give us the next value with
> > each
> > > > iteration on the local thread. I.e. single thread test will get new
> > value
> > > > as new iteration begins.
> > > >
> > > > I have a need that with each time I reference the variable from the
> CSV
> > > > config element, I'll get the next value.
> > > > Maybe that's something silly easy, but I cannot find how to do that.
> > > >
> > > > Best,
> > > >
> > > > Shmuel Krakower.
> > > > www.Beatsoo.org - re-use your jmeter scripts for application
> > performance
> > > > monitoring from worldwide locations for free.
> > > >
> > >
> >
>

Re: CSV dataset to refresh value with every reference

Posted by Deepak Shetty <sh...@gmail.com>.
if you want to control when you read the CSV why not use CSVRead function
or StringFromFile ?


On Mon, Apr 15, 2013 at 8:42 AM, Shmuel Krakower <sh...@gmail.com> wrote:

> Thanks for the response.
> I'd guess I can give it a try in a bit different way.
>
> The only problem is that in my case I need ten different values out of the
> file with each sample (I am sending 10 different user IDs to get their data
> with specific API call).
> The cleanest solution is to add another option to the CSV Dataset Config
> Element, so it will support such case.
> Adding another config option like: Refresh value on: Every reference, Every
> iteration.
>
> Another option I have in mind is if the CSV config create an array of all
> items in CSV file, I can randomly generate the item I wanna get out of the
> array of items. Something similar to the way the regex extractor can create
> arrays.
>
> Shmuel Krakower.
> www.Beatsoo.org - re-use your jmeter scripts for application performance
> monitoring from worldwide locations for free.
>
>
> On Mon, Apr 15, 2013 at 6:00 PM, Flavio Cysne <fl...@gmail.com>
> wrote:
>
> > AFAIK, there isn't a method to do a "readNext" on the CSV file.
> >
> > Maybe using a BeanShell Post-Processor to simulate part of
> > the iterationStart method in CSVDataSet class is a way to solve it.
> >
> >
> > Code extracted from iterationStart method that is relevant to the
> question:
> >
> > 103        FileServer server = FileServer.getFileServer();
> > ...
> > 113            String _fileName = getFilename();
> > 114            String mode = getShareMode();
> > 115            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
> > 116            switch(modeInt){
> > 117                case CSVDataSetBeanInfo.SHARE_ALL:
> > 118                    alias = _fileName;
> > 119                    break;
> > 120                case CSVDataSetBeanInfo.SHARE_GROUP:
> > 121                    alias =
> > _fileName+"@"+System.identityHashCode(context.getThreadGroup());
> > 122                    break;
> > 123                case CSVDataSetBeanInfo.SHARE_THREAD:
> > 124                    alias =
> > _fileName+"@"+System.identityHashCode(context.getThread());
> > 125                    break;
> > 126                default:
> > 127                    alias = _fileName+"@"+mode; // user-specified key
> > 128                    break;
> > 129            }
> > ...
> > 149               if (getQuotedData()) {
> > 150                lineValues = server.getParsedLine(alias, recycle,
> > firstLineIsNames, delim.charAt(0));
> > 151            } else {
> > 152                String line = server.readLine(alias, recycle,
> > firstLineIsNames);
> > 153                lineValues = JOrphanUtils.split(line, delim, false);
> > 154            }
> >
> >
> > With some aspects already known from CSV Dataset Config you could
> restrict
> > the code executed in BeanShell to a few lines.
> >
> >
> >
> >
> > 2013/4/15 Shmuel Krakower <sh...@gmail.com>
> >
> > > Hi all,
> > > The normal behavior of CSV dataset is to give us the next value with
> each
> > > iteration on the local thread. I.e. single thread test will get new
> value
> > > as new iteration begins.
> > >
> > > I have a need that with each time I reference the variable from the CSV
> > > config element, I'll get the next value.
> > > Maybe that's something silly easy, but I cannot find how to do that.
> > >
> > > Best,
> > >
> > > Shmuel Krakower.
> > > www.Beatsoo.org - re-use your jmeter scripts for application
> performance
> > > monitoring from worldwide locations for free.
> > >
> >
>

Re: CSV dataset to refresh value with every reference

Posted by Flavio Cysne <fl...@gmail.com>.
__intSum function could be used instead of __count. In some cases the first
one is more suitable.


2013/4/15 Flavio Cysne <fl...@gmail.com>

> If the number of times you will use these data is already known you should
> rearrange your csv to contain all sequenced data in the same line.
>
> Example: suppose your csv file contains the data below
> bob
> fred
> mark
> tina
>
> you could reformat it to
>
> bob,fred,mark,tina
>
> and use "name1,name2,name3,name4" as column names on the CSV Dataset Config
>
> this way you could compose your variable name using __count function and
> iterate within the sequence.
>
>
> 2013/4/15 Shmuel Krakower <sh...@gmail.com>
>
>> Thanks for the response.
>> I'd guess I can give it a try in a bit different way.
>>
>> The only problem is that in my case I need ten different values out of the
>> file with each sample (I am sending 10 different user IDs to get their
>> data
>> with specific API call).
>> The cleanest solution is to add another option to the CSV Dataset Config
>> Element, so it will support such case.
>> Adding another config option like: Refresh value on: Every reference,
>> Every
>> iteration.
>>
>> Another option I have in mind is if the CSV config create an array of all
>> items in CSV file, I can randomly generate the item I wanna get out of the
>> array of items. Something similar to the way the regex extractor can
>> create
>> arrays.
>>
>> Shmuel Krakower.
>> www.Beatsoo.org - re-use your jmeter scripts for application performance
>> monitoring from worldwide locations for free.
>>
>>
>> On Mon, Apr 15, 2013 at 6:00 PM, Flavio Cysne <fl...@gmail.com>
>> wrote:
>>
>> > AFAIK, there isn't a method to do a "readNext" on the CSV file.
>> >
>> > Maybe using a BeanShell Post-Processor to simulate part of
>> > the iterationStart method in CSVDataSet class is a way to solve it.
>> >
>> >
>> > Code extracted from iterationStart method that is relevant to the
>> question:
>> >
>> > 103        FileServer server = FileServer.getFileServer();
>> > ...
>> > 113            String _fileName = getFilename();
>> > 114            String mode = getShareMode();
>> > 115            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
>> > 116            switch(modeInt){
>> > 117                case CSVDataSetBeanInfo.SHARE_ALL:
>> > 118                    alias = _fileName;
>> > 119                    break;
>> > 120                case CSVDataSetBeanInfo.SHARE_GROUP:
>> > 121                    alias =
>> > _fileName+"@"+System.identityHashCode(context.getThreadGroup());
>> > 122                    break;
>> > 123                case CSVDataSetBeanInfo.SHARE_THREAD:
>> > 124                    alias =
>> > _fileName+"@"+System.identityHashCode(context.getThread());
>> > 125                    break;
>> > 126                default:
>> > 127                    alias = _fileName+"@"+mode; // user-specified key
>> > 128                    break;
>> > 129            }
>> > ...
>> > 149               if (getQuotedData()) {
>> > 150                lineValues = server.getParsedLine(alias, recycle,
>> > firstLineIsNames, delim.charAt(0));
>> > 151            } else {
>> > 152                String line = server.readLine(alias, recycle,
>> > firstLineIsNames);
>> > 153                lineValues = JOrphanUtils.split(line, delim, false);
>> > 154            }
>> >
>> >
>> > With some aspects already known from CSV Dataset Config you could
>> restrict
>> > the code executed in BeanShell to a few lines.
>> >
>> >
>> >
>> >
>> > 2013/4/15 Shmuel Krakower <sh...@gmail.com>
>> >
>> > > Hi all,
>> > > The normal behavior of CSV dataset is to give us the next value with
>> each
>> > > iteration on the local thread. I.e. single thread test will get new
>> value
>> > > as new iteration begins.
>> > >
>> > > I have a need that with each time I reference the variable from the
>> CSV
>> > > config element, I'll get the next value.
>> > > Maybe that's something silly easy, but I cannot find how to do that.
>> > >
>> > > Best,
>> > >
>> > > Shmuel Krakower.
>> > > www.Beatsoo.org - re-use your jmeter scripts for application
>> performance
>> > > monitoring from worldwide locations for free.
>> > >
>> >
>>
>
>

Re: CSV dataset to refresh value with every reference

Posted by Flavio Cysne <fl...@gmail.com>.
If the number of times you will use these data is already known you should
rearrange your csv to contain all sequenced data in the same line.

Example: suppose your csv file contains the data below
bob
fred
mark
tina

you could reformat it to

bob,fred,mark,tina

and use "name1,name2,name3,name4" as column names on the CSV Dataset Config

this way you could compose your variable name using __count function and
iterate within the sequence.


2013/4/15 Shmuel Krakower <sh...@gmail.com>

> Thanks for the response.
> I'd guess I can give it a try in a bit different way.
>
> The only problem is that in my case I need ten different values out of the
> file with each sample (I am sending 10 different user IDs to get their data
> with specific API call).
> The cleanest solution is to add another option to the CSV Dataset Config
> Element, so it will support such case.
> Adding another config option like: Refresh value on: Every reference, Every
> iteration.
>
> Another option I have in mind is if the CSV config create an array of all
> items in CSV file, I can randomly generate the item I wanna get out of the
> array of items. Something similar to the way the regex extractor can create
> arrays.
>
> Shmuel Krakower.
> www.Beatsoo.org - re-use your jmeter scripts for application performance
> monitoring from worldwide locations for free.
>
>
> On Mon, Apr 15, 2013 at 6:00 PM, Flavio Cysne <fl...@gmail.com>
> wrote:
>
> > AFAIK, there isn't a method to do a "readNext" on the CSV file.
> >
> > Maybe using a BeanShell Post-Processor to simulate part of
> > the iterationStart method in CSVDataSet class is a way to solve it.
> >
> >
> > Code extracted from iterationStart method that is relevant to the
> question:
> >
> > 103        FileServer server = FileServer.getFileServer();
> > ...
> > 113            String _fileName = getFilename();
> > 114            String mode = getShareMode();
> > 115            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
> > 116            switch(modeInt){
> > 117                case CSVDataSetBeanInfo.SHARE_ALL:
> > 118                    alias = _fileName;
> > 119                    break;
> > 120                case CSVDataSetBeanInfo.SHARE_GROUP:
> > 121                    alias =
> > _fileName+"@"+System.identityHashCode(context.getThreadGroup());
> > 122                    break;
> > 123                case CSVDataSetBeanInfo.SHARE_THREAD:
> > 124                    alias =
> > _fileName+"@"+System.identityHashCode(context.getThread());
> > 125                    break;
> > 126                default:
> > 127                    alias = _fileName+"@"+mode; // user-specified key
> > 128                    break;
> > 129            }
> > ...
> > 149               if (getQuotedData()) {
> > 150                lineValues = server.getParsedLine(alias, recycle,
> > firstLineIsNames, delim.charAt(0));
> > 151            } else {
> > 152                String line = server.readLine(alias, recycle,
> > firstLineIsNames);
> > 153                lineValues = JOrphanUtils.split(line, delim, false);
> > 154            }
> >
> >
> > With some aspects already known from CSV Dataset Config you could
> restrict
> > the code executed in BeanShell to a few lines.
> >
> >
> >
> >
> > 2013/4/15 Shmuel Krakower <sh...@gmail.com>
> >
> > > Hi all,
> > > The normal behavior of CSV dataset is to give us the next value with
> each
> > > iteration on the local thread. I.e. single thread test will get new
> value
> > > as new iteration begins.
> > >
> > > I have a need that with each time I reference the variable from the CSV
> > > config element, I'll get the next value.
> > > Maybe that's something silly easy, but I cannot find how to do that.
> > >
> > > Best,
> > >
> > > Shmuel Krakower.
> > > www.Beatsoo.org - re-use your jmeter scripts for application
> performance
> > > monitoring from worldwide locations for free.
> > >
> >
>

Re: CSV dataset to refresh value with every reference

Posted by Shmuel Krakower <sh...@gmail.com>.
Thanks for the response.
I'd guess I can give it a try in a bit different way.

The only problem is that in my case I need ten different values out of the
file with each sample (I am sending 10 different user IDs to get their data
with specific API call).
The cleanest solution is to add another option to the CSV Dataset Config
Element, so it will support such case.
Adding another config option like: Refresh value on: Every reference, Every
iteration.

Another option I have in mind is if the CSV config create an array of all
items in CSV file, I can randomly generate the item I wanna get out of the
array of items. Something similar to the way the regex extractor can create
arrays.

Shmuel Krakower.
www.Beatsoo.org - re-use your jmeter scripts for application performance
monitoring from worldwide locations for free.


On Mon, Apr 15, 2013 at 6:00 PM, Flavio Cysne <fl...@gmail.com> wrote:

> AFAIK, there isn't a method to do a "readNext" on the CSV file.
>
> Maybe using a BeanShell Post-Processor to simulate part of
> the iterationStart method in CSVDataSet class is a way to solve it.
>
>
> Code extracted from iterationStart method that is relevant to the question:
>
> 103        FileServer server = FileServer.getFileServer();
> ...
> 113            String _fileName = getFilename();
> 114            String mode = getShareMode();
> 115            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
> 116            switch(modeInt){
> 117                case CSVDataSetBeanInfo.SHARE_ALL:
> 118                    alias = _fileName;
> 119                    break;
> 120                case CSVDataSetBeanInfo.SHARE_GROUP:
> 121                    alias =
> _fileName+"@"+System.identityHashCode(context.getThreadGroup());
> 122                    break;
> 123                case CSVDataSetBeanInfo.SHARE_THREAD:
> 124                    alias =
> _fileName+"@"+System.identityHashCode(context.getThread());
> 125                    break;
> 126                default:
> 127                    alias = _fileName+"@"+mode; // user-specified key
> 128                    break;
> 129            }
> ...
> 149               if (getQuotedData()) {
> 150                lineValues = server.getParsedLine(alias, recycle,
> firstLineIsNames, delim.charAt(0));
> 151            } else {
> 152                String line = server.readLine(alias, recycle,
> firstLineIsNames);
> 153                lineValues = JOrphanUtils.split(line, delim, false);
> 154            }
>
>
> With some aspects already known from CSV Dataset Config you could restrict
> the code executed in BeanShell to a few lines.
>
>
>
>
> 2013/4/15 Shmuel Krakower <sh...@gmail.com>
>
> > Hi all,
> > The normal behavior of CSV dataset is to give us the next value with each
> > iteration on the local thread. I.e. single thread test will get new value
> > as new iteration begins.
> >
> > I have a need that with each time I reference the variable from the CSV
> > config element, I'll get the next value.
> > Maybe that's something silly easy, but I cannot find how to do that.
> >
> > Best,
> >
> > Shmuel Krakower.
> > www.Beatsoo.org - re-use your jmeter scripts for application performance
> > monitoring from worldwide locations for free.
> >
>

Re: CSV dataset to refresh value with every reference

Posted by Flavio Cysne <fl...@gmail.com>.
AFAIK, there isn't a method to do a "readNext" on the CSV file.

Maybe using a BeanShell Post-Processor to simulate part of
the iterationStart method in CSVDataSet class is a way to solve it.


Code extracted from iterationStart method that is relevant to the question:

103        FileServer server = FileServer.getFileServer();
...
113            String _fileName = getFilename();
114            String mode = getShareMode();
115            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
116            switch(modeInt){
117                case CSVDataSetBeanInfo.SHARE_ALL:
118                    alias = _fileName;
119                    break;
120                case CSVDataSetBeanInfo.SHARE_GROUP:
121                    alias =
_fileName+"@"+System.identityHashCode(context.getThreadGroup());
122                    break;
123                case CSVDataSetBeanInfo.SHARE_THREAD:
124                    alias =
_fileName+"@"+System.identityHashCode(context.getThread());
125                    break;
126                default:
127                    alias = _fileName+"@"+mode; // user-specified key
128                    break;
129            }
...
149               if (getQuotedData()) {
150                lineValues = server.getParsedLine(alias, recycle,
firstLineIsNames, delim.charAt(0));
151            } else {
152                String line = server.readLine(alias, recycle,
firstLineIsNames);
153                lineValues = JOrphanUtils.split(line, delim, false);
154            }


With some aspects already known from CSV Dataset Config you could restrict
the code executed in BeanShell to a few lines.




2013/4/15 Shmuel Krakower <sh...@gmail.com>

> Hi all,
> The normal behavior of CSV dataset is to give us the next value with each
> iteration on the local thread. I.e. single thread test will get new value
> as new iteration begins.
>
> I have a need that with each time I reference the variable from the CSV
> config element, I'll get the next value.
> Maybe that's something silly easy, but I cannot find how to do that.
>
> Best,
>
> Shmuel Krakower.
> www.Beatsoo.org - re-use your jmeter scripts for application performance
> monitoring from worldwide locations for free.
>