CI/CD Test Automation: Environment-specific Testing and k6 Monitoring
[Appendix] Integrating test automation
Section titled “[Appendix] Integrating test automation”This section covers Grafana k6-based Module/Smoke Test setup and monitoring integration, along with Test Result Reporting and Dashboard construction.
Test setup by environment
Section titled “Test setup by environment”Local Environment: The test script is developed and run on a local PC, and its logs are inspected there. Test results are exported as Prometheus metrics and pushed to a self-managed metrics store.

CI/CD Integration: The test script is managed in a Git repository and run by the pipeline before CI/CD executes. Test logs are viewed through the CI/CD tool, and results are stored as metrics.

Scheduled Test (Kubernetes CronJob): The test script and configuration are deployed to the k8s cluster as a k6 TestRun resource, and run periodically via a Kubernetes CronJob. The Pod created by the CronJob runs the test script and pushes logs and test result metrics.

Grafana Dashboard-based test result monitoring
Section titled “Grafana Dashboard-based test result monitoring”Here’s an example of building a dashboard from k6 test results using metric queries and monitoring them.
- Test overview for an API call test under a light load of around 10 virtual users

- Performance metric overview for API call test results

- HTTP performance metrics and per-API average response time monitoring for the API call test

- Per-scenario case success rate monitoring for the API call test

- k6 Testrun log monitoring for the API call test

Load testing by type with Grafana k6
Section titled “Load testing by type with Grafana k6”A system needs to run many operations concurrently and respond to diverse requests from diverse users. Load testing is used to prepare for these performance risks.

Different traffic patterns produce different risk profiles for an application, so a comprehensive test plan needs a variety of test types:
- Smoke Test: verifies the script works correctly and the system behaves properly under minimal load
- Average-load Test: evaluates system performance under expected normal conditions
- Stress Test: evaluates system performance at the limit, when load exceeds the expected average
- Soak Test: evaluates system stability and performance over a long period
- Spike Test: verifies system behavior and survivability when activity suddenly and briefly surges
- Breakpoint Test: gradually increases load to find the system’s capacity limit
Average-load test
Section titled “Average-load test”Evaluates how the system performs under typical load by simulating expected concurrent users and requests per second in production, to understand whether the system meets its performance goals under normal load. It’s structured as a ramp-up period that scales script activity up to the desired user count/throughput, a hold period at least 5x longer than the ramp-up, and then a ramp-down period.

touch avg-load.js
import { sleep, check } from 'k6';import http from 'k6/http';
export const options = {stages: [{ duration: '1m', target: 400 },{ duration: '10m', target: 400 },{ duration: '1m', target: 0 },],};
export default function () {const urlRes = http.get('http://<target-host>/test');sleep(1);}
kubectl create cm k6-test-avg-load --from-file ./avg-load.jsChecking the k6 test result:

Stress test
Section titled “Stress test”Evaluates how the system performs when the load is heavier than usual. The load pattern is similar to the average-load test but at a higher load.

touch stress.js
import { sleep, check } from 'k6';import http from 'k6/http';
export const options = {// Key configurations for spike in this sectionstages: [{ duration: '1m', target: 2000 }, // fast ramp-up to a high point{ duration: '5m', target: 2000 }, // fast ramp-up to a high point{ duration: '1m', target: 0 }, // quick ramp-down to 0 users],};
export default () => {const urlRes = http.get('http://<target-host>/test');sleep(1);};
kubectl create cm k6-test-stress --from-file ./stress.jsChecking the k6 test result:

Spike test
Section titled “Spike test”Checks that the system continues to work correctly even when a sudden, massive surge of users generates a traffic event, the kind that happens during ticket sales, product launches, process deadlines, or seasonal sales. It ramps up to a very high load over a very short ramp-up period and has a short plateau/ramp-down.

touch spike.js
import { sleep, check } from 'k6';import http from 'k6/http';
export const options = {// Key configurations for spike in this sectionstages: [{ duration: '2m', target: 3200 }, // fast ramp-up to a high point{ duration: '1m', target: 0 }, // quick ramp-down to 0 users],};
export default () => {const urlRes = http.get('http://<target-host>/test');sleep(1);};
kubectl create cm k6-test-spike --from-file ./spike.jsBreakpoint testing
Section titled “Breakpoint testing”Aims to find the system’s limits. It intentionally pushes the system to fail so you can identify the exact failure point and behavior at the limit, and prepare for it in advance.

touch breakpoint.js
import { sleep, check } from 'k6';import http from 'k6/http';
export const options = {// Key configurations for spike in this sectionstages: [{ duration: '30m', target: 10000 }, // just slowly ramp-up to a HUGE load],};
export default () => {const urlRes = http.get('http://<target-host>/test');sleep(1);};
kubectl create cm k6-test-breakpoint --from-file ./breakpoint.jsClosing
Section titled “Closing”An Application CI/CD pipeline is more than just automated build-and-deploy; it’s a stack of layers: a Cache strategy that optimizes build time, Image Signing that hardens supply-chain security, and Smoke Tests that automatically verify state right after deployment. The next post covers how to actually observe and monitor a service once it’s deployed this way: logging, metrics, and alerting from an Observability perspective.