Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update k6 performance tests II #1336

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
-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 }}
-e K6_PROMETHEUS_RW_TREND_STATS=avg
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-20/cube/2023-3 --env CUBE_LABEL=NFI/2023-3 - </root/k6/performance-tests/graphql/DataCubeComponents.js &&
Expand Down
1 change: 1 addition & 0 deletions k6/performance-tests/generate-github-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
-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 }}
-e K6_PROMETHEUS_RW_TREND_STATS=avg
run: |
${commands}`;

Expand Down
26 changes: 22 additions & 4 deletions k6/performance-tests/graphql/DataCubeComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ const query = `query DataCubeComponents(
)
}`;

const metadataByCubeIri = {
"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9":
{},
"https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3": {},
"https://energy.ld.admin.ch/elcom/electricityprice": {},
};

const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const metadata = metadataByCubeIri[cubeIri];

const variables = {
locale: "en",
Expand All @@ -31,7 +39,7 @@ const variables = {

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

const headers = {
Expand All @@ -49,7 +57,17 @@ export default function Components() {
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
check(res, {
"Response must have data": (res) => {
const body = res.json();
return (
body.data &&
body.data.dataCubeComponents &&
body.data.dataCubeComponents.dimensions &&
body.data.dataCubeComponents.dimensions.length > 0 &&
body.data.dataCubeComponents.measures &&
body.data.dataCubeComponents.measures.length > 0
);
},
});
}
23 changes: 19 additions & 4 deletions k6/performance-tests/graphql/DataCubeMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ const query = `query DataCubeMetadata(
)
}`;

const metadataByCubeIri = {
"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9":
{},
"https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3": {},
"https://energy.ld.admin.ch/elcom/electricityprice": {},
};

const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const metadata = metadataByCubeIri[cubeIri];

const variables = {
locale: "en",
Expand All @@ -31,7 +39,7 @@ const variables = {

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

const headers = {
Expand All @@ -49,7 +57,14 @@ export default function Components() {
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
check(res, {
"Response must have data": (res) => {
const body = res.json();
return (
body.data &&
body.data.dataCubeMetadata &&
body.data.dataCubeMetadata.iri === cubeIri
);
},
});
}
125 changes: 73 additions & 52 deletions k6/performance-tests/graphql/DataCubeObservations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,75 @@ const query = `query DataCubeObservations(
)
}`;

const cubeFilterByCubeIri = {
const metadataByCubeIri = {
"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",
},
cubeFilter: {
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",
cubeFilter: {
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":
{
cubeFilter: {
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://ld.admin.ch/municipality/1",
value:
"https://energy.ld.admin.ch/elcom/electricityprice/product/standard",
},
"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",
},
},
},
Expand All @@ -82,17 +93,18 @@ const cubeFilterByCubeIri = {
const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const metadata = metadataByCubeIri[cubeIri];

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

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

const headers = {
Expand All @@ -110,7 +122,16 @@ export default function Observations() {
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
check(res, {
"Response must have data": (res) => {
const body = res.json();
return (
body.data &&
body.data.dataCubeObservations &&
body.data.dataCubeObservations &&
body.data.dataCubeObservations.data.length > 0 &&
body.data.dataCubeObservations.sparqlEditorUrl
);
},
});
}
28 changes: 24 additions & 4 deletions k6/performance-tests/graphql/DataCubePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ const query = `query DataCubePreview(
)
}`;

const metadataByCubeIri = {
"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9":
{},
"https://environment.ld.admin.ch/foen/nfi/nfi_C-20/cube/2023-3": {},
"https://energy.ld.admin.ch/elcom/electricityprice": {},
};

const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const metadata = metadataByCubeIri[cubeIri];

const variables = {
locale: "en",
Expand All @@ -32,7 +40,7 @@ const variables = {

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

const headers = {
Expand All @@ -50,7 +58,19 @@ export default function Components() {
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
check(res, {
"Response must have data": (res) => {
const body = res.json();
return (
body.data &&
body.data.dataCubePreview &&
body.data.dataCubePreview.dimensions &&
body.data.dataCubePreview.dimensions.length > 0 &&
body.data.dataCubePreview.measures &&
body.data.dataCubePreview.measures.length > 0 &&
body.data.dataCubePreview.observations &&
body.data.dataCubePreview.observations.length > 0
);
},
});
}
20 changes: 14 additions & 6 deletions k6/performance-tests/graphql/PossibleFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const query = `query PossibleFilters(
}
}`;

const cubeFilterByCubeIri = {
const metadataByCubeIri = {
"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",
Expand Down Expand Up @@ -86,18 +86,19 @@ const cubeFilterByCubeIri = {
const env = __ENV.ENV;
const cubeIri = __ENV.CUBE_IRI;
const cubeLabel = __ENV.CUBE_LABEL;
const metadata = metadataByCubeIri[cubeIri];

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

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

const headers = {
Expand All @@ -115,7 +116,14 @@ export default function Observations() {
{ headers }
);

if (!check(res, { "Status code must be 200": (res) => res.status == 200 })) {
fail("Status code was *not* 200!");
}
check(res, {
"Response must have data": (res) => {
const body = res.json();
return (
body.data &&
body.data.possibleFilters &&
body.data.possibleFilters.length > 0
);
},
});
}
Loading