2021-06-24 23:42:28 +00:00
|
|
|
import { sleep, check, group } from "k6";
|
|
|
|
import http from "k6/http";
|
2021-07-13 14:54:23 +00:00
|
|
|
import { Trend } from "k6/metrics";
|
2021-06-24 23:42:28 +00:00
|
|
|
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js";
|
2021-07-13 14:54:23 +00:00
|
|
|
import { base_url, think_time_min, think_time_max } from "../../config.js";
|
2021-06-24 23:42:28 +00:00
|
|
|
import {
|
2021-07-13 14:54:23 +00:00
|
|
|
htmlRequestHeader,
|
|
|
|
commonRequestHeaders,
|
|
|
|
commonGetRequestHeaders,
|
|
|
|
commonNonStandardHeaders,
|
|
|
|
} from "../../headers.js";
|
2021-06-24 23:42:28 +00:00
|
|
|
|
2021-07-13 14:54:23 +00:00
|
|
|
// Custom metric to add to standard results output.
|
|
|
|
let shopPageTrend = new Trend("wc_get_shop");
|
2021-06-24 23:42:28 +00:00
|
|
|
|
2021-07-13 14:54:23 +00:00
|
|
|
export function shopPage() {
|
|
|
|
let response;
|
2021-06-24 23:42:28 +00:00
|
|
|
|
2021-07-13 14:54:23 +00:00
|
|
|
group("Shop Page", function () {
|
2021-07-30 19:38:31 +00:00
|
|
|
var requestHeaders = Object.assign({},
|
2021-07-13 14:54:23 +00:00
|
|
|
htmlRequestHeader,
|
|
|
|
commonRequestHeaders,
|
|
|
|
commonGetRequestHeaders,
|
|
|
|
commonNonStandardHeaders
|
|
|
|
);
|
2021-06-24 23:42:28 +00:00
|
|
|
|
2021-07-13 14:54:23 +00:00
|
|
|
response = http.get(`${base_url}/shop`, {
|
|
|
|
headers: requestHeaders,
|
|
|
|
});
|
|
|
|
shopPageTrend.add(response.timings.duration);
|
|
|
|
check(response, {
|
|
|
|
"is status 200": (r) => r.status === 200,
|
2021-07-30 19:38:31 +00:00
|
|
|
"body contains: woocommerce-products-header": (response) =>
|
2021-07-13 14:54:23 +00:00
|
|
|
response.body.includes(
|
|
|
|
'<header class="woocommerce-products-header">'
|
|
|
|
),
|
|
|
|
});
|
|
|
|
});
|
2021-06-24 23:42:28 +00:00
|
|
|
|
2021-07-13 14:54:23 +00:00
|
|
|
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
|
2021-06-24 23:42:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function () {
|
2021-07-13 14:54:23 +00:00
|
|
|
shopPage();
|
2021-06-24 23:42:28 +00:00
|
|
|
}
|