Skip to content

Commit

Permalink
feat: Add new cube to performance tests & optimize script
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Dec 14, 2023
1 parent e81a58f commit 7ce597d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Performance tests
name: GraphQL performance tests

on: workflow_dispatch

jobs:
compile:
name: Compile site assets
run_tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
- name: Check out
uses: actions/checkout@v2
- name: Run the build process with Docker
- name: Run k6 and upload results to Prometheus
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 }}
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
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=test --env CUBE_IRI=https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-2 --env CUBE_LABEL=nfi_C-96/cube/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://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://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-2 --env CUBE_LABEL=nfi_C-96/cube/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://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://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-2 --env CUBE_LABEL=nfi_C-96/cube/2023-2 - </root/k6/performance-tests/graphql/DataCubeMetadata.js
33 changes: 19 additions & 14 deletions k6/performance-tests/generate-github-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,41 @@ const cubes = [
iri: "https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/",
label: "StateAccounts_Office/4/",
},
{
iri: "https://environment.ld.admin.ch/foen/nfi/nfi_C-96/cube/2023-2",
label: "nfi_C-96/cube/2023-2",
},
];
const commands = envs
.flatMap((e) =>
queries.flatMap((q) => cubes.map((c) => getRunCommand(e, q, c)))
)
.join(" && ");

const generate = () => {
const file = `name: Performance tests
const file = `name: GraphQL performance tests
on: workflow_dispatch
jobs:
compile:
name: Compile site assets
run_tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
- name: Check out
uses: actions/checkout@v2
- name: Run the build process with Docker
- name: Run k6 and upload results to Prometheus
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 }}
run: ${envs
.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_IRI=${cube.iri} --env CUBE_LABEL=${cube.label} - </root/k6/performance-tests/graphql/${query}.js`;
});
});
})
.join(" && ")}`;
run: ${commands}`;

fs.writeFileSync("./.github/workflows/performance-tests.yml", file);
};

generate();

function getRunCommand(env, query, cube) {
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`;
}

0 comments on commit 7ce597d

Please sign in to comment.