Skip to content

Commit

Permalink
feat: Separate cube iri and label
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Dec 14, 2023
1 parent a199957 commit e81a58f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
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 }}
run: k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js && k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js && k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js
run: k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=test --env CUBE_IRI=https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/ --env CUBE_LABEL=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js && k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=int --env CUBE_IRI=https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/ --env CUBE_LABEL=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js && k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata --env ENV=prod --env CUBE_IRI=https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/ --env CUBE_LABEL=StateAccounts_Office/4/ - </root/k6/performance-tests/graphql/DataCubeMetadata.js
9 changes: 7 additions & 2 deletions k6/performance-tests/generate-github-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ const fs = require("fs");

const envs = ["test", "int", "prod"];
const queries = ["DataCubeMetadata"];
const cubes = ["StateAccounts_Office/4/"];
const cubes = [
{
iri: "https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/",
label: "StateAccounts_Office/4/",
},
];

const generate = () => {
const file = `name: Performance tests
Expand All @@ -25,7 +30,7 @@ jobs:
.map((env) => {
return queries.map((query) => {
return cubes.map((cube) => {
return `k6 run -o experimental-prometheus-rw --tag testid=${query} --env ENV=${env} --env CUBE=${cube} - </root/k6/performance-tests/graphql/${query}.js`;
return `k6 run -o experimental-prometheus-rw --tag testid=${query} --env ENV=${env} --env CUBE_IRI=${cube.iri} --env CUBE_LABEL=${cube.label} - </root/k6/performance-tests/graphql/${query}.js`;
});
});
})
Expand Down
25 changes: 13 additions & 12 deletions k6/performance-tests/graphql/DataCubeMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@ const query = `query DataCubeMetadata(
)
}`;

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",
sourceUrl: `https://${env === "prod" ? "" : `${env}.`}lindas.admin.ch/query`,
cubeFilter: {
iri: "https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/",
iri: cubeIri,
},
};

const env = __ENV.ENV;
const cube = __ENV.CUBE;

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

http.post(
`https://${env === "prod" ? "" : `${env}.`}visualize.admin.ch/api/graphql`,
JSON.stringify({ query, variables }),
{
headers: {
"Content-Type": "application/json",
"x-visualize-cache-control": "no-cache",
},
}
{ headers }
);
}

0 comments on commit e81a58f

Please sign in to comment.