From 5f0bf181fcb2d63d7e42c34ea5bac0e74b450c62 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" Date: Thu, 4 Apr 2019 10:48:42 -0500 Subject: [PATCH] MC-15729: Create new GraphQL script for our benchmark - part 1 --- setup/performance-toolkit/benchmark.jmx | 538 ++++++++++++++++++++++++ 1 file changed, 538 insertions(+) diff --git a/setup/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx index c0d57ba0e2cef..2035da9d58265 100644 --- a/setup/performance-toolkit/benchmark.jmx +++ b/setup/performance-toolkit/benchmark.jmx @@ -364,6 +364,16 @@ ${__P(graphQLPoolUsers,1)} = + + graphqlAddConfigurableProductToCartPercentage + ${__P(graphqlAddConfigurableProductToCartPercentage,0)} + = + + + graphqlAddSimpleProductToCartPercentage + ${__P(graphqlAddSimpleProductToCartPercentage,0)} + = + graphqlGetCategoryListByCategoryIdPercentage ${__P(graphqlGetCategoryListByCategoryIdPercentage,0)} @@ -40572,6 +40582,534 @@ vars.putObject("category", categories[number]); + + + 1 + false + 1 + ${graphqlAddSimpleProductToCartPercentage} + mpaf/tool/fragments/_system/scenario_controller_tmpl.jmx + + + +var testLabel = "${testLabel}" ? " (${testLabel})" : ""; +if (testLabel + && sampler.getClass().getName() == 'org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy' +) { + if (sampler.getName().indexOf(testLabel) == -1) { + sampler.setName(sampler.getName() + testLabel); + } +} else if (sampler.getName().indexOf("SetUp - ") == -1) { + sampler.setName("SetUp - " + sampler.getName()); +} + + javascript + mpaf/tool/fragments/_system/setup_label.jmx + + + + vars.put("testLabel", "Add Simple Product To Cart"); + + true + + + + + + + Content-Type + application/json + + + Accept + */* + + + mpaf/tool/fragments/ce/api/header_manager_before_token.jmx + + + + mpaf/tool/fragments/ce/common/init_random_generator_setup.jmx + +import java.util.Random; + +Random random = new Random(); +if (${seedForRandom} > 0) { + random.setSeed(${seedForRandom} + ${__threadNum}); +} + +vars.putObject("randomIntGenerator", random); + + + + true + + + + + +import java.util.Random; + +Random random = vars.getObject("randomIntGenerator"); +number = random.nextInt(props.get("simple_products_list").size()); +product = props.get("simple_products_list").get(number); + +vars.put("product_url_key", product.get("url_key")); +vars.put("product_id", product.get("id")); +vars.put("product_name", product.get("title")); +vars.put("product_uenc", product.get("uenc")); +vars.put("product_sku", product.get("sku")); + + + + true + mpaf/tool/fragments/ce/product_browsing_and_adding_items_to_the_cart/simple_products_setup.jmx + + + + true + + + + false + {"query":"mutation {\n createEmptyCart\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/create_empty_cart.jmx + + + + quote_id + $.data.createEmptyCart + + + BODY + + + + + + true + + + + false + {"query":"mutation { \n addSimpleProductsToCart(\n input: {\n cart_id: \"${quote_id}\"\n cartItems: [\n {\n data: {\n qty: 2\n sku: \"${product_sku}\"\n }\n }\n ]\n }\n ) {\n cart {\n items {\n qty\n product {\n sku\n }\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/add_simple_product_to_cart.jmx + + + + + addSimpleProductsToCart + "sku":"${product_sku}" + + Assertion.response_data + false + 2 + + + + + + true + + + + false + {"query":"{\n cart(cart_id: \"${quote_id}\") {\n items {\n id\n qty\n product {\n sku\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/get_cart.jmx + + + + item_id + $.data.cart.items[0].id + + + BODY + + + + + + true + + + + false + {"query":"mutation {\n removeItemFromCart(\n input: {\n cart_id: \"${quote_id}\"\n cart_item_id: ${item_id}\n }\n ) {\n cart {\n items {\n qty\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/remove_simple_product_from_cart.jmx + + + + + {"data":{"removeItemFromCart":{"cart":{"items":[]}}}} + + Assertion.response_data + false + 8 + + + + + + + + 1 + false + 1 + ${graphqlAddConfigurableProductToCartPercentage} + mpaf/tool/fragments/_system/scenario_controller_tmpl.jmx + + + +var testLabel = "${testLabel}" ? " (${testLabel})" : ""; +if (testLabel + && sampler.getClass().getName() == 'org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy' +) { + if (sampler.getName().indexOf(testLabel) == -1) { + sampler.setName(sampler.getName() + testLabel); + } +} else if (sampler.getName().indexOf("SetUp - ") == -1) { + sampler.setName("SetUp - " + sampler.getName()); +} + + javascript + mpaf/tool/fragments/_system/setup_label.jmx + + + + vars.put("testLabel", "Add Configurable Product To Cart"); + + true + + + + + + + Content-Type + application/json + + + Accept + */* + + + mpaf/tool/fragments/ce/api/header_manager_before_token.jmx + + + + mpaf/tool/fragments/ce/common/init_random_generator_setup.jmx + +import java.util.Random; + +Random random = new Random(); +if (${seedForRandom} > 0) { + random.setSeed(${seedForRandom} + ${__threadNum}); +} + +vars.putObject("randomIntGenerator", random); + + + + true + + + + + +import java.util.Random; + +Random random = vars.getObject("randomIntGenerator"); +number = random.nextInt(props.get("configurable_products_list").size()); +product = props.get("configurable_products_list").get(number); + +vars.put("product_url_key", product.get("url_key")); +vars.put("product_id", product.get("id")); +vars.put("product_name", product.get("title")); +vars.put("product_uenc", product.get("uenc")); +vars.put("product_sku", product.get("sku")); + + + + true + mpaf/tool/fragments/ce/product_browsing_and_adding_items_to_the_cart/configurable_products_setup.jmx + + + + true + + + + false + {"query":"query productDetailByName($name: String, $onServer: Boolean!) {\n products(filter: { name: { eq: $name } }) {\n items {\n id\n sku\n name\n ... on ConfigurableProduct {\n configurable_options {\n attribute_code\n attribute_id\n id\n label\n values {\n default_label\n label\n store_label\n use_default_value\n value_index\n }\n }\n variants {\n product {\n #fashion_color\n #fashion_size\n id\n media_gallery_entries {\n disabled\n file\n label\n position\n }\n sku\n stock_status\n }\n }\n }\n meta_title @include(if: $onServer)\n meta_keyword @include(if: $onServer)\n meta_description @include(if: $onServer)\n }\n }\n}","variables":{"name":"${product_name}","onServer":false},"operationName":"productDetailByName"} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/get_configurable_product_details_by_name.jmx + + + + + "sku":"${product_sku}","name":"${product_name}" + + Assertion.response_data + false + 2 + + + + + product_option + $.data.products.items[0].variants[0].product.sku + + + BODY + mpaf/tool/fragments/ce/graphql/extract_configurable_product_option.jmx + + + + + true + + + + false + {"query":"mutation {\n createEmptyCart\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/create_empty_cart.jmx + + + + quote_id + $.data.createEmptyCart + + + BODY + + + + + + true + + + + false + {"query":"mutation {\n addConfigurableProductsToCart(\n input: {\n cart_id: \"${quote_id}\"\n cartItems: [\n {\n variant_sku: \"${product_option}\"\n data: {\n qty: 2\n sku: \"${product_option}\"\n }\n }\n ]\n }\n ) {\n cart {\n items {\n id\n qty\n product {\n name\n sku\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n }\n }\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/add_configurable_product_to_cart.jmx + + + + + addConfigurableProductsToCart + "sku":"${product_option}" + + Assertion.response_data + false + 2 + + + + + + true + + + + false + {"query":"{\n cart(cart_id: \"${quote_id}\") {\n items {\n id\n qty\n product {\n sku\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/get_cart.jmx + + + + item_id + $.data.cart.items[0].id + + + BODY + + + + + + true + + + + false + {"query":"mutation {\n removeItemFromCart(\n input: {\n cart_id: \"${quote_id}\"\n cart_item_id: ${item_id}\n }\n ) {\n cart {\n items {\n qty\n }\n }\n }\n}","variables":null,"operationName":null} + = + + + + + ${graphql_port_number} + 60000 + 200000 + ${request_protocol} + + ${base_path}graphql + POST + true + false + true + false + false + + mpaf/tool/fragments/ce/graphql/remove_configurable_product_from_cart.jmx + + + + + {"data":{"removeItemFromCart":{"cart":{"items":[]}}}} + + Assertion.response_data + false + 8 + + + + +