Skip to content

Commit

Permalink
test: Add threshold checks to PR performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Feb 15, 2024
1 parent 30fc211 commit 51d0bb6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions k6/performance-tests/graphql/DataCubeComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { check } from "k6";
import exec from "k6/execution";
import http from "k6/http";

const rootPath = __ENV.ROOT_PATH || "../../../";
const cubes = require(`${rootPath}k6/performance-tests/data.js`);

const query = `query DataCubeComponents(
$sourceType: String!
$sourceUrl: String!
Expand All @@ -20,6 +23,7 @@ const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const endpoint = __ENV.ENDPOINT;
const metadata = cubes.find((cube) => cube.iri === cubeIri);

const variables = {
locale: "en",
Expand All @@ -33,6 +37,11 @@ const variables = {
/** @type {import("k6/options").Options} */
export const options = {
iterations: 2,
thresholds: {
http_req_duration: [
`avg<${2 * metadata.queries.DataCubeComponents.expectedDuration}`,
],
},
};

const headers = {
Expand Down
9 changes: 9 additions & 0 deletions k6/performance-tests/graphql/DataCubeMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { check } from "k6";
import exec from "k6/execution";
import http from "k6/http";

const rootPath = __ENV.ROOT_PATH || "../../../";
const cubes = require(`${rootPath}k6/performance-tests/data.js`);

const query = `query DataCubeMetadata(
$sourceType: String!
$sourceUrl: String!
Expand All @@ -20,6 +23,7 @@ const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const endpoint = __ENV.ENDPOINT;
const metadata = cubes.find((cube) => cube.iri === cubeIri);

const variables = {
locale: "en",
Expand All @@ -33,6 +37,11 @@ const variables = {
/** @type {import("k6/options").Options} */
export const options = {
iterations: 2,
thresholds: {
http_req_duration: [
`avg<${2 * metadata.queries.DataCubeMetadata.expectedDuration}`,
],
},
};

const headers = {
Expand Down
5 changes: 5 additions & 0 deletions k6/performance-tests/graphql/DataCubeObservations.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const variables = {
/** @type {import("k6/options").Options} */
export const options = {
iterations: 2,
thresholds: {
http_req_duration: [
`avg<${2 * metadata.queries.DataCubeObservations.expectedDuration}`,
],
},
};

const headers = {
Expand Down
9 changes: 9 additions & 0 deletions k6/performance-tests/graphql/DataCubePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { check } from "k6";
import exec from "k6/execution";
import http from "k6/http";

const rootPath = __ENV.ROOT_PATH || "../../../";
const cubes = require(`${rootPath}k6/performance-tests/data.js`);

const query = `query DataCubePreview(
$sourceType: String!
$sourceUrl: String!
Expand All @@ -20,6 +23,7 @@ const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const endpoint = __ENV.ENDPOINT;
const metadata = cubes.find((cube) => cube.iri === cubeIri);

const variables = {
locale: "en",
Expand All @@ -34,6 +38,11 @@ const variables = {
/** @type {import("k6/options").Options} */
export const options = {
iterations: 2,
thresholds: {
http_req_duration: [
`avg<${2 * metadata.queries.DataCubePreview.expectedDuration}`,
],
},
};

const headers = {
Expand Down
5 changes: 5 additions & 0 deletions k6/performance-tests/graphql/PossibleFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const variables = {
/** @type {import("k6/options").Options} */
export const options = {
iterations: 2,
thresholds: {
http_req_duration: [
`avg<${2 * metadata.queries.PossibleFilters.expectedDuration}`,
],
},
};

const headers = {
Expand Down

0 comments on commit 51d0bb6

Please sign in to comment.