-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CC-34875: Dev performance Phase 2. SAPI tests.
- Loading branch information
1 parent
c8e4a0c
commit bf0cada
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import AbstractResource from './abstract.resource'; | ||
|
||
export default class CatalogSearchResource extends AbstractResource { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
get(sku) { | ||
return this.getRequest(`catalog-search?q=${sku}`); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/tests/product-search/SAPI2_product_search_by_sku_1.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { group } from 'k6'; | ||
import OptionsUtil from '../../utils/options.util'; | ||
import { createMetrics } from '../../utils/metric.util'; | ||
import { ProductFixture } from '../../fixtures/product.fixture'; | ||
import EnvironmentUtil from '../../utils/environment.util'; | ||
import CatalogSearchResource from '../../resources/catalog-search.resource'; | ||
|
||
const testConfiguration = { | ||
...EnvironmentUtil.getDefaultTestConfiguration(), | ||
id: 'SAPI2', | ||
group: 'Search Product By SKU', | ||
metrics: ['SAPI2_get_catalog_search'], | ||
minimumProductsCount: 100, | ||
thresholds: { | ||
SAPI2_get_catalog_search: { | ||
smoke: ['avg<200'], | ||
load: ['avg<400'], | ||
}, | ||
}, | ||
}; | ||
|
||
const { metrics, metricThresholds } = createMetrics(testConfiguration); | ||
export const options = OptionsUtil.loadOptions(testConfiguration, metricThresholds); | ||
|
||
export function setup() { | ||
const dynamicFixture = new ProductFixture({ | ||
productCount: testConfiguration.minimumProductsCount, | ||
}); | ||
|
||
return dynamicFixture.getData(); | ||
} | ||
|
||
export default function (data) { | ||
const product = ProductFixture.iterateData(data); | ||
|
||
group(testConfiguration.group, () => { | ||
const catalogSearchResource = new CatalogSearchResource(); | ||
const response = catalogSearchResource.get(product.sku); | ||
|
||
metrics[testConfiguration.metrics[0]].add(response.timings.duration); | ||
}); | ||
} |