How to run a stress test

Stress test overview

Generated custom resources

The stress test generates three types of custom resources in a hierarchical structure:

MeasurementDevices

MeasurementDevices are generated by parsing a SNMP MIB file to extract available object identifiers (walks). Each MeasurementDevice is assigned a random subset of these walks and configured with SNMP v2 community-based authentication. The number of devices created is controlled by the --measurement-devices flag (default: 2).

PhysicalMeasurements

PhysicalMeasurements represent SNMP polling endpoints and are created per MeasurementDevice. Each PhysicalMeasurement references a specific MeasurementDevice and is assigned a random SNMP target IP from development mock list. The number of PhysicalMeasurements per MeasurementDevice is controlled by the --physical-measurements-per-device flag (default: 4).

DataCenterResources

DataCenterResources are generated in a two-layer hierarchy:

  • Root Layer (PDU): One DataCenterResource per PhysicalMeasurement combination, representing a Power Distribution Unit. Each selects a random walk from its associated MeasurementDevice as the energy metric.
  • First Layer (Baremetal): Additional resources created at an expansion rate controlled by the --datacenter-resources-per-measurement flag (default: 3). Each baremetal resource is assigned parents from the PDU layer with equal distribution.

All resources are created sequentially with a configurable delay between requests, controlled by the --delay flag (default: 100ms).

The diagram below illustrates the hierarchical structure of the generated custom resources:

Stress test observability stack

The stress test includes an observability stack that monitors resource creation and reconciliation:

Prometheus

Prometheus scrapes metrics from the stress test application on port 2112. It collects the following metrics:

  • measurement_device_created: Total number of MeasurementDevices created
  • measurement_device_reconciled: Number of MeasurementDevices with Ready status
  • physical_measurement_created: Total number of PhysicalMeasurements created
  • physical_measurement_reconciled: Number of PhysicalMeasurements with Ready status
  • datacenter_resources_created: Total number of DataCenterResources created
  • datacenter_resources_reconciled: Number of DataCenterResources with Ready status
  • latency_seconds: Kubernetes API query latency for listing resources

The metrics server runs on localhost:2112/metrics and updates every 200 milliseconds.

Grafana

Grafana provides visualization dashboards for the collected metrics. Key features:

  • Authentication disabled: Anonymous access with Admin privileges for easy testing
  • Pre-configured datasource: Automatically connects to Prometheus
  • Dashboard provisioning: Dashboards are loaded from ./grafana/dashboards/
  • Access: Available at http://localhost:3000

The observability stack runs alongside the stress test via Docker Compose with all services on host network mode for direct access to the Kubernetes cluster metrics.

Running the observability stack

KUBECONFIG_FILE=${HOME}/.kube/config docker compose -f ./dev/stresstest-observability/docker-compose.yml up

The KUBECONFIG_FILE environment variable specifies the Kubernetes configuration file that will be mounted into the Prometheus and Grafana containers. This file contains the cluster connection details and authentication credentials required for the observability stack to access your Kubernetes cluster and collect metrics. In most environments, the kubeconfig is located at ${HOME}/.kube/config

This command:

  • Starts Prometheus on http://localhost:9090 to scrape metrics from the stress test application
  • Starts Grafana on http://localhost:3000 with pre-configured dashboards and datasources
  • Configures both services to run on host network mode for direct access to your Kubernetes cluster metrics
  • Enables metric collection at 200ms intervals for real-time monitoring

To stop the observability stack:

docker compose -f ./dev/stresstest-observability/docker-compose.yml down

Running the stress test

To run the stress test, execute the following command:

go run ./dev/stresstest/

The different option flags can be viewed by running:

go run ./dev/stresstest/ -h

Cleaning up resources

To clean the generated resources after the stress test, execute the following command:

go run ./dev/stresstest/ -cleanup