Skip to content

Commit 394b70e

Browse files
committed
MC-20650: Category filtering performance test
1 parent b35c269 commit 394b70e

File tree

1 file changed

+205
-0
lines changed

1 file changed

+205
-0
lines changed

setup/performance-toolkit/benchmark.jmx

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39431,6 +39431,64 @@ if (name == null) {
3943139431
Failure = false;
3943239432
}
3943339433
}
39434+
</stringProp>
39435+
<stringProp name="BeanShellAssertion.filename"/>
39436+
<stringProp name="BeanShellAssertion.parameters"/>
39437+
<boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp>
39438+
</BeanShellAssertion>
39439+
<hashTree/>
39440+
</hashTree>
39441+
39442+
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Query CategoryList" enabled="true">
39443+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
39444+
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
39445+
<collectionProp name="Arguments.arguments">
39446+
<elementProp name="" elementType="HTTPArgument">
39447+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
39448+
<stringProp name="Argument.value">{"query":"{\n categoryList{\n name\n id\n level\n description\n path\n path_in_store\n url_key\n url_path\n children {\n id\n description\n default_sort_by\n children {\n id\n description\n level\n children {\n level\n id\n children {\n id\n }\n }\n }\n }\n }\n}","variables":null,"operationName":null}</stringProp>
39449+
<stringProp name="Argument.metadata">=</stringProp>
39450+
</elementProp>
39451+
</collectionProp>
39452+
</elementProp>
39453+
<stringProp name="HTTPSampler.domain"/>
39454+
<stringProp name="HTTPSampler.port"/>
39455+
<stringProp name="HTTPSampler.connect_timeout"/>
39456+
<stringProp name="HTTPSampler.response_timeout"/>
39457+
<stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp>
39458+
<stringProp name="HTTPSampler.contentEncoding"/>
39459+
<stringProp name="HTTPSampler.path">${base_path}graphql</stringProp>
39460+
<stringProp name="HTTPSampler.method">POST</stringProp>
39461+
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
39462+
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
39463+
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
39464+
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
39465+
<boolProp name="HTTPSampler.monitor">false</boolProp>
39466+
<stringProp name="HTTPSampler.embedded_url_re"/>
39467+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/graphql/query_root_category_list.jmx</stringProp>
39468+
</HTTPSamplerProxy>
39469+
<hashTree>
39470+
<com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="Extract total_count" enabled="true">
39471+
<stringProp name="VAR">graphql_categoryList_query_name</stringProp>
39472+
<stringProp name="JSONPATH">$.data.categoryList[0].name</stringProp>
39473+
<stringProp name="DEFAULT"/>
39474+
<stringProp name="VARIABLE"/>
39475+
<stringProp name="SUBJECT">BODY</stringProp>
39476+
<stringProp name="INPUT_FORMAT">JSON</stringProp>
39477+
</com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor>
39478+
<hashTree/>
39479+
<BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell Assertion" enabled="true">
39480+
<stringProp name="BeanShellAssertion.query">String name = vars.get("graphql_categoryList_query_name");
39481+
if (name == null) {
39482+
Failure = true;
39483+
FailureMessage = "Not Expected \"children\" to be null";
39484+
} else {
39485+
if (!name.equals("Default Category")) {
39486+
Failure = true;
39487+
FailureMessage = "Expected \"name\" to equal \"Default Category\", Actual: " + name;
39488+
} else {
39489+
Failure = false;
39490+
}
39491+
}
3943439492
</stringProp>
3943539493
<stringProp name="BeanShellAssertion.filename"/>
3943639494
<stringProp name="BeanShellAssertion.parameters"/>
@@ -40361,6 +40419,153 @@ function assertCategoryChildren(category, response) {
4036140419

4036240420
}
4036340421

