Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OA start tests. #37

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,52 @@ options.scenarios = {
options.thresholds[`http_req_duration{name:${thresholdTag}}`] = ['avg<300'];

export function setup() {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(vus, iterations, 50);
if (isSequentialSetup()) {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(iterations, 1, 50);
}

if (isConcurrentSetup()) {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(vus, iterations, 50);
}

throw new Error('Invalid setup configuration');
}

export function teardown() {
sharedCheckoutScenario.dynamicFixturesHelper.haveConsoleCommands(['console queue:worker:start --stop-when-empty']);
}

export function execute(data) {
const customerIndex = (__VU - 1) % data.length;
const { customerEmail, quoteIds } = data[customerIndex];
const quoteIndex = __ITER % quoteIds.length;
const { customerEmail, quoteIds } = getCustomerData(data);
const quoteIndex = getQuoteIndex(quoteIds);

// Place an order
const checkoutResponseJson = sharedCheckoutScenario.haveOrder(customerEmail, quoteIds[quoteIndex], false);

// Edit an order
sharedOrderAmendmentScenario.execute(customerEmail, checkoutResponseJson.data.attributes.orderReference, thresholdTag);
}

function getCustomerData(data) {
let customerIndex;

if (isSequentialSetup()) {
customerIndex = __ITER % data.length;
} else if (isConcurrentSetup()) {
customerIndex = (__VU - 1) % data.length;
}

return data[customerIndex];
}

function getQuoteIndex(quoteIds) {
return isSequentialSetup() ? 0 : __ITER % quoteIds.length;
}

function isConcurrentSetup() {
return vus > 1 && iterations === 1;
}

function isSequentialSetup() {
return vus === 1 && iterations > 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,52 @@ options.scenarios = {
options.thresholds[`http_req_duration{name:${thresholdTag}}`] = ['avg<300'];

export function setup() {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(vus, iterations, 70);
if (isSequentialSetup()) {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(iterations, 1, 70);
}

if (isConcurrentSetup()) {
return sharedCheckoutScenario.dynamicFixturesHelper.haveCustomersWithQuotes(vus, iterations, 70);
}

throw new Error('Invalid setup configuration');
}

export function teardown() {
sharedCheckoutScenario.dynamicFixturesHelper.haveConsoleCommands(['console queue:worker:start --stop-when-empty']);
}

export function execute(data) {
const customerIndex = (__VU - 1) % data.length;
const { customerEmail, quoteIds } = data[customerIndex];
const quoteIndex = __ITER % quoteIds.length;
const { customerEmail, quoteIds } = getCustomerData(data);
const quoteIndex = getQuoteIndex(quoteIds);

// Place an order
const checkoutResponseJson = sharedCheckoutScenario.haveOrder(customerEmail, quoteIds[quoteIndex], false);

// Edit an order
sharedOrderAmendmentScenario.execute(customerEmail, checkoutResponseJson.data.attributes.orderReference, thresholdTag);
}

function getCustomerData(data) {
let customerIndex;

if (isSequentialSetup()) {
customerIndex = __ITER % data.length;
} else if (isConcurrentSetup()) {
customerIndex = (__VU - 1) % data.length;
}

return data[customerIndex];
}

function getQuoteIndex(quoteIds) {
return isSequentialSetup() ? 0 : __ITER % quoteIds.length;
}

function isConcurrentSetup() {
return vus > 1 && iterations === 1;
}

function isSequentialSetup() {
return vus === 1 && iterations > 1;
}
Loading