Skip to content

Commit

Permalink
ENV adjustments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiseev committed Feb 28, 2025
1 parent 017de2c commit c8e4a0c
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 56 deletions.
5 changes: 2 additions & 3 deletions .env.example.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
K6_HOSTENV=local
K6_NO_THRESHOLDS=true

ENV_REPOSITORY_ID=suite
ENV_REPOSITORY_TYPE=smoke
SPRYKER_REPOSITORY_ID=suite
SPRYKER_TEST_TYPE=smoke
13 changes: 9 additions & 4 deletions .env.example.staging
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
K6_HOSTENV=local
K6_HOSTENV=staging
K6_NO_THRESHOLDS=true

ENV_REPOSITORY_ID=suite
ENV_REPOSITORY_TYPE=smoke
SPRYKER_REPOSITORY_ID=suite
SPRYKER_TEST_TYPE=smoke
SPRYKER_STOREFRONT_URL=https://yves.eu.spryker-suiteperformance.cloud.spryker.toys
SPRYKER_MERCHANT_PORTAL_URL=https://mp.eu.spryker-suiteperformance.cloud.spryker.toys
SPRYKER_STOREFRONT_API_URL=https://glue.eu.spryker-suiteperformance.cloud.spryker.toys
SPRYKER_BACKEND_API_URL=https://glue-backend.eu.spryker-suiteperformance.cloud.spryker.toys
SPRYKER_BACKOFFICE_URL=https://backoffice.eu.spryker-suiteperformance.cloud.spryker.toys
SPRYKER_BACKOFFICE_API_URL=https://backend-api.eu.spryker-suiteperformance.cloud.spryker.toys
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ This project contains performance tests for the Spryker Commerce applications us

## Prerequisites

- Node.js
- npm
- Docker
- Docker Compose
- Node.js & NPM
- Docker & Docker Compose

## Setup

Expand Down Expand Up @@ -118,8 +116,8 @@ This project contains performance tests for the Spryker Commerce applications us

- `K6_HOSTENV`: Environment for K6 (default: `local`)
- `K6_NO_THRESHOLDS`: Disable thresholds (default: `true`)
- `ENV_REPOSITORY_ID`: Repository ID (default: `suite`)
- `ENV_REPOSITORY_TYPE`: Repository type (default: `smoke`)
- `SPRYKER_REPOSITORY_ID`: Repository ID (default: `suite`)
- `SPRYKER_TEST_TYPE`: Test type (default: `smoke`)

### Docker Compose Files

Expand Down
14 changes: 10 additions & 4 deletions docker-compose.b2b-mp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ services:
- K6_OUT=influxdb=http://influxdb:8086/k6
- K6_STATSD_ADDR=nrstatsd:8125
- K6_STATSD_NAMESPACE=spryker_k6_
- K6_HOSTENV=${K6_HOSTENV}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS}
- ENV_REPOSITORY_ID=${ENV_REPOSITORY_ID}
- ENV_REPOSITORY_TYPE=${ENV_REPOSITORY_TYPE}
- K6_HOSTENV=${K6_HOSTENV:-local}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS:-true}
- SPRYKER_REPOSITORY_ID=${SPRYKER_REPOSITORY_ID:-suite}
- SPRYKER_TEST_TYPE=${SPRYKER_TEST_TYPE:-smoke}
- SPRYKER_STOREFRONT_URL=${SPRYKER_STOREFRONT_URL:-}
- SPRYKER_MERCHANT_PORTAL_URL=${SPRYKER_MERCHANT_PORTAL_URL:-}
- SPRYKER_STOREFRONT_API_URL=${SPRYKER_STOREFRONT_API_URL:-}
- SPRYKER_BACKEND_API_URL=${SPRYKER_BACKEND_API_URL:-}
- SPRYKER_BACKOFFICE_URL=${SPRYKER_BACKOFFICE_URL:-}
- SPRYKER_BACKOFFICE_API_URL=${SPRYKER_BACKOFFICE_API_URL:-}
networks:
- k6
- spryker_b2b_marketplace_dev_private
Expand Down
14 changes: 10 additions & 4 deletions docker-compose.b2b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ services:
- K6_OUT=influxdb=http://influxdb:8086/k6
- K6_STATSD_ADDR=nrstatsd:8125
- K6_STATSD_NAMESPACE=spryker_k6_
- K6_HOSTENV=${K6_HOSTENV}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS}
- ENV_REPOSITORY_ID=${ENV_REPOSITORY_ID}
- ENV_REPOSITORY_TYPE=${ENV_REPOSITORY_TYPE}
- K6_HOSTENV=${K6_HOSTENV:-local}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS:-true}
- SPRYKER_REPOSITORY_ID=${SPRYKER_REPOSITORY_ID:-suite}
- SPRYKER_TEST_TYPE=${SPRYKER_TEST_TYPE:-smoke}
- SPRYKER_STOREFRONT_URL=${SPRYKER_STOREFRONT_URL:-}
- SPRYKER_MERCHANT_PORTAL_URL=${SPRYKER_MERCHANT_PORTAL_URL:-}
- SPRYKER_STOREFRONT_API_URL=${SPRYKER_STOREFRONT_API_URL:-}
- SPRYKER_BACKEND_API_URL=${SPRYKER_BACKEND_API_URL:-}
- SPRYKER_BACKOFFICE_URL=${SPRYKER_BACKOFFICE_URL:-}
- SPRYKER_BACKOFFICE_API_URL=${SPRYKER_BACKOFFICE_API_URL:-}
networks:
- k6
- spryker_b2b_dev_private
Expand Down
14 changes: 10 additions & 4 deletions docker-compose.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ services:
- K6_OUT=influxdb=http://influxdb:8086/k6
- K6_STATSD_ADDR=nrstatsd:8125
- K6_STATSD_NAMESPACE=spryker_k6_
- K6_HOSTENV=${K6_HOSTENV}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS}
- ENV_REPOSITORY_ID=${ENV_REPOSITORY_ID}
- ENV_REPOSITORY_TYPE=${ENV_REPOSITORY_TYPE}
- K6_HOSTENV=${K6_HOSTENV:-local}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS:-true}
- SPRYKER_REPOSITORY_ID=${SPRYKER_REPOSITORY_ID:-suite}
- SPRYKER_TEST_TYPE=${SPRYKER_TEST_TYPE:-smoke}
- SPRYKER_STOREFRONT_URL=${SPRYKER_STOREFRONT_URL:-}
- SPRYKER_MERCHANT_PORTAL_URL=${SPRYKER_MERCHANT_PORTAL_URL:-}
- SPRYKER_STOREFRONT_API_URL=${SPRYKER_STOREFRONT_API_URL:-}
- SPRYKER_BACKEND_API_URL=${SPRYKER_BACKEND_API_URL:-}
- SPRYKER_BACKOFFICE_URL=${SPRYKER_BACKOFFICE_URL:-}
- SPRYKER_BACKOFFICE_API_URL=${SPRYKER_BACKOFFICE_API_URL:-}
networks:
- k6
- spryker_private
Expand Down
32 changes: 17 additions & 15 deletions src/fixtures/checkout.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export class CheckoutFixture extends AbstractFixture {
}

