Skip to content

Commit 5e62491

Browse files
authored
Merge pull request #1427 from magento-performance/Perf_PR
[Performance] Add seed for JMeter scenarios
2 parents ec8868a + 9b3c196 commit 5e62491

File tree

1 file changed

+34
-138
lines changed

1 file changed

+34
-138
lines changed

setup/performance-toolkit/benchmark.jmx

Lines changed: 34 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@
549549
<stringProp name="Argument.value">${__P(scenario,)}</stringProp>
550550
<stringProp name="Argument.metadata">=</stringProp>
551551
</elementProp>
552+
<elementProp name="seedForRandom" elementType="Argument">
553+
<stringProp name="Argument.name">seedForRandom</stringProp>
554+
<stringProp name="Argument.value">${__P(seedForRandom,1)}</stringProp>
555+
<stringProp name="Argument.metadata">=</stringProp>
556+
</elementProp>
552557
<elementProp name="searchQuick" elementType="Argument">
553558
<stringProp name="Argument.name">searchQuick</stringProp>
554559
<stringProp name="Argument.value">${__P(searchQuick,0)}</stringProp>
@@ -732,8 +737,17 @@
732737
<stringProp name="ThreadGroup.delay"/>
733738
</SetupThreadGroup>
734739
<hashTree>
735-
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - BeanShell Sampler: Clear properties" enabled="true">
736-
<stringProp name="BeanShellSampler.query">props.remove("category_url_key");
740+
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - BeanShell Sampler: Initialize" enabled="true">
741+
<stringProp name="BeanShellSampler.query">
742+
// Init and save random object for get random values with/without seed
743+
import java.util.Random;
744+
Random random = new Random();
745+
if (${seedForRandom} &gt; 0) {
746+
random.setSeed(${seedForRandom});
747+
}
748+
props.put("RandomObject", random);
749+
750+
props.remove("category_url_key");
737751
props.remove("category_url_keys_list");
738752
props.remove("category_name");
739753
props.remove("category_names_list");
@@ -2230,57 +2244,28 @@ if ("${cache_indicator}" == "1") {
22302244
<stringProp name="ThreadGroup.delay"/>
22312245
</ThreadGroup>
22322246
<hashTree>
2233-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 1" enabled="true">
2234-
<stringProp name="variableName">rv1</stringProp>
2235-
<stringProp name="outputFormat">'.'</stringProp>
2236-
<stringProp name="minimumValue">1</stringProp>
2237-
<stringProp name="maximumValue">999999</stringProp>
2238-
<stringProp name="randomSeed">1</stringProp>
2239-
<boolProp name="perThread">true</boolProp>
2240-
</RandomVariableConfig>
2241-
<hashTree/>
2242-
2243-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 2" enabled="true">
2244-
<stringProp name="variableName">rv2</stringProp>
2245-
<stringProp name="outputFormat">'.'</stringProp>
2246-
<stringProp name="minimumValue">1</stringProp>
2247-
<stringProp name="maximumValue">999999</stringProp>
2248-
<stringProp name="randomSeed">2</stringProp>
2249-
<boolProp name="perThread">true</boolProp>
2250-
</RandomVariableConfig>
2251-
<hashTree/>
2252-
2253-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 3" enabled="true">
2254-
<stringProp name="variableName">rv3</stringProp>
2255-
<stringProp name="outputFormat">'.'</stringProp>
2256-
<stringProp name="minimumValue">1</stringProp>
2257-
<stringProp name="maximumValue">999999</stringProp>
2258-
<stringProp name="randomSeed">3</stringProp>
2259-
<boolProp name="perThread">true</boolProp>
2260-
</RandomVariableConfig>
2261-
<hashTree/>
2262-
22632247
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="Get arguments${__property(activeAdminThread)}(CatProdBrows)" enabled="true">
22642248
<stringProp name="TestPlan.comments">Passing arguments between threads</stringProp>
2265-
<stringProp name="BeanShellSampler.query">number = (int)(${rv1} * props.get("simple_products_list").size());
2249+
<stringProp name="BeanShellSampler.query">
2250+
number = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
22662251
simpleList = props.get("simple_products_list").get(number);
22672252
vars.put("simple_product_1_url_key", simpleList.get("url_key"));
22682253
vars.put("simple_product_1_name", simpleList.get("title"));
22692254
vars.put("simple_product_1_id", simpleList.get("id"));
22702255

2271-
number1 = (int)(${rv2} * props.get("simple_products_list").size());
2256+
number1 = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
22722257
simpleList = props.get("simple_products_list").get(number1);
22732258
vars.put("simple_product_2_url_key", simpleList.get("url_key"));
22742259
vars.put("simple_product_2_name", simpleList.get("title"));
22752260
vars.put("simple_product_2_id", simpleList.get("id"));
22762261

2277-
number = (int)(${rv3} * props.get("configurable_products_list").size());
2262+
number = props.get("RandomObject").nextInt(props.get("configurable_products_list").size());
22782263
configurableList = props.get("configurable_products_list").get(number);
22792264
vars.put("configurable_product_1_url_key", configurableList.get("url_key"));
22802265
vars.put("configurable_product_1_name", configurableList.get("title"));
22812266
vars.put("configurable_product_1_id", configurableList.get("id"));
22822267

2283-
number = (int)(Math.random() * props.get("category_url_keys_list").size());
2268+
number = props.get("RandomObject").nextInt(props.get("category_url_keys_list").size());
22842269
vars.put("category_url_key", props.get("category_url_keys_list").get(number));
22852270
vars.put("category_name", props.get("category_names_list").get(number));
22862271
vars.put("testLabel", "CatProdBrows");</stringProp>
@@ -2609,53 +2594,23 @@ vars.put("testLabel", "CatProdBrows");</stringProp>
26092594
<stringProp name="ThreadGroup.delay"/>
26102595
</ThreadGroup>
26112596
<hashTree>
2612-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 1" enabled="true">
2613-
<stringProp name="variableName">rv1</stringProp>
2614-
<stringProp name="outputFormat">'.'</stringProp>
2615-
<stringProp name="minimumValue">1</stringProp>
2616-
<stringProp name="maximumValue">999999</stringProp>
2617-
<stringProp name="randomSeed">1</stringProp>
2618-
<boolProp name="perThread">true</boolProp>
2619-
</RandomVariableConfig>
2620-
<hashTree/>
2621-
2622-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 2" enabled="true">
2623-
<stringProp name="variableName">rv2</stringProp>
2624-
<stringProp name="outputFormat">'.'</stringProp>
2625-
<stringProp name="minimumValue">1</stringProp>
2626-
<stringProp name="maximumValue">999999</stringProp>
2627-
<stringProp name="randomSeed">2</stringProp>
2628-
<boolProp name="perThread">true</boolProp>
2629-
</RandomVariableConfig>
2630-
<hashTree/>
2631-
2632-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 3" enabled="true">
2633-
<stringProp name="variableName">rv3</stringProp>
2634-
<stringProp name="outputFormat">'.'</stringProp>
2635-
<stringProp name="minimumValue">1</stringProp>
2636-
<stringProp name="maximumValue">999999</stringProp>
2637-
<stringProp name="randomSeed">3</stringProp>
2638-
<boolProp name="perThread">true</boolProp>
2639-
</RandomVariableConfig>
2640-
<hashTree/>
2641-
26422597
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="Get arguments${__property(activeAdminThread)}(BrowsAddToCart)" enabled="true">
26432598
<stringProp name="TestPlan.comments">Passing arguments between threads</stringProp>
2644-
<stringProp name="BeanShellSampler.query">number = (int)(${rv1} * props.get("simple_products_list").size());
2599+
<stringProp name="BeanShellSampler.query">number = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
26452600
simpleList = props.get("simple_products_list").get(number);
26462601
vars.put("simple_product_1_url_key", simpleList.get("url_key"));
26472602
vars.put("simple_product_1_name", simpleList.get("title"));
26482603
vars.put("simple_product_1_id", simpleList.get("id"));
26492604
vars.put("simple_product_1_uenc", simpleList.get("uenc"));
26502605

2651-
number1 = (int)(${rv2} * props.get("simple_products_list").size());
2606+
number1 = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
26522607
simpleList = props.get("simple_products_list").get(number1);
26532608
vars.put("simple_product_2_url_key", simpleList.get("url_key"));
26542609
vars.put("simple_product_2_name", simpleList.get("title"));
26552610
vars.put("simple_product_2_id", simpleList.get("id"));
26562611
vars.put("simple_product_2_uenc", simpleList.get("uenc"));
26572612

2658-
number = (int)(${rv3} * props.get("configurable_products_list").size());
2613+
number = props.get("RandomObject").nextInt(props.get("configurable_products_list").size());
26592614
configurableList = props.get("configurable_products_list").get(number);
26602615
vars.put("configurable_product_1_url_key", configurableList.get("url_key"));
26612616
vars.put("configurable_product_1_name", configurableList.get("title"));
@@ -2664,7 +2619,7 @@ vars.put("configurable_attribute_id", configurableList.get("attribute_id"));
26642619
vars.put("configurable_option_id", configurableList.get("attribute_option_id"));
26652620
vars.put("configurable_product_1_uenc", simpleList.get("uenc"));
26662621

2667-
number = (int)(Math.random() * props.get("category_url_keys_list").size());
2622+
number = props.get("RandomObject").nextInt(props.get("category_url_keys_list").size());
26682623
vars.put("category_url_key", props.get("category_url_keys_list").get(number));
26692624
vars.put("category_name", props.get("category_names_list").get(number));
26702625
vars.put("testLabel", "BrowsAddToCart");
@@ -3691,53 +3646,24 @@ vars.put("loadType", "Guest");</stringProp>
36913646
<stringProp name="ThreadGroup.delay"/>
36923647
</ThreadGroup>
36933648
<hashTree>
3694-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 1" enabled="true">
3695-
<stringProp name="variableName">rv1</stringProp>
3696-
<stringProp name="outputFormat">'.'</stringProp>
3697-
<stringProp name="minimumValue">1</stringProp>
3698-
<stringProp name="maximumValue">999999</stringProp>
3699-
<stringProp name="randomSeed">1</stringProp>
3700-
<boolProp name="perThread">true</boolProp>
3701-
</RandomVariableConfig>
3702-
<hashTree/>
3703-
3704-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 2" enabled="true">
3705-
<stringProp name="variableName">rv2</stringProp>
3706-
<stringProp name="outputFormat">'.'</stringProp>
3707-
<stringProp name="minimumValue">1</stringProp>
3708-
<stringProp name="maximumValue">999999</stringProp>
3709-
<stringProp name="randomSeed">2</stringProp>
3710-
<boolProp name="perThread">true</boolProp>
3711-
</RandomVariableConfig>
3712-
<hashTree/>
3713-
3714-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 3" enabled="true">
3715-
<stringProp name="variableName">rv3</stringProp>
3716-
<stringProp name="outputFormat">'.'</stringProp>
3717-
<stringProp name="minimumValue">1</stringProp>
3718-
<stringProp name="maximumValue">999999</stringProp>
3719-
<stringProp name="randomSeed">3</stringProp>
3720-
<boolProp name="perThread">true</boolProp>
3721-
</RandomVariableConfig>
3722-
<hashTree/>
3723-
37243649
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="Get arguments${__property(activeAdminThread)}(GuestChkt)" enabled="true">
37253650
<stringProp name="TestPlan.comments">Passing arguments between threads</stringProp>
3726-
<stringProp name="BeanShellSampler.query">number = (int)(${rv1} * props.get("simple_products_list").size());
3651+
<stringProp name="BeanShellSampler.query">
3652+
number = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
37273653
simpleList = props.get("simple_products_list").get(number);
37283654
vars.put("simple_product_1_url_key", simpleList.get("url_key"));
37293655
vars.put("simple_product_1_name", simpleList.get("title"));
37303656
vars.put("simple_product_1_id", simpleList.get("id"));
37313657
vars.put("simple_product_1_uenc", simpleList.get("uenc"));
37323658

3733-
number1 = (int)(${rv2} * props.get("simple_products_list").size());
3659+
number1 = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
37343660
simpleList = props.get("simple_products_list").get(number1);
37353661
vars.put("simple_product_2_url_key", simpleList.get("url_key"));
37363662
vars.put("simple_product_2_name", simpleList.get("title"));
37373663
vars.put("simple_product_2_id", simpleList.get("id"));
37383664
vars.put("simple_product_2_uenc", simpleList.get("uenc"));
37393665

3740-
number = (int)(${rv3} * props.get("configurable_products_list").size());
3666+
number = props.get("RandomObject").nextInt(props.get("configurable_products_list").size());
37413667
configurableList = props.get("configurable_products_list").get(number);
37423668
vars.put("configurable_product_1_url_key", configurableList.get("url_key"));
37433669
vars.put("configurable_product_1_name", configurableList.get("title"));
@@ -3746,7 +3672,7 @@ vars.put("configurable_attribute_id", configurableList.get("attribute_id"));
37463672
vars.put("configurable_option_id", configurableList.get("attribute_option_id"));
37473673
vars.put("configurable_product_1_uenc", simpleList.get("uenc"));
37483674

3749-
number = (int)(Math.random() * props.get("category_url_keys_list").size());
3675+
number = props.get("RandomObject").nextInt(props.get("category_url_keys_list").size());
37503676
vars.put("category_url_key", props.get("category_url_keys_list").get(number));
37513677
vars.put("category_name", props.get("category_names_list").get(number));
37523678
vars.put("testLabel", "GuestChkt");
@@ -5170,55 +5096,25 @@ vars.put("loadType", "Guest");</stringProp>
51705096
<stringProp name="ThreadGroup.delay"/>
51715097
</ThreadGroup>
51725098
<hashTree>
5173-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 1" enabled="true">
5174-
<stringProp name="variableName">rv1</stringProp>
5175-
<stringProp name="outputFormat">'.'</stringProp>
5176-
<stringProp name="minimumValue">1</stringProp>
5177-
<stringProp name="maximumValue">999999</stringProp>
5178-
<stringProp name="randomSeed">1</stringProp>
5179-
<boolProp name="perThread">true</boolProp>
5180-
</RandomVariableConfig>
5181-
<hashTree/>
5182-
5183-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 2" enabled="true">
5184-
<stringProp name="variableName">rv2</stringProp>
5185-
<stringProp name="outputFormat">'.'</stringProp>
5186-
<stringProp name="minimumValue">1</stringProp>
5187-
<stringProp name="maximumValue">999999</stringProp>
5188-
<stringProp name="randomSeed">2</stringProp>
5189-
<boolProp name="perThread">true</boolProp>
5190-
</RandomVariableConfig>
5191-
<hashTree/>
5192-
5193-
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable 3" enabled="true">
5194-
<stringProp name="variableName">rv3</stringProp>
5195-
<stringProp name="outputFormat">'.'</stringProp>
5196-
<stringProp name="minimumValue">1</stringProp>
5197-
<stringProp name="maximumValue">999999</stringProp>
5198-
<stringProp name="randomSeed">3</stringProp>
5199-
<boolProp name="perThread">true</boolProp>
5200-
</RandomVariableConfig>
5201-
<hashTree/>
5202-
52035099
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="Get arguments${__property(activeAdminThread)}(CustomerChkt)" enabled="true">
52045100
<stringProp name="TestPlan.comments">Passing arguments between threads</stringProp>
52055101
<stringProp name="BeanShellSampler.query">import org.apache.jmeter.samplers.SampleResult;
52065102

5207-
number = (int)(${rv1} * props.get("simple_products_list").size());
5103+
number = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
52085104
simpleList = props.get("simple_products_list").get(number);
52095105
vars.put("simple_product_1_url_key", simpleList.get("url_key"));
52105106
vars.put("simple_product_1_name", simpleList.get("title"));
52115107
vars.put("simple_product_1_id", simpleList.get("id"));
52125108
vars.put("simple_product_1_uenc", simpleList.get("uenc"));
52135109

5214-
number1 = (int)(${rv2} * props.get("simple_products_list").size());
5110+
number1 = props.get("RandomObject").nextInt(props.get("simple_products_list").size());
52155111
simpleList = props.get("simple_products_list").get(number1);
52165112
vars.put("simple_product_2_url_key", simpleList.get("url_key"));
52175113
vars.put("simple_product_2_name", simpleList.get("title"));
52185114
vars.put("simple_product_2_id", simpleList.get("id"));
52195115
vars.put("simple_product_2_uenc", simpleList.get("uenc"));
52205116

5221-
number = (int)(${rv3} * props.get("configurable_products_list").size());
5117+
number = props.get("RandomObject").nextInt(props.get("configurable_products_list").size());
52225118
configurableList = props.get("configurable_products_list").get(number);
52235119
vars.put("configurable_product_1_url_key", configurableList.get("url_key"));
52245120
vars.put("configurable_product_1_name", configurableList.get("title"));
@@ -5227,7 +5123,7 @@ vars.put("configurable_attribute_id", configurableList.get("attribute_id"));
52275123
vars.put("configurable_option_id", configurableList.get("attribute_option_id"));
52285124
vars.put("configurable_product_1_uenc", simpleList.get("uenc"));
52295125

5230-
number = (int)(Math.random() * props.get("category_url_keys_list").size());
5126+
number = props.get("RandomObject").nextInt(props.get("category_url_keys_list").size());
52315127
vars.put("category_url_key", props.get("category_url_keys_list").get(number));
52325128
vars.put("category_name", props.get("category_names_list").get(number));
52335129

0 commit comments

Comments
 (0)