40422+
</stringProp>
40423+
</JSR223Assertion>
40424+
<hashTree/>
40425+
</hashTree>
40426+
</hashTree>
40427+
40428+
40429+
<ThroughputController guiclass="ThroughputControllerGui" testclass="ThroughputController" testname="GraphQL Get Category List by category_url_key" enabled="true">
40430+
<intProp name="ThroughputController.style">1</intProp>
40431+
<boolProp name="ThroughputController.perThread">false</boolProp>
40432+
<intProp name="ThroughputController.maxThroughput">1</intProp>
40433+
<stringProp name="ThroughputController.percentThroughput">${graphqlGetCategoryListByCategoryIdPercentage}</stringProp>
40434+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/_system/scenario_controller_tmpl.jmx</stringProp></ThroughputController>
40435+
<hashTree>
40436+
<JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="Set Test Label" enabled="true">
40437+
<stringProp name="script">
40438+
var testLabel = "${testLabel}" ? " (${testLabel})" : "";
40439+
if (testLabel
40440+
&amp;&amp; sampler.getClass().getName() == 'org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy'
40441+
) {
40442+
if (sampler.getName().indexOf(testLabel) == -1) {
40443+
sampler.setName(sampler.getName() + testLabel);
40444+
}
40445+
} else if (sampler.getName().indexOf("SetUp - ") == -1) {
40446+
sampler.setName("SetUp - " + sampler.getName());
40447+
}
40448+
</stringProp>
40449+
<stringProp name="scriptLanguage">javascript</stringProp>
40450+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/_system/setup_label.jmx</stringProp></JSR223PreProcessor>
40451+
<hashTree/>
40452+
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - Set Label" enabled="true">
40453+
<stringProp name="BeanShellSampler.query">
40454+
vars.put("testLabel", "GraphQL Get Category List by category_url_key");
40455+
</stringProp>
40456+
<boolProp name="BeanShellSampler.resetInterpreter">true</boolProp>
40457+
</BeanShellSampler>
40458+
<hashTree/>
40459+
40460+
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
40461+
<collectionProp name="HeaderManager.headers">
40462+
<elementProp name="" elementType="Header">
40463+
<stringProp name="Header.name">Content-Type</stringProp>
40464+
<stringProp name="Header.value">application/json</stringProp>
40465+
</elementProp>
40466+
<elementProp name="" elementType="Header">
40467+
<stringProp name="Header.name">Accept</stringProp>
40468+
<stringProp name="Header.value">*/*</stringProp>
40469+
</elementProp>
40470+
</collectionProp>
40471+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/api/header_manager_before_token.jmx</stringProp></HeaderManager>
40472+
<hashTree/>
40473+
40474+
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - Init Random Generator" enabled="true">
40475+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/common/init_random_generator_setup.jmx</stringProp>
40476+
<stringProp name="BeanShellSampler.query">
40477+
import java.util.Random;
40478+
40479+
Random random = new Random();
40480+
if (${seedForRandom} &gt; 0) {
40481+
random.setSeed(${seedForRandom} + ${__threadNum});
40482+
}
40483+
40484+
vars.putObject("randomIntGenerator", random);
40485+
</stringProp>
40486+
<stringProp name="BeanShellSampler.filename"/>
40487+
<stringProp name="BeanShellSampler.parameters"/>
40488+
<boolProp name="BeanShellSampler.resetInterpreter">true</boolProp>
40489+
</BeanShellSampler>
40490+
<hashTree/>
40491+
40492+
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="SetUp - Prepare Category Data" enabled="true">
40493+
<stringProp name="scriptLanguage">javascript</stringProp>
40494+
<stringProp name="parameters"/>
40495+
<stringProp name="filename"/>
40496+
<stringProp name="cacheKey"/>
40497+
<stringProp name="script">random = vars.getObject("randomIntGenerator");
40498+
40499+
var categories = props.get("categories");
40500+
number = random.nextInt(categories.length);
40501+
40502+
vars.put("category_url_key", categories[number].url_key);
40503+
vars.put("category_name", categories[number].name);
40504+
vars.put("category_id", categories[number].id);
40505+
vars.putObject("category", categories[number]);
40506+
</stringProp>
40507+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/common/extract_category_setup.jmx</stringProp></JSR223Sampler>
40508+
<hashTree/>
40509+
40510+
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Get Category List by category_url_key" enabled="true">
40511+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
40512+
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
40513+
<collectionProp name="Arguments.arguments">
40514+
<elementProp name="" elementType="HTTPArgument">
40515+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
40516+
<stringProp name="Argument.value">{"query" : "{\n categoryList(filters:{url_key: {in: [\"${category_url_key}\"]}}) {\n id\n children {\n id\n name\n url_key\n url_path\n children_count\n path\n image\n productImagePreview: products(pageSize: 1, sort: {name: ASC}) {\n items {\n small_image {\n label\n url\n }\n }\n }\n }\n }\n}"}</stringProp>
40517+
<stringProp name="Argument.metadata">=</stringProp>
40518+
</elementProp>
40519+
</collectionProp>
40520+
</elementProp>
40521+
<stringProp name="HTTPSampler.domain"/>
40522+
<stringProp name="HTTPSampler.port">${graphql_port_number}</stringProp>
40523+
<stringProp name="HTTPSampler.connect_timeout">60000</stringProp>
40524+
<stringProp name="HTTPSampler.response_timeout">200000</stringProp>
40525+
<stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp>
40526+
<stringProp name="HTTPSampler.contentEncoding"/>
40527+
<stringProp name="HTTPSampler.path">${base_path}graphql</stringProp>
40528+
<stringProp name="HTTPSampler.method">POST</stringProp>
40529+
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
40530+
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
40531+
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
40532+
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
40533+
<boolProp name="HTTPSampler.monitor">false</boolProp>
40534+
<stringProp name="HTTPSampler.embedded_url_re"/>
40535+
<stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/graphql/get_category_list_by_category_url_key.jmx</stringProp>
40536+
</HTTPSamplerProxy>
40537+
<hashTree>
40538+
<JSR223Assertion guiclass="TestBeanGUI" testclass="JSR223Assertion" testname="Assert found categories" enabled="true">
40539+
<stringProp name="scriptLanguage">javascript</stringProp>
40540+
<stringProp name="parameters"/>
40541+
<stringProp name="filename"/>
40542+
<stringProp name="cacheKey"/>
40543+
<stringProp name="script">var category = vars.getObject("category");
40544+
var response = JSON.parse(prev.getResponseDataAsString());
40545+
40546+
assertCategoryId(category, response);
40547+
assertCategoryChildren(category, response);
40548+
40549+
function assertCategoryId(category, response) {
40550+
if (response.data == undefined || response.data.categoryList == undefined || response.data.categoryList[0].id != category.id) {
40551+
AssertionResult.setFailureMessage("Cannot find category with id \"" + category.id + "\"");
40552+
AssertionResult.setFailure(true);
40553+
}
40554+
}
40555+
40556+
function assertCategoryChildren(category, response) {
40557+
foundCategory = response.data &amp;&amp; response.data.categoryList ? response.data.categoryList[0] : null;
40558+
if (foundCategory) {
40559+
var childrenFound = foundCategory.children.map(function (c) {return parseInt(c.id)});
40560+
var children = category.children.map(function (c) {return parseInt(c)});
40561+
if (JSON.stringify(children.sort()) != JSON.stringify(childrenFound.sort())) {
40562+
AssertionResult.setFailureMessage("Cannot math children categories \"" + JSON.stringify(children) + "\" for to found one: \"" + JSON.stringify(childrenFound) + "\"");
40563+
AssertionResult.setFailure(true);
40564+
}
40565+
}
40566+
40567+
}
40568+
4036440569
</stringProp>
4036540570
</JSR223Assertion>
4036640571
<hashTree/>

0 commit comments

Comments
 (0)