k6: Update existing tests for COT (#34582)

* Update k6 tests to remove linting errors, replace custom metrics with tags, and add ability to run against COT

* Added changelog

* Updated readme for new k6 perf config variables & removal of custom metrics

* Updated k6 tag names
This commit is contained in:
Tam Mullen 2022-09-13 12:40:28 -07:00 committed by GitHub
parent 5e57471c5a
commit 3e85dde082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1897 additions and 1511 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Updating k6 perf tests for COT

View File

@ -76,8 +76,12 @@ base_url | base URL of the test environment | yes `__ENV.URL`
base_host | base host of the test environment (for use in headers) | yes `__ENV.HOST`
admin_username | username for admin user | yes `__ENV.A_USER`
admin_password | password for admin user | yes `__ENV.A_PW`
admin_acc_login | set to true if site needs to use my account for admin login | yes `__ENV.A_PW`
customer_username | username for customer user | yes `__ENV.C_USER`
customer_password | password for customer user | yes `__ENV.C_PW`
cot_status | set to true if site is using order tables | yes `__ENV.C_PW`
admin_orders_base_url | url part for order urls when posts table is used | no
cot_admin_orders_base_url | url part for order urls when orders table is used | no
addresses_customer_billing_* | billing address details for existing customer user | no
addresses_guest_billing_* | billing address details for guest customer user | no
payment_method | payment method (currently only `cod` supported) | no
@ -115,7 +119,7 @@ This will run the individual test for 1 iteration.
Included in the `tests` folder are some sample scenarios that can be ran or used as a starting point to be modified to suit the context in which tests are being ran.
`simple-all-shopper-requests.js` and `simple-all-merchant-requests.js` are included scenarios that use the `per-vu-iterations` scenario executor type to run each request sequentially for 1 iteration to make sure they are working.
`simple-all-requests.js` is an included scenario that uses the `per-vu-iterations` scenario executor type to run each request sequentially for 1 iteration to make sure they are working.
`example-all-requests-ramping-vus.js` and `example-all-requests-arrival-rate.js` are included example scenarios for load testing that use the `ramping-vus` and `ramping-arrival-rate` scenario executor types to run all the requests under load of multiple virtual users. These scenarios can be modified to suit the load profile for the context that the tests will be ran.
@ -126,11 +130,11 @@ The amount of think time can be controlled from `config.js`.
>**_Note: Its important to note to be very careful when adding load to a scenario. By accident a dangerous amount of load could be ran aginst the test environment that could effectively be like a denial-of-service attack on the test environment. Also important to consider any other consequences of running large load such as triggering of emails._**
To execute a test scenario (for example `tests/simple-all-shopper-requests.js`).
To execute a test scenario (for example `tests/simple-all-requests.js`).
CLI `k6 run tests/simple-all-shopper-requests.js`
CLI `k6 run tests/simple-all-requests.js`
Docker `docker run --network="host" -v /[YOUR LOCAL WC DIRECTORY FULL PATH]/tests:/tests -it loadimpact/k6 run /tests/simple-all-shopper-requests.js`
Docker `docker run --network="host" -v /[YOUR LOCAL WC DIRECTORY FULL PATH]/tests:/tests -it loadimpact/k6 run /tests/simple-all-requests.js`
---
### Debugging Tests
@ -243,14 +247,6 @@ Checks are like asserts but they dont stop the tests if they record a failure
All requests have had checks for at least a `200` http status repsonse added and most also have an additional check for a string contained in the response body.
---
### Custom Metrics
By default the built-in metrics group the HTTP requests timings so it isn't possible drill down into individual HTTP request timings. To enable seeing these individual timing in the aggregated summary report it is possible to create a custom metric for each request.
The tests name them after the requests which the metric represents.
---
---
## Other Resources

View File

@ -1,12 +1,20 @@
/* eslint-disable no-undef */
export const base_url = __ENV.URL || 'http://localhost:8086';
export const base_host = __ENV.HOST || 'localhost:8086';
export const admin_username = __ENV.A_USER || 'admin';
export const admin_password = __ENV.A_PW || 'password';
export const admin_acc_login = __ENV.A_ACC_LOGIN || false;
export const customer_username = __ENV.C_USER || 'customer@woocommercecoree2etestsuite.com';
export const customer_username =
__ENV.C_USER || 'customer@woocommercecoree2etestsuite.com';
export const customer_password = __ENV.C_PW || 'password';
export const cot_status = __ENV.COT || false;
export const admin_orders_base_url = 'edit.php?post_type=shop_order';
export const cot_admin_orders_base_url = 'admin.php?page=wc-orders';
export const addresses_customer_billing_first_name = 'John';
export const addresses_customer_billing_last_name = 'Doe';
export const addresses_customer_billing_company = 'Automattic';

View File

@ -1,37 +1,37 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { URLSearchParams } from "https://jslib.k6.io/url/1.0.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
import { URLSearchParams } from 'https://jslib.k6.io/url/1.0.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
add_product_title,
add_product_regular_price,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonAPIRequestHeader,
jsonRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonPostRequestHeaders,
contentTypeRequestHeader,
commonAPIGetRequestHeaders,
commonNonStandardHeaders,
apiNonceHeader,
allRequestHeader,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let postNewTypeProductTrend = new Trend("wc_get_new_post_type_product");
let wcAdminNotesMainTrend = new Trend("wc_get_admin_notes_main");
let wcAdminNotesOtherTrend = new Trend("wc_get_admin_notes_other");
let wcAdminCESOptionsTrend = new Trend("wc_get_admin_options_ces");
let wpAdminHeartbeatAutosaveTrend = new Trend("wc_post_wp_admin_ajax_heartbeat_autosave");
let wpAdminSamplePermalinkTrend = new Trend("wc_post_wp_admin_ajax_sample_permalink");
} from '../../headers.js';
export function addProduct() {
let response;
@ -47,69 +47,70 @@ export function addProduct() {
let api_x_wp_nonce;
let apiNonceHeader;
group("Add New Product", function () {
var requestHeaders = Object.assign({},
group( 'Add New Product', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
{ origin: `${base_url}` },
{ origin: `${ base_url }` },
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(
`${base_url}/wp-admin/post-new.php?post_type=product`,
`${ base_url }/wp-admin/post-new.php?post_type=product`,
{
headers: requestHeaders,
tags: { name: 'Merchant - Add New Product' },
}
);
postNewTypeProductTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Add new product' header": (response) =>
response.body.includes("Add new product</h1>"),
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Add new product' header": ( response ) =>
response.body.includes( 'Add new product</h1>' ),
} );
// Correlate nonce values for use in subsequent requests.
ajax_nonce_add_meta = response
.html()
.find("input[id=_ajax_nonce-add-meta]")
.find( 'input[id=_ajax_nonce-add-meta]' )
.first()
.attr("value");
.attr( 'value' );
ajax_nonce_add_product_cat = response
.html()
.find("input[id=_ajax_nonce-add-product_cat]")
.find( 'input[id=_ajax_nonce-add-product_cat]' )
.first()
.attr("value");
.attr( 'value' );
wpnonce = response
.html()
.find("input[id=_wpnonce]")
.find( 'input[id=_wpnonce]' )
.first()
.attr("value");
.attr( 'value' );
closed_postboxes_nonce = response
.html()
.find("input[id=closedpostboxesnonce]")
.find( 'input[id=closedpostboxesnonce]' )
.first()
.attr("value");
.attr( 'value' );
sample_permalink_nonce = response
.html()
.find("input[id=samplepermalinknonce]")
.find( 'input[id=samplepermalinknonce]' )
.first()
.attr("value");
.attr( 'value' );
woocommerce_meta_nonce = response
.html()
.find("input[id=woocommerce_meta_nonce]")
.find( 'input[id=woocommerce_meta_nonce]' )
.first()
.attr("value");
.attr( 'value' );
meta_box_order_nonce = response
.html()
.find("input[id=meta-box-order-nonce]")
.find( 'input[id=meta-box-order-nonce]' )
.first()
.attr("value");
.attr( 'value' );
post_id = response
.html()
.find("input[id=post_ID]")
.find( 'input[id=post_ID]' )
.first()
.attr("value");
.attr( 'value' );
heartbeat_nonce = findBetween(
response.body,
'heartbeatSettings = {"nonce":"',
@ -123,14 +124,15 @@ export function addProduct() {
// Create request header with nonce value for use in subsequent requests.
apiNonceHeader = {
"x-wp-nonce": `${api_x_wp_nonce}`,
'x-wp-nonce': `${ api_x_wp_nonce }`,
};
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Inbox Notes", function () {
var requestHeaders = Object.assign({},
group( 'Add New Product - Other Requests', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -139,56 +141,47 @@ export function addProduct() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`status=unactioned&type%5B0%5D=info&type%5B1%5D=marketing&type%5B2%5D=survey&type%5B3%5D=warning&` +
`orderby=date&order=desc&_locale=user`,
`${ base_url }/wp-json/wc-admin/onboarding/tasks?_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-admin/onboarding/tasks?' },
}
);
wcAdminNotesMainTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
}
);
wcAdminNotesOtherTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
group("CES Options", function () {
var requestHeaders = Object.assign({},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
apiNonceHeader,
commonNonStandardHeaders
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue',
},
}
);
wcAdminCESOptionsTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Autosave heartbeat", function () {
var requestHeaders = Object.assign({},
group( 'Autosave heartbeat', function () {
const requestHeaders = Object.assign(
{},
commonNonStandardHeaders,
jsonAPIRequestHeader,
commonPostRequestHeaders,
@ -196,37 +189,38 @@ export function addProduct() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`${ base_url }/wp-admin/admin-ajax.php`,
{
_nonce: `${heartbeat_nonce}`,
action: "heartbeat",
"data%5Bwp-refresh-post-lock%5D%5Bpost_id%5D": `${post_id}`,
"data%5Bwp_autosave%5D%5B_wpnonce%5D": `${wpnonce}`,
"data%5Bwp_autosave%5D%5Bauto_draft%5D": "1",
"data%5Bwp_autosave%5D%5Bcatslist%5D": "",
"data%5Bwp_autosave%5D%5Bcomment_status%5D": "open",
"data%5Bwp_autosave%5D%5Bcontent%5D": "",
"data%5Bwp_autosave%5D%5Bexcerpt%5D": "",
"data%5Bwp_autosave%5D%5Bpost_author%5D": "1",
"data%5Bwp_autosave%5D%5Bpost_id%5D": `${post_id}`,
"data%5Bwp_autosave%5D%5Bpost_title%5D": `${add_product_title}`,
"data%5Bwp_autosave%5D%5Bpost_type%5D": "product",
has_focus: "true",
interval: "15",
screen_id: "product",
_nonce: `${ heartbeat_nonce }`,
action: 'heartbeat',
'data%5Bwp-refresh-post-lock%5D%5Bpost_id%5D': `${ post_id }`,
'data%5Bwp_autosave%5D%5B_wpnonce%5D': `${ wpnonce }`,
'data%5Bwp_autosave%5D%5Bauto_draft%5D': '1',
'data%5Bwp_autosave%5D%5Bcatslist%5D': '',
'data%5Bwp_autosave%5D%5Bcomment_status%5D': 'open',
'data%5Bwp_autosave%5D%5Bcontent%5D': '',
'data%5Bwp_autosave%5D%5Bexcerpt%5D': '',
'data%5Bwp_autosave%5D%5Bpost_author%5D': '1',
'data%5Bwp_autosave%5D%5Bpost_id%5D': `${ post_id }`,
'data%5Bwp_autosave%5D%5Bpost_title%5D': `${ add_product_title }`,
'data%5Bwp_autosave%5D%5Bpost_type%5D': 'product',
has_focus: 'true',
interval: '15',
screen_id: 'product',
},
{
headers: requestHeaders,
tags: { name: 'Merchant - action=heartbeat autosave' },
}
);
wpAdminHeartbeatAutosaveTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("Sample Permalink", function () {
var requestHeaders = Object.assign({},
group( 'Sample Permalink', function () {
const requestHeaders = Object.assign(
{},
commonNonStandardHeaders,
allRequestHeader,
contentTypeRequestHeader,
@ -234,30 +228,30 @@ export function addProduct() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`${ base_url }/wp-admin/admin-ajax.php`,
{
action: "sample-permalink",
new_title: `${add_product_title}`,
post_id: `${post_id}`,
samplepermalinknonce: `${sample_permalink_nonce}`,
action: 'sample-permalink',
new_title: `${ add_product_title }`,
post_id: `${ post_id }`,
samplepermalinknonce: `${ sample_permalink_nonce }`,
},
{
headers: requestHeaders,
tags: { name: 'Merchant - action=sample-permalink' },
}
);
wpAdminSamplePermalinkTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Permalink:'": (response) =>
response.body.includes("<strong>Permalink:</strong>"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Permalink:'": ( response ) =>
response.body.includes( '<strong>Permalink:</strong>' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Update New Product", function () {
var requestHeaders = Object.assign({},
group( 'Update New Product', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -265,112 +259,115 @@ export function addProduct() {
commonNonStandardHeaders
);
const productParams = new URLSearchParams([
["_ajax_nonce-add-meta", `${ajax_nonce_add_meta}`],
["_ajax_nonce-add-product_cat", `${ajax_nonce_add_product_cat}`],
["_backorders", "no"],
["_button_text", ""],
["_download_expiry", ""],
["_download_limit", ""],
["_height", ""],
["_length", ""],
["_low_stock_amount", ""],
["_original_stock", "0"],
["_product_url", ""],
["_purchase_note", ""],
["_regular_price", `${add_product_regular_price}`],
["_sale_price", ""],
["_sale_price_dates_from", ""],
["_sale_price_dates_to", ""],
["_sku", ""],
["_stock", "0"],
["_stock_status", "instock"],
["_thumbnail_id", "-1"],
["_visibility", "visible"],
["_weight", ""],
["_width", ""],
["_wp_http_referer", ""],
["_wp_original_http_referer", ""],
["_wpnonce", `${wpnonce}`],
["aa", "2021"],
["action", "editpost"],
["attribute_taxonomy", ""],
["auto_draft", ""],
["closedpostboxesnonce", `${closed_postboxes_nonce}`],
["comment_status", "open"],
["content", ""],
["cur_aa", "2021"],
["cur_hh", "15"],
["cur_jj", "09"],
["cur_mm", "07"],
["cur_mn", "48"],
["current_featured", "no"],
["current_visibility", "visible"],
["excerpt", ""],
["hh", "15"],
["hidden_aa", "2021"],
["hidden_hh", "15"],
["hidden_jj", "09"],
["hidden_mm", "07"],
["hidden_mn", "48"],
["hidden_post_password", ""],
["hidden_post_status", "draft"],
["hidden_post_visibility", "public"],
["jj", "09"],
["menu_order", "0"],
["meta-box-order-nonce", `${meta_box_order_nonce}`],
["metakeyinput", ""],
["metakeyselect", "%2523NONE%2523"],
["metavalue", ""],
["mm", "07"],
["mn", "48"],
["newproduct_cat", "New%2520category%2520name"],
["newproduct_cat_parent", "-1"],
["newtag%255Bproduct_tag%255D", ""],
["original_post_status", "auto-draft"],
["original_post_title", ""],
["original_publish", "Publish"],
["originalaction", "editpost"],
["post_ID", `${post_id}`],
["post_author", "1"],
["post_name", ""],
["post_password", ""],
["post_status", "draft"],
["post_title", `${add_product_title}`],
["post_type", "product"],
["product-type", "simple"],
["product_image_gallery", ""],
["product_shipping_class", "-1"],
["publish", "Publish"],
["referredby", ""],
["samplepermalinknonce", `${sample_permalink_nonce}`],
["ss", "12"],
["tax_input%255Bproduct_cat%255D%255B%255D", "0"],
["tax_input%255Bproduct_tag%255D", ""],
["user_ID", "1"],
["visibility", "public"],
["woocommerce_meta_nonce", `${woocommerce_meta_nonce}`],
["wp-preview", ""],
]);
const productParams = new URLSearchParams( [
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
[
'_ajax_nonce-add-product_cat',
`${ ajax_nonce_add_product_cat }`,
],
[ '_backorders', 'no' ],
[ '_button_text', '' ],
[ '_download_expiry', '' ],
[ '_download_limit', '' ],
[ '_height', '' ],
[ '_length', '' ],
[ '_low_stock_amount', '' ],
[ '_original_stock', '0' ],
[ '_product_url', '' ],
[ '_purchase_note', '' ],
[ '_regular_price', `${ add_product_regular_price }` ],
[ '_sale_price', '' ],
[ '_sale_price_dates_from', '' ],
[ '_sale_price_dates_to', '' ],
[ '_sku', '' ],
[ '_stock', '0' ],
[ '_stock_status', 'instock' ],
[ '_thumbnail_id', '-1' ],
[ '_visibility', 'visible' ],
[ '_weight', '' ],
[ '_width', '' ],
[ '_wp_http_referer', '' ],
[ '_wp_original_http_referer', '' ],
[ '_wpnonce', `${ wpnonce }` ],
[ 'aa', '2021' ],
[ 'action', 'editpost' ],
[ 'attribute_taxonomy', '' ],
[ 'auto_draft', '' ],
[ 'closedpostboxesnonce', `${ closed_postboxes_nonce }` ],
[ 'comment_status', 'open' ],
[ 'content', '' ],
[ 'cur_aa', '2021' ],
[ 'cur_hh', '15' ],
[ 'cur_jj', '09' ],
[ 'cur_mm', '07' ],
[ 'cur_mn', '48' ],
[ 'current_featured', 'no' ],
[ 'current_visibility', 'visible' ],
[ 'excerpt', '' ],
[ 'hh', '15' ],
[ 'hidden_aa', '2021' ],
[ 'hidden_hh', '15' ],
[ 'hidden_jj', '09' ],
[ 'hidden_mm', '07' ],
[ 'hidden_mn', '48' ],
[ 'hidden_post_password', '' ],
[ 'hidden_post_status', 'draft' ],
[ 'hidden_post_visibility', 'public' ],
[ 'jj', '09' ],
[ 'menu_order', '0' ],
[ 'meta-box-order-nonce', `${ meta_box_order_nonce }` ],
[ 'metakeyinput', '' ],
[ 'metakeyselect', '%2523NONE%2523' ],
[ 'metavalue', '' ],
[ 'mm', '07' ],
[ 'mn', '48' ],
[ 'newproduct_cat', 'New%2520category%2520name' ],
[ 'newproduct_cat_parent', '-1' ],
[ 'newtag%255Bproduct_tag%255D', '' ],
[ 'original_post_status', 'auto-draft' ],
[ 'original_post_title', '' ],
[ 'original_publish', 'Publish' ],
[ 'originalaction', 'editpost' ],
[ 'post_ID', `${ post_id }` ],
[ 'post_author', '1' ],
[ 'post_name', '' ],
[ 'post_password', '' ],
[ 'post_status', 'draft' ],
[ 'post_title', `${ add_product_title }` ],
[ 'post_type', 'product' ],
[ 'product-type', 'simple' ],
[ 'product_image_gallery', '' ],
[ 'product_shipping_class', '-1' ],
[ 'publish', 'Publish' ],
[ 'referredby', '' ],
[ 'samplepermalinknonce', `${ sample_permalink_nonce }` ],
[ 'ss', '12' ],
[ 'tax_input%255Bproduct_cat%255D%255B%255D', '0' ],
[ 'tax_input%255Bproduct_tag%255D', '' ],
[ 'user_ID', '1' ],
[ 'visibility', 'public' ],
[ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ],
[ 'wp-preview', '' ],
] );
response = http.post(
`${base_url}/wp-admin/post.php`,
`${ base_url }/wp-admin/post.php`,
productParams.toString(),
{
headers: requestHeaders,
tags: { name: 'Merchant - Update New Product' },
}
);
postNewTypeProductTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Edit product' header": (response) =>
response.body.includes("Edit product</h1>"),
"body contains: 'Product published' confirmation": (response) =>
response.body.includes("Product published."),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Edit product' header": ( response ) =>
response.body.includes( 'Edit product</h1>' ),
"body contains: 'Product published' confirmation": ( response ) =>
response.body.includes( 'Product published.' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,9 +1,19 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import { base_url, think_time_min, think_time_max } from '../../config.js';
import {
htmlRequestHeader,
jsonAPIRequestHeader,
@ -14,14 +24,7 @@ import {
commonPostRequestHeaders,
commonAPIGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let postTypeCouponTrend = new Trend("wc_get_post_type_coupon");
let wcAdminNotesMainTrend = new Trend("wc_get_admin_notes_main");
let wcAdminNotesOtherTrend = new Trend("wc_get_admin_notes_other");
let wcAdminCESOptionsTrend = new Trend("wc_get_admin_options_ces");
let wpAdminHeartbeatTrend = new Trend("wc_post_wp_admin_heartbeat");
} from '../../headers.js';
export function coupons() {
let response;
@ -29,23 +32,27 @@ export function coupons() {
let apiNonceHeader;
let heartbeat_nonce;
group("Coupons Page", function () {
var requestHeaders = Object.assign({},
group( 'Coupons Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-admin/edit.php?post_type=shop_coupon`, {
headers: requestHeaders,
});
postTypeCouponTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Coupons' header": (response) =>
response.body.includes("Coupons</h1>"),
});
response = http.get(
`${ base_url }/wp-admin/edit.php?post_type=shop_coupon`,
{
headers: requestHeaders,
tags: { name: 'Merchant - Coupons' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Coupons' header": ( response ) =>
response.body.includes( 'Coupons</h1>' ),
} );
// Correlate nonce values for use in subsequent requests.
heartbeat_nonce = findBetween(
@ -61,14 +68,15 @@ export function coupons() {
// Create request header with nonce value for use in subsequent requests.
apiNonceHeader = {
"x-wp-nonce": `${api_x_wp_nonce}`,
'x-wp-nonce': `${ api_x_wp_nonce }`,
};
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Inbox Notes", function () {
var requestHeaders = Object.assign({},
group( 'Coupons - Other Requests', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -77,54 +85,34 @@ export function coupons() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`status=unactioned&type%5B0%5D=info&type%5B1%5D=marketing&type%5B2%5D=survey&type%5B3%5D=warning&` +
`orderby=date&order=desc&_locale=user`,
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
}
);
wcAdminNotesMainTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue',
},
}
);
wcAdminNotesOtherTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("CES Options", function () {
var requestHeaders = Object.assign({},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
apiNonceHeader,
commonNonStandardHeaders
);
response = http.get(
`${base_url}/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
}
);
wcAdminCESOptionsTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
group("WP Admin Heartbeat", function () {
var requestHeaders = Object.assign({},
group( 'WP Admin Heartbeat', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
contentTypeRequestHeader,
@ -133,19 +121,19 @@ export function coupons() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`_nonce=${heartbeat_nonce}&action=heartbeat&has_focus=true&interval=15&screen_id=shop_coupon`,
`${ base_url }/wp-admin/admin-ajax.php`,
`_nonce=${ heartbeat_nonce }&action=heartbeat&has_focus=true&interval=15&screen_id=shop_coupon`,
{
headers: requestHeaders,
tags: { name: 'Merchant - action=heartbeat' },
}
);
wpAdminHeartbeatTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,53 +1,51 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import { base_url, think_time_min, think_time_max } from '../../config.js';
import {
htmlRequestHeader,
jsonAPIRequestHeader,
jsonRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
contentTypeRequestHeader,
commonPostRequestHeaders,
commonAPIGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let postTypeOrderTrend = new Trend("wc_get_post_type_order");
let wcAdminNotesMainTrend = new Trend("wc_get_admin_notes_main");
let wcAdminNotesOtherTrend = new Trend("wc_get_admin_notes_other");
let wcAdminCESOptionsTrend = new Trend("wc_get_admin_options_ces");
let wcAdminOrdersActivityTrend = new Trend("wc_get_analytics_orders");
let wcAdminProductsActivityTrend = new Trend("wc_get_analytics_products");
let wcAdminReviewsActivityTrend = new Trend("wc_get_analytics_reviews");
} from '../../headers.js';
export function homeWCAdmin() {
let response;
let api_x_wp_nonce;
let apiNonceHeader;
let heartbeat_nonce;
group("WC Home Page", function () {
var requestHeaders = Object.assign({},
group( 'WC Home Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-admin/admin.php?page=wc-admin`, {
response = http.get( `${ base_url }/wp-admin/admin.php?page=wc-admin`, {
headers: requestHeaders,
});
postTypeOrderTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: current page is 'Home'": (response) =>
response.body.includes('aria-current="page">Home'),
});
tags: { name: 'Merchant - WC-Admin' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: current page is 'Home'": ( response ) =>
response.body.includes( 'aria-current="page">Home' ),
} );
// Correlate nonce values for use in subsequent requests.
api_x_wp_nonce = findBetween(
@ -58,14 +56,15 @@ export function homeWCAdmin() {
// Create request header with nonce value for use in subsequent requests.
apiNonceHeader = {
"x-wp-nonce": `${api_x_wp_nonce}`,
'x-wp-nonce': `${ api_x_wp_nonce }`,
};
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Inbox Notes", function () {
var requestHeaders = Object.assign({},
group( 'WC Admin - Other Requests', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -74,33 +73,45 @@ export function homeWCAdmin() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`status=unactioned&type%5B0%5D=info&type%5B1%5D=marketing&type%5B2%5D=survey&type%5B3%5D=warning&` +
`orderby=date&order=desc&_locale=user`,
`${ base_url }/wp-json/wc-admin/onboarding/tasks?_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-admin/onboarding/tasks?' },
}
);
wcAdminNotesMainTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
}
);
wcAdminNotesOtherTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
group("Orders Activity", function () {
var requestHeaders = Object.assign({},
response = http.get(
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue',
},
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group( 'Orders Activity', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -109,20 +120,21 @@ export function homeWCAdmin() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/orders?page=1&per_page=1&status%5B0%5D=processing&` +
`status%5B1%5D=on-hold&_fields%5B0%5D=id&_locale=user`,
`${ base_url }/wp-json/wc-analytics/orders?page=1&per_page=1&status%5B0%5D=processing&` +
`status%5B1%5D=on-hold&_fields%5B0%5D=id&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/orders?' },
}
);
wcAdminOrdersActivityTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("Reviews Activity", function () {
var requestHeaders = Object.assign({},
group( 'Reviews Activity', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -131,20 +143,21 @@ export function homeWCAdmin() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/products/reviews?page=1&per_page=1&status=hold&` +
`_embed=1&_fields%5B0%5D=id&_locale=user`,
`${ base_url }/wp-json/wc-analytics/products/reviews?page=1&per_page=1&status=hold&` +
`_embed=1&_fields%5B0%5D=id&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/products/reviews?' },
}
);
wcAdminReviewsActivityTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("Products Activity", function () {
var requestHeaders = Object.assign({},
group( 'Products Activity', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -153,40 +166,21 @@ export function homeWCAdmin() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/products/low-in-stock?page=1&per_page=1&` +
`low_in_stock=true&status=publish&_fields%5B0%5D=id&_locale=user`,
`${ base_url }/wp-json/wc-analytics/products/low-in-stock?page=1&per_page=1&` +
`low_in_stock=true&status=publish&_fields%5B0%5D=id&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-analytics/products/low-in-stock?',
},
}
);
wcAdminProductsActivityTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("CES Options", function () {
var requestHeaders = Object.assign({},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
apiNonceHeader,
commonNonStandardHeaders
);
response = http.get(
`${base_url}/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
}
);
wcAdminCESOptionsTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,14 +1,22 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
admin_username,
admin_password,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
allRequestHeader,
@ -16,49 +24,46 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let myAccountTrend = new Trend("wc_get_myaccount");
let myAccountLoginTrend = new Trend("wc_post_myaccount");
let myAccountLoginTrend2 = new Trend("wc_post_wc-ajax_get_refreshed_fragments");
} from '../../headers.js';
export function myAccountMerchantLogin() {
let response;
let woocommerce_login_nonce;
group("My Account", function () {
var requestHeaders = Object.assign({},
group( 'My Account', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/my-account`, {
response = http.get( `${ base_url }/my-account`, {
headers: requestHeaders,
});
myAccountTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'My account' title": (response) =>
tags: { name: 'Shopper - My Account Login Page' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'My account' title": ( response ) =>
response.body.includes(
'<h1 class="entry-title">My account</h1>'
),
});
} );
// Correlate nonce value for use in subsequent requests.
woocommerce_login_nonce = response
.html()
.find("input[name=woocommerce-login-nonce]")
.find( 'input[name=woocommerce-login-nonce]' )
.first()
.attr("value");
});
.attr( 'value' );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("My Account Login", function () {
var requestHeaders = Object.assign({},
group( 'My Account Login', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -66,46 +71,48 @@ export function myAccountMerchantLogin() {
);
response = http.post(
`${base_url}/my-account`,
`${ base_url }/my-account`,
{
username: `${admin_username}`,
password: `${admin_password}`,
"woocommerce-login-nonce": `${woocommerce_login_nonce}`,
_wp_http_referer: "/my-account",
login: "Log%20in",
username: `${ admin_username }`,
password: `${ admin_password }`,
'woocommerce-login-nonce': `${ woocommerce_login_nonce }`,
_wp_http_referer: '/my-account',
login: 'Log%20in',
},
{
headers: {
headers: requestHeaders,
},
headers: requestHeaders,
tags: { name: 'Shopper - Login to My Account' },
}
);
myAccountLoginTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: my account welcome message": (response) =>
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: my account welcome message': ( response ) =>
response.body.includes(
"From your account dashboard you can view"
'From your account dashboard you can view'
),
});
} );
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders
);
response = http.post(`${base_url}/?wc-ajax=get_refreshed_fragments`, {
headers: requestHeaders,
});
myAccountLoginTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
response = http.post(
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
{
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,9 +1,25 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
cot_status,
admin_orders_base_url,
cot_admin_orders_base_url,
think_time_min,
think_time_max,
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -12,37 +28,48 @@ import {
contentTypeRequestHeader,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
} from '../../headers.js';
// Nonce and cookie jar to be used in subsequent iterations
let heartbeat_nonce;
let jar;
// Custom metrics to add to standard results output.
let postTypeOrderTrend = new Trend("wc_get_post_type_order");
let wpAdminHeartbeatTrend = new Trend("wc_post_wp_admin_heartbeat");
// Change URL if COT is enabled and being used
let admin_orders_base;
if ( cot_status === true ) {
admin_orders_base = cot_admin_orders_base_url;
} else {
admin_orders_base = admin_orders_base_url;
}
export function ordersHeartbeat() {
let response;
// Request orders list only on first iteration to correlate heartbeat nonce
if (__ITER == 0) {
group("Orders Page", function () {
var requestHeaders = Object.assign({},
// eslint-disable-next-line no-undef, eqeqeq
if ( __ITER == 0 ) {
group( 'Orders Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-admin/edit.php?post_type=shop_order`, {
headers: requestHeaders,
});
postTypeOrderTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Orders' header": (response) =>
response.body.includes("Orders</h1>"),
});
response = http.get(
`${ base_url }/wp-admin/${ admin_orders_base }`,
{
headers: requestHeaders,
tags: { name: 'Merchant - All Orders' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
// eslint-disable-next-line no-shadow
"body contains: 'Orders' header": ( response ) =>
response.body.includes( 'Orders</h1>' ),
} );
// Correlate nonce values for use in subsequent requests.
heartbeat_nonce = findBetween(
@ -53,13 +80,16 @@ export function ordersHeartbeat() {
// Cookie jar for subsequent iterations so cookies won't be reset
jar = http.cookieJar();
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep(
randomIntBetween( `${ think_time_min }`, `${ think_time_max }` )
);
}
group("WP Admin Heartbeat", function () {
var requestHeaders = Object.assign({},
group( 'WP Admin Heartbeat', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
contentTypeRequestHeader,
@ -68,20 +98,20 @@ export function ordersHeartbeat() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`_nonce=${heartbeat_nonce}&action=heartbeat&has_focus=true&interval=15&screen_id=shop_order`,
`${ base_url }/wp-admin/admin-ajax.php`,
`_nonce=${ heartbeat_nonce }&action=heartbeat&has_focus=true&interval=15&screen_id=shop_order`,
{
headers: requestHeaders,
jar
tags: { name: 'Merchant - action=heartbeat' },
jar,
}
);
wpAdminHeartbeatTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,28 +1,45 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable import/no-unresolved */
/* eslint-disable no-shadow */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
cot_status,
admin_orders_base_url,
cot_admin_orders_base_url,
think_time_min,
think_time_max,
product_search_term,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
} from '../../headers.js';
// Custom metrics to add to standard results output.
let postTypeOrderSearchTrend = new Trend("wc_get_post_type_order_search");
// Change URL if COT is enabled and being used
let admin_orders_base;
if ( cot_status === true ) {
admin_orders_base = cot_admin_orders_base_url;
} else {
admin_orders_base = admin_orders_base_url;
}
export function ordersSearch() {
let response;
group("Orders Search", function () {
var requestHeaders = Object.assign({},
group( 'Orders Search', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -30,22 +47,22 @@ export function ordersSearch() {
);
response = http.get(
`${base_url}/wp-admin/edit.php?s=${product_search_term}&` +
`post_status=all&post_type=shop_order&action=-1&m=0&_customer_user&` +
`paged=1&action2=-1`,
`${ base_url }/wp-admin/${ admin_orders_base }` +
`&s=${ product_search_term }&action=-1&m=0&_customer_user&` +
`paged=1&action2=-1`,
{
headers: requestHeaders,
tags: { name: 'Merchant - Search Orders By Product' },
}
);
postTypeOrderSearchTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Search results' subtitle": (response) =>
response.body.includes("Search results for:"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Search results' subtitle": ( response ) =>
response.body.includes( 'Search results for:' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,9 +1,26 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
cot_status,
admin_orders_base_url,
cot_admin_orders_base_url,
think_time_min,
think_time_max,
} from '../../config.js';
import {
htmlRequestHeader,
jsonAPIRequestHeader,
@ -14,14 +31,15 @@ import {
commonPostRequestHeaders,
commonAPIGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
} from '../../headers.js';
// Custom metrics to add to standard results output.
let postTypeOrderTrend = new Trend("wc_get_post_type_order");
let wcAdminNotesMainTrend = new Trend("wc_get_admin_notes_main");
let wcAdminNotesOtherTrend = new Trend("wc_get_admin_notes_other");
let wcAdminCESOptionsTrend = new Trend("wc_get_admin_options_ces");
let wpAdminHeartbeatTrend = new Trend("wc_post_wp_admin_heartbeat");
// Change URL if COT is enabled and being used
let admin_orders_base;
if ( cot_status === true ) {
admin_orders_base = cot_admin_orders_base_url;
} else {
admin_orders_base = admin_orders_base_url;
}
export function orders() {
let response;
@ -29,23 +47,24 @@ export function orders() {
let apiNonceHeader;
let heartbeat_nonce;
group("Orders Page", function () {
var requestHeaders = Object.assign({},
group( 'All Orders', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-admin/edit.php?post_type=shop_order`, {
response = http.get( `${ base_url }/wp-admin/${ admin_orders_base }`, {
headers: requestHeaders,
});
postTypeOrderTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Orders' header": (response) =>
response.body.includes("Orders</h1>"),
});
tags: { name: 'Merchant - All Orders' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Orders' header": ( response ) =>
response.body.includes( 'Orders</h1>' ),
} );
// Correlate nonce values for use in subsequent requests.
heartbeat_nonce = findBetween(
@ -61,14 +80,15 @@ export function orders() {
// Create request header with nonce value for use in subsequent requests.
apiNonceHeader = {
"x-wp-nonce": `${api_x_wp_nonce}`,
'x-wp-nonce': `${ api_x_wp_nonce }`,
};
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Inbox Notes", function () {
var requestHeaders = Object.assign({},
group( 'All Orders - Other Requests', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -77,54 +97,45 @@ export function orders() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`status=unactioned&type%5B0%5D=info&type%5B1%5D=marketing&type%5B2%5D=survey&type%5B3%5D=warning&` +
`orderby=date&order=desc&_locale=user`,
`${ base_url }/wp-json/wc-admin/onboarding/tasks?_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-admin/onboarding/tasks?' },
}
);
wcAdminNotesMainTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
}
);
wcAdminNotesOtherTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
group("CES Options", function () {
var requestHeaders = Object.assign({},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
apiNonceHeader,
commonNonStandardHeaders
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue',
},
}
);
wcAdminCESOptionsTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("WP Admin Heartbeat", function () {
var requestHeaders = Object.assign({},
group( 'WP Admin Heartbeat', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
contentTypeRequestHeader,
@ -133,19 +144,19 @@ export function orders() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`_nonce=${heartbeat_nonce}&action=heartbeat&has_focus=true&interval=15&screen_id=shop_order`,
`${ base_url }/wp-admin/admin-ajax.php`,
`_nonce=${ heartbeat_nonce }&action=heartbeat&has_focus=true&interval=15&screen_id=shop_order`,
{
headers: requestHeaders,
tags: { name: 'Merchant - action=heartbeat' },
}
);
wpAdminHeartbeatTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,9 +1,19 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import { base_url, think_time_min, think_time_max } from '../../config.js';
import {
htmlRequestHeader,
jsonAPIRequestHeader,
@ -14,14 +24,7 @@ import {
commonPostRequestHeaders,
commonAPIGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let postTypeProductTrend = new Trend("wc_get_post_type_product");
let wcAdminNotesMainTrend = new Trend("wc_get_admin_notes_main");
let wcAdminNotesOtherTrend = new Trend("wc_get_admin_notes_other");
let wcAdminCESOptionsTrend = new Trend("wc_get_admin_options_ces");
let wpAdminHeartbeatTrend = new Trend("wc_post_wp_admin_heartbeat");
} from '../../headers.js';
export function products() {
let response;
@ -29,23 +32,27 @@ export function products() {
let apiNonceHeader;
let heartbeat_nonce;
group("Products Page", function () {
var requestHeaders = Object.assign({},
group( 'Products Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-admin/edit.php?post_type=product`, {
headers: requestHeaders,
});
postTypeProductTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Products' header": (response) =>
response.body.includes("Products</h1>"),
});
response = http.get(
`${ base_url }/wp-admin/edit.php?post_type=product`,
{
headers: requestHeaders,
tags: { name: 'Merchant - All Products' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Products' header": ( response ) =>
response.body.includes( 'Products</h1>' ),
} );
// Correlate nonce values for use in subsequent requests.
heartbeat_nonce = findBetween(
@ -61,14 +68,15 @@ export function products() {
// Create request header with nonce value for use in subsequent requests.
apiNonceHeader = {
"x-wp-nonce": `${api_x_wp_nonce}`,
'x-wp-nonce': `${ api_x_wp_nonce }`,
};
});
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Inbox Notes", function () {
var requestHeaders = Object.assign({},
group( 'All Products - Other Requests', function () {
const requestHeaders = Object.assign(
{},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
@ -77,54 +85,45 @@ export function products() {
);
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`status=unactioned&type%5B0%5D=info&type%5B1%5D=marketing&type%5B2%5D=survey&type%5B3%5D=warning&` +
`orderby=date&order=desc&_locale=user`,
`${ base_url }/wp-json/wc-admin/onboarding/tasks?_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-admin/onboarding/tasks?' },
}
);
wcAdminNotesMainTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
`type=error%2Cupdate&status=unactioned&_locale=user`,
{
headers: requestHeaders,
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
}
);
wcAdminNotesOtherTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
group("CES Options", function () {
var requestHeaders = Object.assign({},
jsonAPIRequestHeader,
commonRequestHeaders,
commonAPIGetRequestHeaders,
apiNonceHeader,
commonNonStandardHeaders
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
response = http.get(
`${base_url}/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
{
headers: requestHeaders,
tags: {
name: 'Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue',
},
}
);
wcAdminCESOptionsTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
group("WP Admin Heartbeat", function () {
var requestHeaders = Object.assign({},
group( 'WP Admin Heartbeat', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
contentTypeRequestHeader,
@ -133,19 +132,19 @@ export function products() {
);
response = http.post(
`${base_url}/wp-admin/admin-ajax.php`,
`_nonce=${heartbeat_nonce}&action=heartbeat&has_focus=true&interval=15&screen_id=edit-product`,
`${ base_url }/wp-admin/admin-ajax.php`,
`_nonce=${ heartbeat_nonce }&action=heartbeat&has_focus=true&interval=15&screen_id=edit-product`,
{
headers: requestHeaders,
tags: { name: 'Merchant - action=heartbeat' },
}
);
wpAdminHeartbeatTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,59 +1,65 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
admin_username,
admin_password,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let wpLoginTrend = new Trend("wc_get_wp_login");
let wpLoginWPAdminTrend = new Trend("wc_post_wp_login");
} from '../../headers.js';
export function wpLogin() {
let response;
let testcookie;
group("Login Page", function () {
var requestHeaders = Object.assign({},
group( 'Login Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/wp-login.php`, {
response = http.get( `${ base_url }/wp-login.php`, {
headers: requestHeaders,
});
wpLoginTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Log in' title": (response) =>
response.body.includes("<title>Log In"),
});
tags: { name: 'Merchant - WP Login Page' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Log in' title": ( response ) =>
response.body.includes( '<title>Log In' ),
} );
// Correlate cookie value for use in subsequent requests.
testcookie = response
.html()
.find("input[name=testcookie]")
.find( 'input[name=testcookie]' )
.first()
.attr("value");
});
.attr( 'value' );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Login to WP Admin", function () {
var requestHeaders = Object.assign({},
group( 'Login to WP Admin', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -61,27 +67,27 @@ export function wpLogin() {
);
response = http.post(
`${base_url}/wp-login.php`,
`${ base_url }/wp-login.php`,
{
log: `${admin_username}`,
pwd: `${admin_password}`,
"wp-submit": "Log%20In",
redirect_to: `${base_url}/wp-admin`,
testcookie: `${testcookie}`,
log: `${ admin_username }`,
pwd: `${ admin_password }`,
'wp-submit': 'Log%20In',
redirect_to: `${ base_url }/wp-admin`,
testcookie: `${ testcookie }`,
},
{
headers: requestHeaders,
tags: { name: 'Merchant - Login to WP Admin' },
}
);
wpLoginWPAdminTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: wp-admin 'Dashboard' header": (response) =>
response.body.includes("<h1>Dashboard</h1>"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: wp-admin 'Dashboard' header": ( response ) =>
response.body.includes( '<h1>Dashboard</h1>' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,8 +1,18 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
product_sku,
@ -10,7 +20,7 @@ import {
coupon_code,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -19,22 +29,17 @@ import {
commonPostRequestHeaders,
commonNonStandardHeaders,
contentTypeRequestHeader,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let addToCartTrend = new Trend("wc_post_wc-ajax_add_to_cart");
let viewCartTrend = new Trend("wc_get_cart");
let applyCouponTrend = new Trend("wc_post_wc-ajax_apply_coupon");
let applyCouponCartTrend = new Trend("wc_post_cart");
} from '../../headers.js';
export function cartApplyCoupon() {
let response;
let apply_coupon_nonce;
let item_name;
// let item_name;
let woocommerce_cart_nonce;
group("Product Page Add to cart", function () {
var requestheaders = Object.assign({},
group( 'Product Page Add to cart', function () {
const requestheaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -42,42 +47,43 @@ export function cartApplyCoupon() {
);
response = http.post(
`${base_url}/?wc-ajax=add_to_cart`,
`${ base_url }/?wc-ajax=add_to_cart`,
{
product_sku: `${product_sku}`,
product_id: `${product_id}`,
quantity: "1",
product_sku: `${ product_sku }`,
product_id: `${ product_id }`,
quantity: '1',
},
{
headers: requestheaders,
tags: { name: 'Shopper - wc-ajax=add_to_cart' },
}
);
addToCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("View Cart", function () {
var requestheaders = Object.assign({},
group( 'View Cart', function () {
const requestheaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/cart`, {
response = http.get( `${ base_url }/cart`, {
headers: requestheaders,
});
viewCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
tags: { name: 'Shopper - View Cart' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body does not contain: 'your cart is currently empty'": (
response
) => !response.body.includes("Your cart is currently empty."),
});
) => ! response.body.includes( 'Your cart is currently empty.' ),
} );
// Correlate cart item value for use in subsequent requests.
apply_coupon_nonce = findBetween(
@ -85,22 +91,19 @@ export function cartApplyCoupon() {
'apply_coupon_nonce":"',
'","'
);
item_name = findBetween(
response.body,
'name="cart[',
'][qty]'
);
// item_name = findBetween( response.body, 'name="cart[', '][qty]' );
woocommerce_cart_nonce = response
.html()
.find("input[name=woocommerce-cart-nonce]")
.find( 'input[name=woocommerce-cart-nonce]' )
.first()
.attr("value");
});
.attr( 'value' );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Apply Coupon", function () {
var requestheaders = Object.assign({},
group( 'Apply Coupon', function () {
const requestheaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -109,43 +112,44 @@ export function cartApplyCoupon() {
);
response = http.post(
`${base_url}/?wc-ajax=apply_coupon`,
`${ base_url }/?wc-ajax=apply_coupon`,
{
coupon_code: `${coupon_code}`,
security: `${apply_coupon_nonce}`,
coupon_code: `${ coupon_code }`,
security: `${ apply_coupon_nonce }`,
},
{
headers: requestheaders,
tags: { name: 'Shopper - wc-ajax=apply_coupon' },
}
);
applyCouponTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Coupon code applied successfully'": (response) =>
response.body.includes("Coupon code applied successfully"),
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Coupon code applied successfully'": ( response ) =>
response.body.includes( 'Coupon code applied successfully' ),
} );
response = http.post(`${base_url}/cart`,
{
_wp_http_referer: "%2Fcart",
//"cart["+`${item_name}`+"][qty]": "1",
coupon_code: "",
"woocommerce-cart-nonce": `${woocommerce_cart_nonce}`,
},
{
headers: requestheaders,
}
response = http.post(
`${ base_url }/cart`,
{
_wp_http_referer: '%2Fcart',
// "cart["+`${item_name}`+"][qty]": "1",
coupon_code: '',
'woocommerce-cart-nonce': `${ woocommerce_cart_nonce }`,
},
{
headers: requestheaders,
tags: { name: 'Shopper - Update Cart' },
}
);
applyCouponCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'woocommerce-remove-coupon' class": (response) =>
response.body.includes('class="woocommerce-remove-coupon"'),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'woocommerce-remove-coupon' class": ( response ) =>
response.body.includes( 'class="woocommerce-remove-coupon"' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,15 +1,25 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
product_sku,
product_id,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -17,20 +27,16 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let addToCartTrend = new Trend("wc_post_wc-ajax_add_to_cart");
let viewCartTrend = new Trend("wc_get_cart");
let removeItemCartTrend = new Trend("wc_get_cart_remove_item");
} from '../../headers.js';
export function cartRemoveItem() {
let response;
let item_to_remove;
let wpnonce;
group("Product Page Add to cart", function () {
var requestheaders = Object.assign({},
group( 'Product Page Add to cart', function () {
const requestheaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -38,78 +44,75 @@ export function cartRemoveItem() {
);
response = http.post(
`${base_url}/?wc-ajax=add_to_cart`,
`${ base_url }/?wc-ajax=add_to_cart`,
{
product_sku: `${product_sku}`,
product_id: `${product_id}`,
quantity: "1",
product_sku: `${ product_sku }`,
product_id: `${ product_id }`,
quantity: '1',
},
{
headers: requestheaders,
tags: { name: 'Shopper - wc-ajax=add_to_cart' },
}
);
addToCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("View Cart", function () {
var requestheaders = Object.assign({},
group( 'View Cart', function () {
const requestheaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/cart`, {
response = http.get( `${ base_url }/cart`, {
headers: requestheaders,
});
viewCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
tags: { name: 'Shopper - View Cart' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body does not contain: 'your cart is currently empty'": (
response
) => !response.body.includes("Your cart is currently empty."),
});
) => ! response.body.includes( 'Your cart is currently empty.' ),
} );
// Correlate cart item value for use in subsequent requests.
item_to_remove = findBetween(
response.body,
'?remove_item=',
'&'
);
wpnonce = findBetween(
response.body,
'_wpnonce=',
'" class="remove"'
);
});
item_to_remove = findBetween( response.body, '?remove_item=', '&' );
wpnonce = findBetween( response.body, '_wpnonce=', '" class="remove"' );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Remove item from cart", function () {
var requestheaders = Object.assign({},
group( 'Remove item from cart', function () {
const requestheaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/cart?remove_item=${item_to_remove}&_wpnonce=${wpnonce}`, {
headers: requestheaders,
});
removeItemCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'removed'": (response) =>
response.body.includes(" removed."),
});
});
response = http.get(
`${ base_url }/cart?remove_item=${ item_to_remove }&_wpnonce=${ wpnonce }`,
{
headers: requestheaders,
tags: { name: 'Shopper - Remove Item From Cart' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'removed'": ( response ) =>
response.body.includes( ' removed.' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,14 +1,22 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
product_sku,
product_id,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -16,17 +24,14 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let addToCartTrend = new Trend("wc_post_wc-ajax_add_to_cart");
let viewCartTrend = new Trend("wc_get_cart");
} from '../../headers.js';
export function cart() {
let response;
group("Product Page Add to cart", function () {
var requestheaders = Object.assign({},
group( 'Product Page Add to cart', function () {
const requestheaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -34,45 +39,46 @@ export function cart() {
);
response = http.post(
`${base_url}/?wc-ajax=add_to_cart`,
`${ base_url }/?wc-ajax=add_to_cart`,
{
product_sku: `${product_sku}`,
product_id: `${product_id}`,
quantity: "1",
product_sku: `${ product_sku }`,
product_id: `${ product_id }`,
quantity: '1',
},
{
headers: requestheaders,
tags: { name: 'Shopper - wc-ajax=add_to_cart' },
}
);
addToCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("View Cart", function () {
var requestheaders = Object.assign({},
group( 'View Cart', function () {
const requestheaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/cart`, {
response = http.get( `${ base_url }/cart`, {
headers: requestheaders,
});
viewCartTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
tags: { name: 'Shopper - View Cart' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body does not contain: 'your cart is currently empty'": (
response
) => !response.body.includes("Your cart is currently empty."),
});
});
) => ! response.body.includes( 'Your cart is currently empty.' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,43 +1,57 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max, product_category } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
think_time_min,
think_time_max,
product_category,
} from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metric to add to standard results output.
let categoryPageTrend = new Trend("wc_get_product_category_name");
} from '../../headers.js';
export function categoryPage() {
let response;
group("Category Page", function () {
var requestHeaders = Object.assign({},
group( 'Category Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/product-category/${product_category}/`, {
headers: requestHeaders,
});
categoryPageTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: Category's title": (response) =>
response = http.get(
`${ base_url }/product-category/${ product_category }/`,
{
headers: requestHeaders,
tags: { name: 'Shopper - Category Page' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: Category's title": ( response ) =>
response.body.includes(
`<h1 class="woocommerce-products-header__title page-title">${product_category}</h1>`
`<h1 class="woocommerce-products-header__title page-title">${ product_category }</h1>`
),
});
});
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,8 +1,18 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
customer_username,
@ -27,7 +37,7 @@ import {
payment_method,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -36,15 +46,7 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let proceedCheckoutTrend1 = new Trend("wc_get_checkout");
let proceedCheckoutTrend2 = new Trend("wc_post_wc-ajax_update_order_review");
let checkoutLoginTrend = new Trend("wc_post_checkout");
let placeOrderTrend = new Trend("wc_post_wc-ajax_checkout");
let orderReceivedTrend1 = new Trend("wc_get_order_received");
let orderReceivedTrend2 = new Trend("wc_post_wc-ajax_get_refreshed_fragments");
} from '../../headers.js';
export function checkoutCustomerLogin() {
let response;
@ -53,37 +55,41 @@ export function checkoutCustomerLogin() {
let update_order_review_nonce_guest;
let update_order_review_nonce_customer;
group("Proceed to checkout", function () {
var requestHeaders = Object.assign({},
group( 'Proceed to checkout', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/checkout`, {
response = http.get( `${ base_url }/checkout`, {
headers: requestHeaders,
});
proceedCheckoutTrend1.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains checkout class": (response) =>
response.body.includes('class="checkout woocommerce-checkout"'),
});
tags: { name: 'Shopper - View Checkout' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains checkout class': ( response ) =>
response.body.includes(
'class="checkout woocommerce-checkout"'
),
} );
// Correlate nonce values for use in subsequent requests.
woocommerce_login_nonce = response
.html()
.find("input[name=woocommerce-login-nonce]")
.find( 'input[name=woocommerce-login-nonce]' )
.first()
.attr("value");
.attr( 'value' );
update_order_review_nonce_guest = findBetween(
response.body,
'update_order_review_nonce":"',
'","apply_coupon_nonce'
);
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -91,38 +97,39 @@ export function checkoutCustomerLogin() {
);
response = http.post(
`${base_url}/?wc-ajax=update_order_review`,
`${ base_url }/?wc-ajax=update_order_review`,
{
security: `${update_order_review_nonce_guest}`,
payment_method: `${payment_method}`,
country: `${addresses_guest_billing_country}`,
state: `${addresses_guest_billing_state}`,
postcode: `${addresses_guest_billing_postcode}`,
city: `${addresses_guest_billing_city}`,
address: `${addresses_guest_billing_address_1}`,
address_2: `${addresses_guest_billing_address_2}`,
s_country: `${addresses_guest_billing_country}`,
s_state: `${addresses_guest_billing_state}`,
s_postcode: `${addresses_guest_billing_postcode}`,
s_city: `${addresses_guest_billing_city}`,
s_address: `${addresses_guest_billing_address_1}`,
s_address_2: `${addresses_guest_billing_address_2}`,
has_full_address: "true",
security: `${ update_order_review_nonce_guest }`,
payment_method: `${ payment_method }`,
country: `${ addresses_guest_billing_country }`,
state: `${ addresses_guest_billing_state }`,
postcode: `${ addresses_guest_billing_postcode }`,
city: `${ addresses_guest_billing_city }`,
address: `${ addresses_guest_billing_address_1 }`,
address_2: `${ addresses_guest_billing_address_2 }`,
s_country: `${ addresses_guest_billing_country }`,
s_state: `${ addresses_guest_billing_state }`,
s_postcode: `${ addresses_guest_billing_postcode }`,
s_city: `${ addresses_guest_billing_city }`,
s_address: `${ addresses_guest_billing_address_1 }`,
s_address_2: `${ addresses_guest_billing_address_2 }`,
has_full_address: 'true',
},
{
headers: requestHeaders,
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=update_order_review' },
}
);
proceedCheckoutTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Login on checkout", function () {
var requestHeaders = Object.assign({},
group( 'Login on checkout', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -130,39 +137,38 @@ export function checkoutCustomerLogin() {
);
response = http.post(
`${base_url}/checkout`,
`${ base_url }/checkout`,
{
username: `${customer_username}`,
password: `${customer_password}`,
"woocommerce-login-nonce": `${woocommerce_login_nonce}`,
_wp_http_referer: "%2Fcheckout",
redirect: `${base_url}/checkout`,
login: "Login",
username: `${ customer_username }`,
password: `${ customer_password }`,
'woocommerce-login-nonce': `${ woocommerce_login_nonce }`,
_wp_http_referer: '%2Fcheckout',
redirect: `${ base_url }/checkout`,
login: 'Login',
},
{
headers: {
headers: requestHeaders,
},
headers: requestHeaders,
tags: { name: 'Shopper - Login to Checkout' },
}
);
checkoutLoginTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
// Correlate nonce values for use in subsequent requests.
woocommerce_process_checkout_nonce_customer = response
.html()
.find("input[name=woocommerce-process-checkout-nonce]")
.find( 'input[name=woocommerce-process-checkout-nonce]' )
.first()
.attr("value");
.attr( 'value' );
update_order_review_nonce_customer = findBetween(
response.body,
'update_order_review_nonce":"',
'","apply_coupon_nonce'
);
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -170,38 +176,39 @@ export function checkoutCustomerLogin() {
);
response = http.post(
`${base_url}/?wc-ajax=update_order_review`,
`${ base_url }/?wc-ajax=update_order_review`,
{
security: `${update_order_review_nonce_customer}`,
payment_method: `${payment_method}`,
country: `${addresses_customer_billing_country}`,
state: `${addresses_customer_billing_state}`,
postcode: `${addresses_customer_billing_postcode}`,
city: `${addresses_customer_billing_city}`,
address: `${addresses_customer_billing_address_1}`,
address_2: `${addresses_customer_billing_address_2}`,
s_country: `${addresses_customer_billing_country}`,
s_state: `${addresses_customer_billing_state}`,
s_postcode: `${addresses_customer_billing_postcode}`,
s_city: `${addresses_customer_billing_city}`,
s_address: `${addresses_customer_billing_address_1}`,
s_address_2: `${addresses_customer_billing_address_2}`,
has_full_address: "true",
security: `${ update_order_review_nonce_customer }`,
payment_method: `${ payment_method }`,
country: `${ addresses_customer_billing_country }`,
state: `${ addresses_customer_billing_state }`,
postcode: `${ addresses_customer_billing_postcode }`,
city: `${ addresses_customer_billing_city }`,
address: `${ addresses_customer_billing_address_1 }`,
address_2: `${ addresses_customer_billing_address_2 }`,
s_country: `${ addresses_customer_billing_country }`,
s_state: `${ addresses_customer_billing_state }`,
s_postcode: `${ addresses_customer_billing_postcode }`,
s_city: `${ addresses_customer_billing_city }`,
s_address: `${ addresses_customer_billing_address_1 }`,
s_address_2: `${ addresses_customer_billing_address_2 }`,
has_full_address: 'true',
},
{
headers: requestHeaders,
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=update_order_review' },
}
);
proceedCheckoutTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Place Order", function () {
var requestHeaders = Object.assign({},
group( 'Place Order', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -209,76 +216,81 @@ export function checkoutCustomerLogin() {
);
response = http.post(
`${base_url}/?wc-ajax=checkout`,
`${ base_url }/?wc-ajax=checkout`,
{
billing_first_name: `${addresses_customer_billing_first_name}`,
billing_last_name: `${addresses_customer_billing_last_name}`,
billing_company: `${addresses_customer_billing_company}`,
billing_country: `${addresses_customer_billing_country}`,
billing_address_1: `${addresses_customer_billing_address_1}`,
billing_address_2: `${addresses_customer_billing_address_2}`,
billing_city: `${addresses_customer_billing_city}`,
billing_state: `${addresses_customer_billing_state}`,
billing_postcode: `${addresses_customer_billing_postcode}`,
billing_phone: `${addresses_customer_billing_phone}`,
billing_email: `${addresses_customer_billing_email}`,
order_comments: "",
payment_method: `${payment_method}`,
"woocommerce-process-checkout-nonce": `${woocommerce_process_checkout_nonce_customer}`,
_wp_http_referer: "%2F%3Fwc-ajax%3Dupdate_order_review",
billing_first_name: `${ addresses_customer_billing_first_name }`,
billing_last_name: `${ addresses_customer_billing_last_name }`,
billing_company: `${ addresses_customer_billing_company }`,
billing_country: `${ addresses_customer_billing_country }`,
billing_address_1: `${ addresses_customer_billing_address_1 }`,
billing_address_2: `${ addresses_customer_billing_address_2 }`,
billing_city: `${ addresses_customer_billing_city }`,
billing_state: `${ addresses_customer_billing_state }`,
billing_postcode: `${ addresses_customer_billing_postcode }`,
billing_phone: `${ addresses_customer_billing_phone }`,
billing_email: `${ addresses_customer_billing_email }`,
order_comments: '',
payment_method: `${ payment_method }`,
'woocommerce-process-checkout-nonce': `${ woocommerce_process_checkout_nonce_customer }`,
_wp_http_referer: '%2F%3Fwc-ajax%3Dupdate_order_review',
},
{
headers: requestHeaders,
tags: { name: 'Shopper - wc-ajax=checkout' },
}
);
placeOrderTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: order-received": (response) =>
response.body.includes("order-received"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: order-received': ( response ) =>
response.body.includes( 'order-received' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Order received", function () {
var requestHeaders = Object.assign({},
group( 'Order received', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/checkout/order-received/`, {
headers: requestheaders,
});
check(response, {
response = http.get( `${ base_url }/checkout/order-received/`, {
headers: requestHeaders,
tags: { name: 'Shopper - Order Received' },
} );
check( response, {
"body contains: 'Thank you. Your order has been received.'": (
response
) =>
response.body.includes(
"Thank you. Your order has been received."
'Thank you. Your order has been received.'
),
});
orderReceivedTrend1.add(response.timings.duration);
} );
var requestheaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders
);
response = http.post(`${base_url}/?wc-ajax=get_refreshed_fragments`, {
headers: requestHeaders,
});
orderReceivedTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
response = http.post(
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
{
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,8 +1,18 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { findBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import {
randomIntBetween,
findBetween,
} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
addresses_guest_billing_first_name,
@ -19,7 +29,7 @@ import {
payment_method,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
jsonRequestHeader,
@ -28,51 +38,48 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let proceedCheckoutTrend1 = new Trend("wc_get_checkout");
let proceedCheckoutTrend2 = new Trend("wc_post_wc-ajax_update_order_review");
let placeOrderTrend = new Trend("wc_post_wc-ajax_checkout");
let orderReceivedTrend1 = new Trend("wc_get_order_received");
let orderReceivedTrend2 = new Trend("wc_post_wc-ajax_get_refreshed_fragments");
} from '../../headers.js';
export function checkoutGuest() {
let response;
let woocommerce_process_checkout_nonce_guest;
let update_order_review_nonce_guest;
group("Proceed to checkout", function () {
var requestHeaders = Object.assign({},
group( 'Proceed to checkout', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/checkout`, {
response = http.get( `${ base_url }/checkout`, {
headers: requestHeaders,
});
proceedCheckoutTrend1.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'woocommerce-checkout' class": (response) =>
response.body.includes('class="checkout woocommerce-checkout"'),
});
tags: { name: 'Shopper - View Checkout' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'woocommerce-checkout' class": ( response ) =>
response.body.includes(
'class="checkout woocommerce-checkout"'
),
} );
// Correlate nonce values for use in subsequent requests.
woocommerce_process_checkout_nonce_guest = response
.html()
.find("input[name=woocommerce-process-checkout-nonce]")
.find( 'input[name=woocommerce-process-checkout-nonce]' )
.first()
.attr("value");
.attr( 'value' );
update_order_review_nonce_guest = findBetween(
response.body,
'update_order_review_nonce":"',
'","apply_coupon_nonce'
);
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -80,38 +87,39 @@ export function checkoutGuest() {
);
response = http.post(
`${base_url}/?wc-ajax=update_order_review`,
`${ base_url }/?wc-ajax=update_order_review`,
{
security: `${update_order_review_nonce_guest}`,
payment_method: `${payment_method}`,
country: `${addresses_guest_billing_country}`,
state: `${addresses_guest_billing_state}`,
postcode: `${addresses_guest_billing_postcode}`,
city: `${addresses_guest_billing_city}`,
address: `${addresses_guest_billing_address_1}`,
address_2: `${addresses_guest_billing_address_2}`,
s_country: `${addresses_guest_billing_country}`,
s_state: `${addresses_guest_billing_state}`,
s_postcode: `${addresses_guest_billing_postcode}`,
s_city: `${addresses_guest_billing_city}`,
s_address: `${addresses_guest_billing_address_1}`,
s_address_2: `${addresses_guest_billing_address_2}`,
has_full_address: "true",
security: `${ update_order_review_nonce_guest }`,
payment_method: `${ payment_method }`,
country: `${ addresses_guest_billing_country }`,
state: `${ addresses_guest_billing_state }`,
postcode: `${ addresses_guest_billing_postcode }`,
city: `${ addresses_guest_billing_city }`,
address: `${ addresses_guest_billing_address_1 }`,
address_2: `${ addresses_guest_billing_address_2 }`,
s_country: `${ addresses_guest_billing_country }`,
s_state: `${ addresses_guest_billing_state }`,
s_postcode: `${ addresses_guest_billing_postcode }`,
s_city: `${ addresses_guest_billing_city }`,
s_address: `${ addresses_guest_billing_address_1 }`,
s_address_2: `${ addresses_guest_billing_address_2 }`,
has_full_address: 'true',
},
{
headers: requestHeaders,
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=update_order_review' },
}
);
proceedCheckoutTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Place Order", function () {
var requestHeaders = Object.assign({},
group( 'Place Order', function () {
const requestHeaders = Object.assign(
{},
jsonRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
@ -119,76 +127,81 @@ export function checkoutGuest() {
);
response = http.post(
`${base_url}/?wc-ajax=checkout`,
`${ base_url }/?wc-ajax=checkout`,
{
billing_first_name: `${addresses_guest_billing_first_name}`,
billing_last_name: `${addresses_guest_billing_last_name}`,
billing_company: `${addresses_guest_billing_company}`,
billing_country: `${addresses_guest_billing_country}`,
billing_address_1: `${addresses_guest_billing_address_1}`,
billing_address_2: `${addresses_guest_billing_address_2}`,
billing_city: `${addresses_guest_billing_city}`,
billing_state: `${addresses_guest_billing_state}`,
billing_postcode: `${addresses_guest_billing_postcode}`,
billing_phone: `${addresses_guest_billing_phone}`,
billing_email: `${addresses_guest_billing_email}`,
order_comments: "",
payment_method: `${payment_method}`,
"woocommerce-process-checkout-nonce": `${woocommerce_process_checkout_nonce_guest}`,
_wp_http_referer: "%2F%3Fwc-ajax%3Dupdate_order_review",
billing_first_name: `${ addresses_guest_billing_first_name }`,
billing_last_name: `${ addresses_guest_billing_last_name }`,
billing_company: `${ addresses_guest_billing_company }`,
billing_country: `${ addresses_guest_billing_country }`,
billing_address_1: `${ addresses_guest_billing_address_1 }`,
billing_address_2: `${ addresses_guest_billing_address_2 }`,
billing_city: `${ addresses_guest_billing_city }`,
billing_state: `${ addresses_guest_billing_state }`,
billing_postcode: `${ addresses_guest_billing_postcode }`,
billing_phone: `${ addresses_guest_billing_phone }`,
billing_email: `${ addresses_guest_billing_email }`,
order_comments: '',
payment_method: `${ payment_method }`,
'woocommerce-process-checkout-nonce': `${ woocommerce_process_checkout_nonce_guest }`,
_wp_http_referer: '%2F%3Fwc-ajax%3Dupdate_order_review',
},
{
headers: requestHeaders,
tags: { name: 'Shopper - wc-ajax=checkout' },
}
);
placeOrderTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: order-received": (response) =>
response.body.includes("order-received"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: order-received': ( response ) =>
response.body.includes( 'order-received' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("Order received", function () {
var requestHeaders = Object.assign({},
group( 'Order received', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/checkout/order-received/`, {
response = http.get( `${ base_url }/checkout/order-received/`, {
headers: requestHeaders,
});
check(response, {
tags: { name: 'Shopper - Order Received' },
} );
check( response, {
"body contains: 'Thank you. Your order has been received.'": (
response
) =>
response.body.includes(
"Thank you. Your order has been received."
'Thank you. Your order has been received.'
),
});
orderReceivedTrend1.add(response.timings.duration);
} );
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders
);
response = http.post(`${base_url}/?wc-ajax=get_refreshed_fragments`, {
headers: requestHeaders,
});
orderReceivedTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
response = http.post(
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
{
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,39 +1,45 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import { base_url, think_time_min, think_time_max } from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metric to add to standard results output.
let homePageTrend = new Trend("wc_get_site_root");
} from '../../headers.js';
export function homePage() {
let response;
group("Home Page", function () {
var requestHeaders = Object.assign({},
group( 'Home Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/`, {
response = http.get( `${ base_url }/`, {
headers: requestHeaders,
});
homePageTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
tags: { name: 'Shopper - Site Root' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,14 +1,22 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
customer_username,
customer_password,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
allRequestHeader,
@ -16,49 +24,46 @@ import {
commonGetRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metrics to add to standard results output.
let myAccountTrend = new Trend("wc_get_myaccount");
let myAccountLoginTrend = new Trend("wc_post_myaccount");
let myAccountLoginTrend2 = new Trend("wc_post_wc-ajax_get_refreshed_fragments");
} from '../../headers.js';
export function myAccount() {
let response;
let woocommerce_login_nonce;
group("My Account", function () {
var requestHeaders = Object.assign({},
group( 'My Account', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/my-account`, {
response = http.get( `${ base_url }/my-account`, {
headers: requestHeaders,
});
myAccountTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'My account' title": (response) =>
tags: { name: 'Shopper - My Account Login Page' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'My account' title": ( response ) =>
response.body.includes(
'<h1 class="entry-title">My account</h1>'
),
});
} );
// Correlate nonce value for use in subsequent requests.
woocommerce_login_nonce = response
.html()
.find("input[name=woocommerce-login-nonce]")
.find( 'input[name=woocommerce-login-nonce]' )
.first()
.attr("value");
});
.attr( 'value' );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
group("My Account Login", function () {
var requestHeaders = Object.assign({},
group( 'My Account Login', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -66,46 +71,48 @@ export function myAccount() {
);
response = http.post(
`${base_url}/my-account`,
`${ base_url }/my-account`,
{
username: `${customer_username}`,
password: `${customer_password}`,
"woocommerce-login-nonce": `${woocommerce_login_nonce}`,
_wp_http_referer: "/my-account",
login: "Log%20in",
username: `${ customer_username }`,
password: `${ customer_password }`,
'woocommerce-login-nonce': `${ woocommerce_login_nonce }`,
_wp_http_referer: '/my-account',
login: 'Log%20in',
},
{
headers: {
headers: requestHeaders,
},
headers: requestHeaders,
tags: { name: 'Shopper - Login to My Account' },
}
);
myAccountLoginTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: my account welcome message": (response) =>
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: my account welcome message': ( response ) =>
response.body.includes(
"From your account dashboard you can view"
'From your account dashboard you can view'
),
});
} );
var requestHeaders = Object.assign({},
const requestHeadersPost = Object.assign(
{},
allRequestHeader,
commonRequestHeaders,
commonPostRequestHeaders,
commonNonStandardHeaders
);
response = http.post(`${base_url}/?wc-ajax=get_refreshed_fragments`, {
headers: requestHeaders,
});
myAccountLoginTrend2.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
});
});
response = http.post(
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
{
headers: requestHeadersPost,
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
}
);
check( response, {
'is status 200': ( r ) => r.status === 200,
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,28 +1,34 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
product_search_term,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metric to add to standard results output.
let searchProductTrend = new Trend("wc_get_search_product");
} from '../../headers.js';
export function searchProduct() {
let response;
group("Search Product", function () {
var requestHeaders = Object.assign({},
group( 'Search Product', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
@ -30,20 +36,20 @@ export function searchProduct() {
);
response = http.get(
`${base_url}/?s=${product_search_term}&post_type=product`,
`${ base_url }/?s=${ product_search_term }&post_type=product`,
{
headers: requestHeaders,
tags: { name: 'Shopper - Search Products' },
}
);
searchProductTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: 'Search results' title": (response) =>
response.body.includes("Search results:"),
});
});
check( response, {
'is status 200': ( r ) => r.status === 200,
"body contains: 'Search results' title": ( response ) =>
response.body.includes( 'Search results:' ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,43 +1,49 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
import { base_url, think_time_min, think_time_max } from "../../config.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import { base_url, think_time_min, think_time_max } from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metric to add to standard results output.
let shopPageTrend = new Trend("wc_get_shop");
} from '../../headers.js';
export function shopPage() {
let response;
group("Shop Page", function () {
var requestHeaders = Object.assign({},
group( 'Shop Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/shop`, {
response = http.get( `${ base_url }/shop`, {
headers: requestHeaders,
});
shopPageTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: woocommerce-products-header": (response) =>
tags: { name: 'Shopper - Shop Page' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: woocommerce-products-header': ( response ) =>
response.body.includes(
'<header class="woocommerce-products-header">'
),
});
});
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -1,47 +1,53 @@
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
/* eslint-disable no-shadow */
/* eslint-disable import/no-unresolved */
/**
* External dependencies
*/
import { sleep, check, group } from 'k6';
import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
/**
* Internal dependencies
*/
import {
base_url,
product_url,
product_sku,
think_time_min,
think_time_max,
} from "../../config.js";
} from '../../config.js';
import {
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders,
} from "../../headers.js";
// Custom metric to add to standard results output.
let productPageTrend = new Trend("wc_get_product_page");
} from '../../headers.js';
export function singleProduct() {
let response;
group("Product Page", function () {
var requestHeaders = Object.assign({},
group( 'Product Page', function () {
const requestHeaders = Object.assign(
{},
htmlRequestHeader,
commonRequestHeaders,
commonGetRequestHeaders,
commonNonStandardHeaders
);
response = http.get(`${base_url}/product/${product_url}`, {
response = http.get( `${ base_url }/product/${ product_url }`, {
headers: requestHeaders,
});
productPageTrend.add(response.timings.duration);
check(response, {
"is status 200": (r) => r.status === 200,
"body contains: product SKU": (response) =>
response.body.includes(`class="sku">${product_sku}`),
});
});
tags: { name: 'Shopper - Product Page' },
} );
check( response, {
'is status 200': ( r ) => r.status === 200,
'body contains: product SKU': ( response ) =>
response.body.includes( `class="sku">${ product_sku }` ),
} );
} );
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
}
export default function () {

View File

@ -19,38 +19,17 @@ import { orders } from '../requests/merchant/orders.js';
import { ordersSearch } from '../requests/merchant/orders-search.js';
import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js';
const shopper_request_threshold = 'p(95)<10000';
const merchant_request_threshold = 'p(95)<10000';
export const options = {
scenarios: {
homePageSmoke: {
shopperBrowseSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
exec: 'homePageFlow',
},
shopPageSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '5s',
exec: 'shopPageFlow',
},
searchProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '10s',
exec: 'searchProductFlow',
},
singleProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '15s',
exec: 'singleProductFlow',
maxDuration: '180s',
exec: 'shopperBrowseFlow',
},
myAccountSmoke: {
executor: 'per-vu-iterations',
@ -94,21 +73,121 @@ export const options = {
},
thresholds: {
checks: [ 'rate==1' ],
'http_req_duration{name:Shopper - Site Root}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Shop Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Search Products}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Category Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Product Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=add_to_cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Remove Item From Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=apply_coupon}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Update Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=update_order_review}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Order Received}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=get_refreshed_fragments}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - My Account Login Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to My Account}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Merchant - WP Login Page}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Login to WP Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - WC-Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/orders?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/reviews?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/low-in-stock?}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - All Orders}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Search Orders By Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - All Products}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Add New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=sample-permalink}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=heartbeat autosave}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Update New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Coupons}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/onboarding/tasks?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/admin/notes?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - action=heartbeat}': [
`${ merchant_request_threshold }`,
],
},
};
export function homePageFlow() {
export function shopperBrowseFlow() {
homePage();
}
export function shopPageFlow() {
shopPage();
}
export function searchProductFlow() {
searchProduct();
}
export function singleProductFlow() {
singleProduct();
categoryPage();
searchProduct();
singleProduct();
}
export function checkoutGuestFlow() {
cart();

View File

@ -1,3 +1,6 @@
/**
* Internal dependencies
*/
import { homePage } from '../requests/shopper/home.js';
import { shopPage } from '../requests/shopper/shop-page.js';
import { searchProduct } from '../requests/shopper/search-product.js';
@ -6,127 +9,206 @@ import { cart } from '../requests/shopper/cart.js';
import { cartRemoveItem } from '../requests/shopper/cart-remove-item.js';
import { checkoutGuest } from '../requests/shopper/checkout-guest.js';
import { checkoutCustomerLogin } from '../requests/shopper/checkout-customer-login.js';
import { coupons } from '../requests/merchant/coupons.js';
import { myAccount } from '../requests/shopper/my-account.js';
import { categoryPage } from '../requests/shopper/category-page.js';
import { wpLogin } from '../requests/merchant/wp-login.js';
import { products } from '../requests/merchant/products.js';
import { addProduct } from '../requests/merchant/add-product.js';
import { coupons } from '../requests/merchant/coupons.js';
import { orders } from '../requests/merchant/orders.js';
import { ordersSearch } from '../requests/merchant/orders-search.js';
import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js';
export let options = {
scenarios: {
homePageSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
exec: 'homePageFlow',
},
shopPageSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '5s',
exec: 'shopPageFlow',
},
searchProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '10s',
exec: 'searchProductFlow',
},
singleProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '15s',
exec: 'singleProductFlow',
},
myAccountSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '20s',
exec: 'myAccountFlow',
},
cartSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '25s',
exec: 'cartFlow',
},
checkoutGuestSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '120s',
startTime: '30s',
exec: 'checkoutGuestFlow',
},
checkoutCustomerLoginSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '120s',
startTime: '40s',
exec: 'checkoutCustomerLoginFlow',
},
allMerchantSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '360s',
exec: 'allMerchantFlow',
},
},
const shopper_request_threshold = 'p(95)<10000';
const merchant_request_threshold = 'p(95)<10000';
export const options = {
scenarios: {
shopperBrowseSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '180s',
exec: 'shopperBrowseFlow',
},
myAccountSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '20s',
exec: 'myAccountFlow',
},
cartSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '60s',
startTime: '25s',
exec: 'cartFlow',
},
checkoutGuestSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '120s',
startTime: '30s',
exec: 'checkoutGuestFlow',
},
checkoutCustomerLoginSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '120s',
startTime: '40s',
exec: 'checkoutCustomerLoginFlow',
},
allMerchantSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 3,
maxDuration: '360s',
exec: 'allMerchantFlow',
},
},
thresholds: {
checks: [ 'rate==1' ],
'http_req_duration{name:Shopper - Site Root}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Shop Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Search Products}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Category Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Product Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=add_to_cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Remove Item From Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=apply_coupon}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Update Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=update_order_review}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Order Received}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=get_refreshed_fragments}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - My Account Login Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to My Account}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Merchant - WP Login Page}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Login to WP Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - WC-Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/orders?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/reviews?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/low-in-stock?}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - All Orders}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Search Orders By Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - All Products}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Add New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=sample-permalink}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=heartbeat autosave}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Update New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Coupons}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/onboarding/tasks?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/admin/notes?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - action=heartbeat}': [
`${ merchant_request_threshold }`,
],
},
};
export function homePageFlow() {
homePage();
}
export function shopPageFlow() {
shopPage();
}
export function searchProductFlow() {
searchProduct();
}
export function singleProductFlow() {
singleProduct();
categoryPage();
export function shopperBrowseFlow() {
homePage();
shopPage();
categoryPage();
searchProduct();
singleProduct();
}
export function checkoutGuestFlow() {
cart();
checkoutGuest();
cart();
checkoutGuest();
}
export function checkoutCustomerLoginFlow() {
cart();
checkoutCustomerLogin();
cart();
checkoutCustomerLogin();
}
export function myAccountFlow() {
myAccount();
myAccount();
}
export function cartFlow() {
cartRemoveItem();
cartRemoveItem();
}
export function allMerchantFlow() {
wpLogin();
homeWCAdmin();
orders();
ordersSearch();
products();
addProduct();
coupons();
wpLogin();
homeWCAdmin();
orders();
ordersSearch();
products();
addProduct();
coupons();
}

View File

@ -1,31 +0,0 @@
import { wpLogin } from '../requests/merchant/wp-login.js';
import { products } from '../requests/merchant/products.js';
import { addProduct } from '../requests/merchant/add-product.js';
import { coupons } from '../requests/merchant/coupons.js';
import { orders } from '../requests/merchant/orders.js';
import { ordersSearch } from '../requests/merchant/orders-search.js';
import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js';
import { myAccountMerchantLogin } from '../requests/merchant/my-account-merchant.js';
export let options = {
scenarios: {
allMerchantSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '360s',
exec: 'allMerchantFlow',
},
},
};
// Use myAccountMerchantLogin() instead of wpLogin() if having issues with login.
export function allMerchantFlow() {
wpLogin();
homeWCAdmin();
orders();
ordersSearch();
products();
addProduct();
coupons();
}

View File

@ -0,0 +1,223 @@
/**
* Internal dependencies
*/
import { homePage } from '../requests/shopper/home.js';
import { shopPage } from '../requests/shopper/shop-page.js';
import { searchProduct } from '../requests/shopper/search-product.js';
import { singleProduct } from '../requests/shopper/single-product.js';
import { cart } from '../requests/shopper/cart.js';
import { cartRemoveItem } from '../requests/shopper/cart-remove-item.js';
import { cartApplyCoupon } from '../requests/shopper/cart-apply-coupon.js';
import { checkoutGuest } from '../requests/shopper/checkout-guest.js';
import { checkoutCustomerLogin } from '../requests/shopper/checkout-customer-login.js';
import { myAccount } from '../requests/shopper/my-account.js';
import { categoryPage } from '../requests/shopper/category-page.js';
import { products } from '../requests/merchant/products.js';
import { addProduct } from '../requests/merchant/add-product.js';
import { coupons } from '../requests/merchant/coupons.js';
import { orders } from '../requests/merchant/orders.js';
import { ordersSearch } from '../requests/merchant/orders-search.js';
import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js';
import { wpLogin } from '../requests/merchant/wp-login.js';
import { myAccountMerchantLogin } from '../requests/merchant/my-account-merchant.js';
import { admin_acc_login } from '../config.js';
const shopper_request_threshold = 'p(95)<10000';
const merchant_request_threshold = 'p(95)<10000';
export const options = {
scenarios: {
shopperBrowseSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
exec: 'shopperBrowseFlow',
},
checkoutGuestSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '16s',
exec: 'checkoutGuestFlow',
},
checkoutCustomerLoginSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '32s',
exec: 'checkoutCustomerLoginFlow',
},
myAccountSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '48s',
exec: 'myAccountFlow',
},
cartSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '58s',
exec: 'cartFlow',
},
allMerchantSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '360s',
exec: 'allMerchantFlow',
},
},
thresholds: {
checks: [ 'rate==1' ],
'http_req_duration{name:Shopper - Site Root}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Shop Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Search Products}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Category Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Product Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=add_to_cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Remove Item From Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=apply_coupon}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Update Cart}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - View Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=update_order_review}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Order Received}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - wc-ajax=get_refreshed_fragments}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to Checkout}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - My Account Login Page}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Shopper - Login to My Account}': [
`${ shopper_request_threshold }`,
],
'http_req_duration{name:Merchant - WP Login Page}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Login to WP Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - WC-Admin}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/orders?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/reviews?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/products/low-in-stock?}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - All Orders}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Search Orders By Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - All Products}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Add New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=sample-permalink}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - action=heartbeat autosave}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Update New Product}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - Coupons}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/onboarding/tasks?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-analytics/admin/notes?}': [
`${ merchant_request_threshold }`,
],
'http_req_duration{name:Merchant - wc-admin/options?options=woocommerce_ces_tracks_queue}':
[ `${ merchant_request_threshold }` ],
'http_req_duration{name:Merchant - action=heartbeat}': [
`${ merchant_request_threshold }`,
],
},
};
export function shopperBrowseFlow() {
homePage();
shopPage();
categoryPage();
searchProduct();
singleProduct();
}
export function checkoutGuestFlow() {
cart();
checkoutGuest();
}
export function checkoutCustomerLoginFlow() {
cart();
checkoutCustomerLogin();
}
export function myAccountFlow() {
myAccount();
}
export function cartFlow() {
cartRemoveItem();
cartApplyCoupon();
}
export function allMerchantFlow() {
if ( admin_acc_login === true ) {
myAccountMerchantLogin();
} else {
wpLogin();
}
homeWCAdmin();
orders();
ordersSearch();
products();
addProduct();
coupons();
}

View File

@ -1,108 +0,0 @@
import { homePage } from '../requests/shopper/home.js';
import { shopPage } from '../requests/shopper/shop-page.js';
import { searchProduct } from '../requests/shopper/search-product.js';
import { singleProduct } from '../requests/shopper/single-product.js';
import { cart } from '../requests/shopper/cart.js';
import { cartRemoveItem } from '../requests/shopper/cart-remove-item.js';
import { cartApplyCoupon } from '../requests/shopper/cart-apply-coupon.js';
import { checkoutGuest } from '../requests/shopper/checkout-guest.js';
import { checkoutCustomerLogin } from '../requests/shopper/checkout-customer-login.js';
import { myAccount } from '../requests/shopper/my-account.js';
import { categoryPage } from '../requests/shopper/category-page.js';
export let options = {
scenarios: {
homePageSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '10s',
exec: 'cartFlow',
},
shopPageSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '10s',
startTime: '4s',
exec: 'shopPageFlow',
},
searchProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '10s',
startTime: '8s',
exec: 'searchProductFlow',
},
singleProductSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '10s',
startTime: '12s',
exec: 'singleProductFlow',
},
checkoutGuestSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '16s',
exec: 'checkoutGuestFlow',
},
checkoutCustomerLoginSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '32s',
exec: 'checkoutCustomerLoginFlow',
},
myAccountSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '48s',
exec: 'myAccountFlow',
},
cartSmoke: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
maxDuration: '50s',
startTime: '58s',
exec: 'cartFlow',
},
},
};
export function homePageFlow() {
homePage();
}
export function shopPageFlow() {
shopPage();
}
export function searchProductFlow() {
searchProduct();
}
export function singleProductFlow() {
singleProduct();
categoryPage();
}
export function checkoutGuestFlow() {
cart();
checkoutGuest();
}
export function checkoutCustomerLoginFlow() {
cart();
checkoutCustomerLogin();
}
export function myAccountFlow() {
myAccount();
}
export function cartFlow() {
cartRemoveItem();
cartApplyCoupon();
}