Skip to content

Commit

Permalink
Merge pull request #1335 from visualize-admin/chore/update-k6-perform…
Browse files Browse the repository at this point in the history
…ance-tests

chore: Update k6 performance tests
  • Loading branch information
bprusinowski authored Feb 14, 2024
2 parents 665eb8e + 683262e commit f55381c
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 38 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,47 @@ jobs:
-e K6_PROMETHEUS_RW_SERVER_URL=${{ secrets.K6_PROMETHEUS_RW_SERVER_URL }}
run: |
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=test --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=int --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=int --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeMetadata.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubeObservations --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubeObservations.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubePreview.js
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=DataCubePreview --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/DataCubePreview.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=prod --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/PossibleFilters.js &&
k6 run -o experimental-prometheus-rw --tag testid=PossibleFilters --env ENV=prod --env CUBE_IRI=https://energy.ld.admin.ch/elcom/electricityprice --env CUBE_LABEL=Elcom - </root/k6/performance-tests/graphql/PossibleFilters.js
14 changes: 11 additions & 3 deletions k6/performance-tests/generate-github-action.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const fs = require("fs");

const envs = ["test", "int", "prod"];
const queries = ["DataCubeComponents", "DataCubeMetadata", "DataCubePreview"];
const queries = [
"DataCubeComponents",
"DataCubeMetadata",
"DataCubeObservations",
"DataCubePreview",
"PossibleFilters",
];
const cubes = [
{
iri: "https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9",
Expand All @@ -17,8 +23,10 @@ const cubes = [
},
];
const commands = envs
.flatMap((e) =>
queries.flatMap((q) => cubes.map((c) => getRunCommand(e, q, c)))
.flatMap((env) =>
queries.flatMap((query) =>
cubes.map((cube) => getRunCommand(env, query, cube))
)
)
.join(" &&\n ");

Expand Down
116 changes: 116 additions & 0 deletions k6/performance-tests/graphql/DataCubeObservations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { check, fail } from "k6";
import exec from "k6/execution";
import http from "k6/http";

const query = `query DataCubeObservations(
$sourceType: String!
$sourceUrl: String!
$locale: String!
$cubeFilter: DataCubeObservationFilter!
) {
dataCubeObservations(
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
cubeFilter: $cubeFilter
)
}`;

const cubeFilterByCubeIri = {
"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9":
{
iri: "https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9",
filters: {
"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Kanton":
{
type: "single",
value: "https://ld.admin.ch/canton/1",
},
},
},
"https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3": {
iri: "https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3",
filters: {
"https://environment.ld.admin.ch/foen/nfi/unitOfReference": {
type: "single",
value: "https://ld.admin.ch/country/CHE",
},
"https://environment.ld.admin.ch/foen/nfi/classificationUnit": {
type: "single",
value:
"https://environment.ld.admin.ch/foen/nfi/ClassificationUnit/Total",
},
"https://environment.ld.admin.ch/foen/nfi/inventory": {
type: "single",
value: "https://environment.ld.admin.ch/foen/nfi/Inventory/150",
},
"https://environment.ld.admin.ch/foen/nfi/unitOfEvaluation": {
type: "single",
value: "https://environment.ld.admin.ch/foen/nfi/UnitOfEvaluation/2382",
},
"https://environment.ld.admin.ch/foen/nfi/evaluationType": {
type: "single",
value: "https://environment.ld.admin.ch/foen/nfi/EvaluationType/1",
},
},
},
"https://energy.ld.admin.ch/elcom/electricityprice": {
iri: "https://energy.ld.admin.ch/elcom/electricityprice",
filters: {
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/municipality":
{
type: "single",
value: "https://ld.admin.ch/municipality/1",
},
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/category": {
type: "single",
value: "https://energy.ld.admin.ch/elcom/electricityprice/category/C1",
},
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/operator": {
type: "single",
value: "https://energy.ld.admin.ch/elcom/electricityprice/operator/486",
},
"https://energy.ld.admin.ch/elcom/electricityprice/dimension/product": {
type: "single",
value:
"https://energy.ld.admin.ch/elcom/electricityprice/product/standard",
},
},
},
};

const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;

const variables = {
locale: "en",
sourceType: "sparql",
sourceUrl: "https://lindas.admin.ch/query",
cubeFilter: cubeFilterByCubeIri[cubeIri],
};

/** @type {import("k6/options").Options} */
export const options = {
iterations: 1,
};

const headers = {
"Content-Type": "application/json",
"x-visualize-cache-control": "no-cache",
};

export default function Observations() {
exec.vu.metrics.tags.env = env;
exec.vu.metrics.tags.cube = cubeLabel;

const res = http.post(
`https://${env === "prod" ? "" : `${env}.`}visualize.admin.ch/api/graphql`,
JSON.stringify({ query, variables }),
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
}
Loading

0 comments on commit f55381c

Please sign in to comment.