Skip to content

CI/CD Test Automation: Environment-specific Testing and k6 Monitoring

Interactive Diagram

새 탭 ↗

This section covers Grafana k6-based Module/Smoke Test setup and monitoring integration, along with Test Result Reporting and Dashboard construction.

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.

Local Environment Test

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.

CI/CD Integration Test

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.

Scheduled Test

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 Test Overview
  • Performance metric overview for API call test results Performance Metric Overview
  • HTTP performance metrics and per-API average response time monitoring for the API call test HTTP Performance Metric Monitoring
  • Per-scenario case success rate monitoring for the API call test Scenario Success Rate Monitoring
  • k6 Testrun log monitoring for the API call test Testrun Log Monitoring

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.

Load test types

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

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.

Average-load test

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.js

Checking the k6 test result:

Average-load test result

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.

Stress test

touch stress.js
import { sleep, check } from 'k6';
import http from 'k6/http';
export const options = {
// Key configurations for spike in this section
stages: [
{ 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.js

Checking the k6 test result:

Stress test result

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.

Spike test

touch spike.js
import { sleep, check } from 'k6';
import http from 'k6/http';
export const options = {
// Key configurations for spike in this section
stages: [
{ 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.js

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.

Breakpoint test

touch breakpoint.js
import { sleep, check } from 'k6';
import http from 'k6/http';
export const options = {
// Key configurations for spike in this section
stages: [
{ 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.js

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.

  1. Application CI/CD Architecture: Variables, Secrets, and Reusable Modules
  2. GitHub Actions CI Workflow: Build Caching and Image Builds
  3. GitOps CD Workflow: Image Signing and Smoke Testing
  4. CI/CD Test Automation: Environment-specific Testing and k6 Monitoring