_getCustomersWithQuotesPayload() {
const baseOperations = [
let companyPermissions = [];
let baseOperations = [
{
type: 'transfer',
name: 'LocaleTransfer',
Expand Down Expand Up @@ -83,7 +84,7 @@ export class CheckoutFixture extends AbstractFixture {
];

if (this.repositoryId === 'b2b-mp' || this.repositoryId === 'b2b') {
const companyPermissions = [
companyPermissions = [
{
type: 'helper',
name: 'haveCompany',
Expand Down Expand Up @@ -141,10 +142,9 @@ export class CheckoutFixture extends AbstractFixture {
],
},
];

baseOperations.push(...companyPermissions);
}

baseOperations.push(...companyPermissions);
const products = Array.from({ length: this.itemCount }, (_, i) => this._createProductPayload(i)).flat();
const customers = Array.from({ length: this.customerCount }, (_, i) => this._createCustomerPayload(i)).flat();

Expand All @@ -161,6 +161,7 @@ export class CheckoutFixture extends AbstractFixture {

_createProductPayload(index) {
const productKey = `product${index + 1}`;
let productOffer = [];
let product = [
{
type: 'helper',
Expand Down Expand Up @@ -207,7 +208,7 @@ export class CheckoutFixture extends AbstractFixture {

if (this.repositoryId === 'b2b-mp') {
const productOfferKey = `productOffer${index + 1}`;
const productOffer = [
productOffer = [
{
type: 'helper',
name: 'haveProductOffer',
Expand Down Expand Up @@ -236,16 +237,18 @@ export class CheckoutFixture extends AbstractFixture {
],
},
];

product.push(...productOffer);
}

product.push(...productOffer);

return product;
}

_createCustomerPayload(index) {
const customerKey = `customer${index + 1}`;
const quotes = Array.from({ length: this.cartCount }, (_, quoteIndex) => ({
let emptyQuotes = [];
let companyUser = [];
let quotes = Array.from({ length: this.cartCount }, (_, quoteIndex) => ({
type: 'helper',
name: 'havePersistentQuote',
key: `${customerKey}Quote${quoteIndex + 1}`,
Expand All @@ -258,7 +261,7 @@ export class CheckoutFixture extends AbstractFixture {
}));

if (this.emptyCartCount) {
const emptyQuotes = Array.from({ length: this.emptyCartCount }, (_, emptyQuoteIndex) => ({
emptyQuotes = Array.from({ length: this.emptyCartCount }, (_, emptyQuoteIndex) => ({
type: 'helper',
name: 'havePersistentQuote',
key: `${customerKey}EmptyQuote${emptyQuoteIndex + 1}`,
Expand All @@ -269,10 +272,10 @@ export class CheckoutFixture extends AbstractFixture {
},
],
}));

quotes.push(...emptyQuotes);
}

quotes.push(...emptyQuotes);

const customer = [
{
type: 'helper',
Expand All @@ -289,7 +292,7 @@ export class CheckoutFixture extends AbstractFixture {
];

if (this.repositoryId === 'b2b-mp' || this.repositoryId === 'b2b') {
const companyUser = [
companyUser = [
{
type: 'helper',
name: 'haveCompanyUser',
Expand All @@ -304,11 +307,10 @@ export class CheckoutFixture extends AbstractFixture {
],
},
];

customer.push(...companyUser);
}

customer.push(...quotes);
customer.push(...companyUser);
customer.push(...(quotes || []));

return customer;
}
Expand Down
7 changes: 4 additions & 3 deletions src/fixtures/product.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class ProductFixture extends AbstractFixture {

_createProductPayload(index) {
const productKey = `product${index + 1}`;
let productOffer = [];
let product = [
{
type: 'helper',
Expand Down Expand Up @@ -130,7 +131,7 @@ export class ProductFixture extends AbstractFixture {

if (this.repositoryId === 'b2b-mp') {
const productOfferKey = `productOffer${index + 1}`;
const productOffer = [
productOffer = [
{
type: 'helper',
name: 'haveProductOffer',
Expand Down Expand Up @@ -159,10 +160,10 @@ export class ProductFixture extends AbstractFixture {
],
},
];

product.push(...productOffer);
}

product.push(...productOffer);

return product;
}
}
22 changes: 11 additions & 11 deletions src/utils/environment.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class EnvironmentUtil {
case 'local':
return 'http://yves.eu.spryker.local';
case 'staging':
return 'https://yves.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_STOREFRONT_URL;
default:
console.error('Url or env not defined');
}
Expand All @@ -15,7 +15,7 @@ export default class EnvironmentUtil {
case 'local':
return 'http://mp.eu.spryker.local';
case 'staging':
return 'https://mp.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_MERCHANT_PORTAL_URL;
default:
console.error('Url or env not defined');
}
Expand All @@ -26,7 +26,7 @@ export default class EnvironmentUtil {
case 'local':
return 'http://glue.eu.spryker.local';
case 'staging':
return 'https://glue.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_STOREFRONT_API_URL;
default:
console.error('Url or env not defined');
}
Expand All @@ -37,7 +37,7 @@ export default class EnvironmentUtil {
case 'local':
return 'http://glue-backend.eu.spryker.local';
case 'staging':
return 'https://glue-backend.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_BACKEND_API_URL;
default:
console.error('Url or env not defined');
}
Expand All @@ -48,7 +48,7 @@ export default class EnvironmentUtil {
case 'local':
return 'http://backoffice.eu.spryker.local';
case 'staging':
return 'https://backoffice.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_BACKOFFICE_URL;
default:
console.error('Url or env not defined');
}
Expand All @@ -59,14 +59,14 @@ export default class EnvironmentUtil {
case 'local':
return 'http://backend-api.eu.spryker.local';
case 'staging':
return 'https://backend-api.eu.spryker-suiteperformance.cloud.spryker.toys';
return __ENV.SPRYKER_BACKOFFICE_API_URL;
default:
console.error('Url or env not defined');
}
}

static getVus() {
switch (this.getRepositoryType()) {
switch (this.getTestType()) {
case 'smoke':
return 1;
case 'load':
Expand All @@ -77,7 +77,7 @@ export default class EnvironmentUtil {
}

static getIterations() {
switch (this.getRepositoryType()) {
switch (this.getTestType()) {
case 'smoke':
return 10;
case 'load':
Expand All @@ -87,8 +87,8 @@ export default class EnvironmentUtil {
}
}

static getRepositoryType() {
return __ENV.ENV_REPOSITORY_TYPE;
static getTestType() {
return __ENV.SPRYKER_TEST_TYPE;
}

static getExecutor() {
Expand All @@ -105,6 +105,6 @@ export default class EnvironmentUtil {
}

static getRepositoryId() {
return __ENV.ENV_REPOSITORY_ID;
return __ENV.SPRYKER_REPOSITORY_ID;
}
}
2 changes: 1 addition & 1 deletion src/utils/metric.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function createMetrics(testConfiguration) {
testConfiguration.metrics.forEach((metricName) => {
metrics[metricName] = new Trend(metricName);
const thresholds = testConfiguration.thresholds[metricName];
metricThresholds[metricName] = thresholds[EnvironmentUtil.getRepositoryType()] || thresholds.smoke;
metricThresholds[metricName] = thresholds[EnvironmentUtil.getTestType()] || thresholds.smoke;
});

return { metrics, metricThresholds };
Expand Down
2 changes: 1 addition & 1 deletion src/utils/payment.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class PaymentUtil {
}

static getPaymentProviderName() {
switch (__ENV.ENV_REPOSITORY_ID) {
switch (__ENV.SPRYKER_REPOSITORY_ID) {
case 'suite':
return 'DummyPayment';
case 'b2b':
Expand Down

0 comments on commit c8e4a0c

Please sign in to comment.