Skip to content

Commit

Permalink
Merge pull request #37 from spryker/fixed-start-oa
Browse files Browse the repository at this point in the history
Fixed OA start tests.
  • Loading branch information
dmiseev authored Jan 22, 2025
2 parents 207d19c + e532108 commit 1623ad4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 8 deletions.
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;
}

0 comments on commit 1623ad4

Please sign in to comment.