Integration Tests
Basic integration test suite for cluster-health-analyzer running on OpenShift.
Usage
# Deploy and test
make deploy-integration
make test-integration
# Cleanup
make undeploy-integration
Requirements
- OpenShift cluster access (
oc login required)
- Go 1.26+
- Permissions to create resources in
openshift-monitoring namespace
- PrometheusRule CRD available (standard OpenShift installation)
Test Prerequisites
Before running tests, ensure Thanos querier is accessible:
# Start port-forward to Thanos (required for Prometheus client)
make proxy
This runs oc port-forward -n openshift-monitoring svc/thanos-querier 9090:9091 in the background and is required for tests to query cluster metrics.
Test Lifecycle
Integration tests follow a specific resource lifecycle pattern:
- Resource Creation: Each test creates resources with unique names (timestamp-based suffix)
- No Automatic Cleanup: Resources are intentionally left running after tests for inspection
- Pre-Test Cleanup: Each test's
BeforeEach removes its own resources from previous runs
- Manual Cleanup: Remove all test resources with:
oc delete deployment,prometheusrule -l test-type=crashloop -n openshift-monitoring
oc delete deployment,prometheusrule -l test-type=stress -n openshift-monitoring
This approach allows you to inspect resources after test completion while preventing accumulation across test runs.
Configuration
Override defaults via environment variables:
CHA_IMAGE=quay.io/myorg/cluster-health-analyzer:dev make deploy-integration
CHA_IMAGE=quay.io/myorg/cluster-health-analyzer:dev make test-integration