Skip to content

Commit

Permalink
feat: Add DataCubePreview performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Dec 14, 2023
1 parent 533fdbc commit 96eb273
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,36 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: grafana/k6:latest
options: -v ${{ github.workspace }}:/root -e K6_PROMETHEUS_RW_USERNAME=${{ secrets.K6_PROMETHEUS_RW_USERNAME }} -e K6_PROMETHEUS_RW_PASSWORD=${{ secrets.K6_PROMETHEUS_RW_PASSWORD }} -e K6_PROMETHEUS_RW_SERVER_URL=${{ secrets.K6_PROMETHEUS_RW_SERVER_URL }}
options: |
-v ${{ github.workspace }}:/root
-e K6_PROMETHEUS_RW_USERNAME=${{ secrets.K6_PROMETHEUS_RW_USERNAME }}
-e K6_PROMETHEUS_RW_PASSWORD=${{ secrets.K6_PROMETHEUS_RW_PASSWORD }}
-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-2 --env CUBE_LABEL=NFI/2023-2 - </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-2 --env CUBE_LABEL=NFI/2023-2 - </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=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-2 --env CUBE_LABEL=NFI/2023-2 - </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=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-2 --env CUBE_LABEL=NFI/2023-2 - </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-2 --env CUBE_LABEL=NFI/2023-2 - </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=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-2 --env CUBE_LABEL=NFI/2023-2 - </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=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-2 --env CUBE_LABEL=NFI/2023-2 - </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-2 --env CUBE_LABEL=NFI/2023-2 - </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=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=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-2 --env CUBE_LABEL=NFI/2023-2 - </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
8 changes: 6 additions & 2 deletions k6/performance-tests/generate-github-action.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require("fs");

const envs = ["test", "int", "prod"];
const queries = ["DataCubeComponents", "DataCubeMetadata"];
const queries = ["DataCubeComponents", "DataCubeMetadata", "DataCubePreview"];
const cubes = [
{
iri: "https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9",
Expand Down Expand Up @@ -38,7 +38,11 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: grafana/k6:latest
options: -v \${{ github.workspace }}:/root -e K6_PROMETHEUS_RW_USERNAME=\${{ secrets.K6_PROMETHEUS_RW_USERNAME }} -e K6_PROMETHEUS_RW_PASSWORD=\${{ secrets.K6_PROMETHEUS_RW_PASSWORD }} -e K6_PROMETHEUS_RW_SERVER_URL=\${{ secrets.K6_PROMETHEUS_RW_SERVER_URL }}
options: |
-v \${{ github.workspace }}:/root
-e K6_PROMETHEUS_RW_USERNAME=\${{ secrets.K6_PROMETHEUS_RW_USERNAME }}
-e K6_PROMETHEUS_RW_PASSWORD=\${{ secrets.K6_PROMETHEUS_RW_PASSWORD }}
-e K6_PROMETHEUS_RW_SERVER_URL=\${{ secrets.K6_PROMETHEUS_RW_SERVER_URL }}
run: |
${commands}`;

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

const query = `query DataCubePreview(
$iri: String!
$sourceType: String!
$sourceUrl: String!
$locale: String!
$latest: Boolean
$disableValuesLoad: Boolean = true
) {
dataCubeByIri(
iri: $iri
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
latest: $latest
disableValuesLoad: $disableValuesLoad
) {
iri
title
description
publicationStatus
observations(
sourceType: $sourceType
sourceUrl: $sourceUrl
preview: true
limit: 10
) {
data
sparqlEditorUrl
}
}
}`;

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

const variables = {
iri: cubeIri,
sourceType: "sparql",
sourceUrl: `https://${env === "prod" ? "" : `${env}.`}lindas.admin.ch/query`,
locale: "en",
latest: false,
};

/** @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 Components() {
exec.vu.metrics.tags.env = env;
exec.vu.metrics.tags.cube = cubeLabel;

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

0 comments on commit 96eb273

Please sign in to comment.