From 39ef604787b34ca70e3aa74706dbf357374400a6 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 15 Feb 2024 15:21:18 +0100 Subject: [PATCH] test: Add threshold checks to PR performance tests --- k6/performance-tests/graphql/DataCubeComponents.js | 9 +++++++++ k6/performance-tests/graphql/DataCubeMetadata.js | 9 +++++++++ k6/performance-tests/graphql/DataCubeObservations.js | 5 +++++ k6/performance-tests/graphql/DataCubePreview.js | 9 +++++++++ k6/performance-tests/graphql/PossibleFilters.js | 5 +++++ 5 files changed, 37 insertions(+) diff --git a/k6/performance-tests/graphql/DataCubeComponents.js b/k6/performance-tests/graphql/DataCubeComponents.js index f0cbfceab2..a7ff7a69b5 100644 --- a/k6/performance-tests/graphql/DataCubeComponents.js +++ b/k6/performance-tests/graphql/DataCubeComponents.js @@ -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! @@ -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", @@ -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 = { diff --git a/k6/performance-tests/graphql/DataCubeMetadata.js b/k6/performance-tests/graphql/DataCubeMetadata.js index c75a37bf5b..ddeb17534c 100644 --- a/k6/performance-tests/graphql/DataCubeMetadata.js +++ b/k6/performance-tests/graphql/DataCubeMetadata.js @@ -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! @@ -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", @@ -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 = { diff --git a/k6/performance-tests/graphql/DataCubeObservations.js b/k6/performance-tests/graphql/DataCubeObservations.js index d57ef5ecb5..e76726568f 100644 --- a/k6/performance-tests/graphql/DataCubeObservations.js +++ b/k6/performance-tests/graphql/DataCubeObservations.js @@ -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 = { diff --git a/k6/performance-tests/graphql/DataCubePreview.js b/k6/performance-tests/graphql/DataCubePreview.js index 0352f8876a..396fefe871 100644 --- a/k6/performance-tests/graphql/DataCubePreview.js +++ b/k6/performance-tests/graphql/DataCubePreview.js @@ -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! @@ -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", @@ -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 = { diff --git a/k6/performance-tests/graphql/PossibleFilters.js b/k6/performance-tests/graphql/PossibleFilters.js index b1d36a83c7..be6e54e39e 100644 --- a/k6/performance-tests/graphql/PossibleFilters.js +++ b/k6/performance-tests/graphql/PossibleFilters.js @@ -40,6 +40,11 @@ const variables = { /** @type {import("k6/options").Options} */ export const options = { iterations: 2, + thresholds: { + http_req_duration: [ + `avg<${metadata.queries.PossibleFilters.expectedDuration}`, + ], + }, }; const headers = {