Dreaming of using Grafana Cloud for all your testing needs? This repository will help you get started.
Note: The demo app used for all examples is QuickPizza.
What you'll find here:
src/
backend/
– k6 tests for backend APIsweb_app/
– k6 tests for frontend_lib/http_client.ts
– client autogenerated using openapi-to-k6_studio/
– k6 studio artifactsdata/
– reusable datasets (e.g. users.json)generators/
– test generatorsrecordings/
– recordings of different user flows (HTTP)
specs/
quickpizza.openapi.yaml
– OpenAPI spec for QuickPizza
terraform/
gck6.projects.tf
– GCk6 projects, limits, and quotasgck6.permissions.tf
– GCk6 RBAC config (incl. giving access to all projects to a specific team)gck6.scheduled_tests.tf
– GCk6 scheduled testssm.checks.tf
– Synthetic Monitoring checks (incl. a multi-file scripted check)stack.teams.tf
– Grafana Cloud stack teams and roles
k8s/
plz.definition.yaml
– GCk6 PLZ test definitionplz.quota.yaml
– GCk6 PLZ quota config
.github/workflows/
ci.yaml
– runs on every push to main- spins up a local QuickPizza container
- runs backend tests locally with run-k6-action
- annotates test runs with branch/PR metadata
release.yaml
– runs on new GitHub Releases- runs backend tests in GCk6 with run-k6-action (targeting a public QuickPizza deployment)
- annotates runs with release metadata
- sets the runs as baselines in GCk6
extensions/
Dockerfile
– Dockerfile to build a custom image with k6 extensionsxk6-judge/
– custom k6 extension
Make sure you have the following prerequisites installed:
- Node (>= 22.x)
- Terraform (>= 1.3.0)
- A Grafana Cloud account with an existing stack
After cloning the repository create a .env file based on the .env.example file.
cp .env.example .env
Then, edit the .env file and add a Grafana Cloud API Key and the details of your stack.
STACK_SLUG=mystack
CLOUD_REGION=prod-eu-west-2
CLOUD_ACCESS_POLICY_TOKEN=abdc123
That's it! Now run the following command to create the resources in your Grafana Cloud Stack.
make tf-bootstrap
Once you are done, you can check your Grafana Cloud stack to see the new resources.
If you want to clean up and remove all the resources created, just run:
make tf-destroy
Where to find the Stack Slug and Cloud Region?
- Log in to your Grafana Cloud account.
- Select your organization from the organization drop-down menu.
- In the Stacks section, click Details next to the stack you want to use.
- Copy the Slug and the Region.
How do I create a Grafana Cloud API key?
With a Grafana Cloud Access Policy. Make sure that you configure the minimun required scopes:
- stacks:read
- stacks:write
- subscriptions:read
- orgs:read
- stack-service-accounts:write
Just run:
make gen-openapi-client
You can sync them between your local Studio installation and this repository using:
# Copy artifacts from the repo to your local Studio install
make studio-update-local
# Copy artifacts from your local Studio install to the repo
make studio-update-repo
Only generators, recordings and data files will be synced.
The commands are non-destructive, meaning they will only add or update files, never delete them.