ARO-HCP / test-integration
CLAUDE.md39 starsChanged 2 months agoApache-2.0View on GitHub
Artifact-driven integration tests for frontend, backend, and admin services. Tests run against a mock Cosmos DB by default. Tests are declarative: you define a sequence of numbered step directories under an artifacts tree. The framework discovers them automatically via //go:embed artifacts and fs.ReadDir().
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- config/AGENTS.mdAGENTS.md
- test/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- config/CLAUDE.mdCLAUDE.md
- test/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bootstrap-api-versionSkill
- pr-standardsSkill
- agentic-workflowsSkill
The file
We split this claude.md into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 39
Create a new directory under the appropriate artifacts/<Suite>/<ResourceType>/ path
- Very specific: line 40
Add step directories with the NN-<stepType>-<description>/ naming convention
- Distinctive: line 41
Put JSON files in each step directory (resource documents, expected results, keys)
- Distinctive: line 133
No key file needed
- Distinctive: line 134
Place standard Kubernetes resource JSON/YAML files directly in the step directory
- Very specific: line 177
Before the first node pool httpCreate/httpReplace:
- Very specific: line 189
When the update should reach Cluster Service (GetCluster / UpdateCluster):
- Very specific: line 195
Place these immediately before the cluster update step.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
test-integration
Artifact-driven integration tests for frontend, backend, and admin services. Tests run against a mock Cosmos DB by default.
Directory Layout
test-integration/
├── admin/ # Admin API integration tests
├── backend/ # Backend controller tests
├── frontend/ # Frontend service tests
├── utils/
│ ├── databasemutationhelpers/ # Step framework, assertions, step_*.go implementations
│ ├── integrationutils/ # Test infrastructure (mock cosmos, cluster service mock, HTTP servers)
│ └── controllertesthelpers/ # Controller test frameworkHow Tests Work
Tests are declarative: you define a sequence of numbered step directories under an artifacts tree. The framework discovers them automatically via //go:embed artifacts and fs.ReadDir().
Artifact tree structure
artifacts/<SuiteName>/<ResourceType>/<TestCase>/
00-load-initial-state/
01-httpCreate-resource/
02-httpGet-resource/
...
99-cosmosCompare-end-state/- Each test case is a directory containing numbered step subdirectories
- Steps execute sequentially, sorted by their numeric prefix (
NN-) - Step type is parsed from the directory name:
NN-<stepType>-<description>/
Adding a new test
- Create a new directory under the appropriate
artifacts/<Suite>/<ResourceType>/path - Add step directories with the
NN-<stepType>-<description>/naming convention - Put JSON files in each step directory (resource documents, expected results, keys)
- The test framework discovers it automatically -- no Go code changes needed
Step Types
Loading steps
| Step type | Purpose |
load / loadCosmos | Load raw JSON documents directly into cosmos |
loadClusterService | Load mock cluster service state (files suffixed -cluster.json, -nodepool.json, -externalauth.json, -autoscaler.json, -hypershiftdetails.json, -provisionshard.json) |
kubernetesLoad | Create Kubernetes resources via fake clientsets |
kubernetesApply | Update existing K8s resources from JSON/YAML files. Can be partial files. |
migrateCosmos | Trigger database schema migrations |
HTTP API steps (ARM REST calls)
| Step type | Purpose | Compares response? |
httpGet | GET a single resource | Yes, via ResourceInstanceEquals |
httpList | LIST resources | Yes, each item compared |
httpCreate / httpReplace | PUT a resource | No (checks error only) |
httpPost | POST a resource | No (checks error only) |
httpPatch | PATCH a resource | No (checks error only) |
httpDelete | DELETE a resource | No (checks error only) |
Database CRUD steps (direct DB operations)
| Step type | Purpose |
create | Create resource via DB CRUD API |
get | Get resource by parsed ResourceID |
getByID | Get by cosmos ID |
list | List resources in container |
replace | Replace entire resource |
replaceWithETag | Replace with optimistic concurrency |
delete | Delete resource |
listActiveOperations | List in-progress operations for a resource |
Untyped database steps
| Step type | Purpose |
untypedGet | Get untyped document |
untypedList | List untyped documents |
untypedListRecursive | Recursively list untyped descendants |
untypedDelete | Delete untyped document |
Assertion / control steps
| Step type | Purpose |
cosmosCompare | Assert entire cosmos state matches expected JSON documents |
kubernetesCompare | Assert K8s resource state matches expected JSON files (uses ResourceInstanceEquals) |
completeOperation | Mark an async operation as succeeded |
setClusterServiceID | Stamp a Cluster Service internal ID onto a cluster/node pool/external auth doc. Clusters get a random CS HREF (matching mock PostCluster behavior) unless cluster-service-id.json is provided. Node pools and external auths derive from the parent cluster's stored CS ID. Node pool create: add an explicit setClusterServiceID-cluster step (or loadCosmos with a pre-stamped cluster) before the first node pool httpCreate/httpReplace, since node pool creation requires the parent cluster to have a clusterServiceID. External auth creation does not require a parent Cluster Service ID. Cluster update: when a cluster httpReplace/httpPatch should call the Cluster Service mock (GetCluster/UpdateCluster), add setClusterServiceID-cluster (with fixed cluster-service-id.json) immediately followed by loadClusterService-cluster before the update step. See Cluster Service ID patterns below. |
Step Directory Contents
Most steps contain:
00-key.json-- identifies the target resource (format varies by step type)- One or more
*.jsonfiles -- resource documents or expected results expected-error.txt(optional) -- expected error substring for error-checking steps
Key file formats
HTTP steps:
{"resourceID": "/subscriptions/.../providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/name"}Typed CRUD steps:
{
"parentResourceId": "/subscriptions/.../providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/name",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/hcpOpenShiftControllers"
}Untyped recursive steps:
{
"parentResourceId": "/subscriptions/.../...",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters",
"descendents": [
{"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools", "resourceName": "pool-name"}
]
}Kubernetes steps (kubernetesLoad, kubernetesApply, kubernetesCompare):
- No key file needed
- Place standard Kubernetes resource JSON/YAML files directly in the step directory
- Resources are identified by their
apiVersion,kind,metadata.name, and optionallymetadata.namespace
Cosmos Document ID Format
The .id field in cosmos documents is a UUID V5 derived from the resource's ARM resource ID:
- Lowercase the entire resource ID
- Generate a UUID V5 using a fixed namespace UUID (
bf1ee0a1-0147-41ed-a083-d3cbbf7bea99) and the lowercased resource ID as the name
Example: /subscriptions/AAA/resourceGroups/BBB/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/CCC
becomes: <uuid-v5-hash> (e.g., a1b2c3d4-e5f6-5789-abcd-ef0123456789)
The UUID V5 format provides:
- Deterministic IDs (same resource ID always produces the same UUID)
- Compliance with Cosmos DB key length limits
- URL-safe characters (no
/or|delimiters)
Implementation: internal/api/arm/types_cosmosdata.go:ResourceIDStringToCosmosID()
ResourceInstanceEquals (comparison logic)
per_resource_comparer.go -- the core assertion function used by all comparison steps.
Always stripped from both expected and actual before comparison:
- Cosmos internals:
_rid,_self,_etag,_attachments,_ts cosmosMetadata.etagendTime(for operations)- Timestamps:
startTime,lastTransitionTime,operationId - Internal tracking:
activeOperationId,internalId(including underintermediateResourceDoc) - Controller condition
lastTransitionTimeentries
Stripped only for Operation resources (detected via resourceType field or operationId presence):
id,resourceId,cosmosMetadata-- these are UUID-based for operations
Not stripped (now compared) for non-operation resources:
id-- must match the pipe-delimited cosmos ID for cosmos documents, or the ARM resource ID for HTTP responses
Cluster Service ID patterns
The frontend only calls the Cluster Service mock on cluster update when the Cosmos document already has a clusterServiceID (frontend/pkg/frontend/cluster.go). Integration tests must make that ID explicit and seed the mock when exercising update paths.
Node pool create
Before the first node pool httpCreate/httpReplace:
NN-setClusterServiceID-cluster/00-key.json— parent clusterresourceIDfrom the cluster create step- No
cluster-service-id.json— parent gets a random CS HREF at runtime (matches backendPostClusterbehavior) - Child
setClusterServiceID-resourcederives the child CS ID from the parent's stored ID
Skip when the parent is pre-stamped via loadCosmos (e.g. cluster-creating / cluster-deleting fixtures).
External auth creation does not need setClusterServiceID-cluster. External auth create and update operations use an empty internalId, even when updating a legacy resource with a stored clusterServiceID.
Cluster update (httpReplace / httpPatch)
When the update should reach Cluster Service (GetCluster / UpdateCluster):
NN-setClusterServiceID-cluster/00-key.json— clusterresourceIDNN-setClusterServiceID-cluster/cluster-service-id.json— fixed HREF, e.g."/api/clusters_mgmt/v1/clusters/cs-{suite-name}"NN+1-loadClusterService-cluster/cs-{suite-name}-cluster.jsonandcs-{suite-name}-autoscaler.json— mock fixtures whosehrefmatches the stamped ID
Place these immediately before the cluster update step. Complete any in-flight create operation first if the suite creates then updates (see noop-update, create-current).
cosmosCompare after CS-backed update: bump the cluster document's cosmosMetadata.instanceVersion (typically +1). clusterServiceID and activeOperationId are stripped by ResourceInstanceEquals and need not match exactly. Reference: Cluster/read-old-data, Cluster/create-current.
Error-path updates that fail validation before CS (e.g. update-to-illegal-value, update-reject-cluster-version-skew-patch) may still include the stamp/load steps for consistency, but the mock is not consulted when validation rejects the request first.
Running Tests
go test ./test-integration/frontend/...
go test ./test-integration/backend/...
go test ./test-integration/admin/...Tests run against mock infrastructure by default. Set FRONTEND_SIMULATION_TESTING=true to also run against real Cosmos DB.
The frontend starts real cluster, node pool, ServiceProviderCluster (SPC), and
ServiceProviderNodePool (SPNP) informers before fixtures are loaded.
The artifact harness waits for visible DB membership, instance versions, and typed
content to match these caches before HTTP create/replace/patch/delete steps. Go
tests that mutate storage directly should call IntegrationTestInfo.WaitForFrontendCaches
before cache-dependent requests. Integration informers use a test-only short relist
interval for same-version fixture replacements and hard deletes; production defaults
are unchanged. Readiness requires HTTP 200 from frontend /healthz and admin
/healthz/ready, and servers must be cancelled and joined before storage cleanup.
SPC and SPNP documents are backend-owned. Frontend admission reads them from the
cache and never initializes missing documents. Explicitly seed SPC before cluster
updates and node pool creation, and SPNP before node pool updates or cluster
updates that inspect existing node pools, using loadCosmos steps or typed DB
creates. Preserve expected Cosmos snapshots by loading the
provider documents they expect rather than relying on frontend side effects.
Key Source Files
utils/databasemutationhelpers/resource_crud_test_util.go-- test orchestration, step discoveryutils/databasemutationhelpers/per_resource_comparer.go-- assertion/comparison logicutils/databasemutationhelpers/step_*.go-- individual step implementationsutils/integrationutils/utils.go-- test infrastructure setup (mock cosmos, HTTP servers)utils/integrationutils/kube_mock.go-- fake Kubernetes clientsets with informer supportutils/integrationutils/cluster_service_mock.go-- OCM cluster service mockinternal/databasetesting/mock_dbclient.go-- in-memory cosmos mock
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

