Stuck in a nested loop while using JMeter. Nested loop controller and CSV data set config. -
on site have 2 merchant actions: search , browse. search triggers 3 browses.
i have jmeter test uses csv file of merchants , merchant id numbers, when running test @ scale want merchants on site used.
i have mapped in jmeter so:
- loop controller
- http sampler (search /search/${merchant_name})
- csv data set config (merchant name)
- loop controller
- http sampler (browse /merchant/${merchant_id})
- csv data set config (merchant id)
i set loop count = 2
in outer loop , loop count = 3
in inner loop.
i expect 2 searches trigger 6 browse actions. search, followed 3 browses, continually until abort test.
have misunderstood loop construct? expected behaviour?
how can achieve goal of running search, followed 3 browses, twice?
i think you're misusing csv data set configuration.
i've got scenario working follows:
given following csv files:
merchants.csv
containing:
merchant1name merchant2name
and 2 other csv files: merchant1name.csv
, merchant2name.csv
contents of:
id1 id2 id3
and following test plan structure:
- thread group (1 thread, 1 second ramp-up, 1 loop)
- loop controller (2 loops)
- http request /${merchantname}
- beanshell post processor (see below code , explanation)
- csv data set config (filename: full path merchants.csv file, variable names: merchantname, defaults)
- loop controller (3 loops)
- http request /${merchantid}
- csv data set config (filename: full path merchantname1 file, merchantname1 should property, variable name: merchantid, defaults)
- http request /${merchantid}
- http request /${merchantname}
- loop controller (2 loops)
by using "all defaults" in regards csv data set config assume following:
- file encoding - blank (my jmeter running utf-8 fine majority of cases)
- delimiter - , (comma)
- allow quoted data - false
- recycle on eof - true
- stop thread on eof - false
- sharing mode - threads
beanshell code:
props.put("merchantname", vars.get("merchantname"));
this required csv data config not allow using variables in file path.
path in inner loop:
c:\jmeter\${__p(merchantname,)}.csv
you can refer http://glinius.narod.ru/stackoverflow/nestedloop.zip file. unpack "nestedloop" folder (1 jmx file , 3 csv files) /bin folder of jmeter , run test. it'll produce 8 requests
reference material:
Comments
Post a Comment