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-measurementflag (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 createdmeasurement_device_reconciled: Number of MeasurementDevices with Ready statusphysical_measurement_created: Total number of PhysicalMeasurements createdphysical_measurement_reconciled: Number of PhysicalMeasurements with Ready statusdatacenter_resources_created: Total number of DataCenterResources createddatacenter_resources_reconciled: Number of DataCenterResources with Ready statuslatency_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
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:9090to scrape metrics from the stress test application - Starts Grafana on
http://localhost:3000with 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:
Running the stress test
To run the stress test, execute the following command:
The different option flags can be viewed by running:
Cleaning up resources
To clean the generated resources after the stress test, execute the following command: