Skip to content

test(simulate): give each simulate command its own integration suite - #508

Draft
jcogilvie wants to merge 28 commits into
crossplane:mainfrom
jcogilvie:jco-simulate-integration-split
Draft

jcogilvie wants to merge 28 commits into
crossplane:mainfrom
jcogilvie:jco-simulate-integration-split

Conversation

@jcogilvie

Copy link
Copy Markdown
Collaborator

Description of your changes

Note

Stacked on #487, so until it merges, this PR's diff includes it. The commits for this PR are the top five.

This is the follow-up to two of @haarchri's comments on #486. All the simulate integration cases lived in cmd/crossplane/project. Now each command owns its suite, and the simulate.ProjectResult type is renamed to fit what it is.

Suites per command:

  • cmd/crossplane/composition: TestCompDiffIntegration and the fixtures only it uses.
  • cmd/crossplane/xr: TestDiffIntegration and the fixtures only it uses.
  • cmd/crossplane/project: keeps the project simulate cases, the plan-output and provider-plan tests.
  • Shared harness: internal/testutils/integration/simharness, behind the integration build tag. It holds the argv translation, the run helpers, the case types and the least-privilege RBAC rules.
  • Shared fixtures: the CRDs and every fixture more than one suite uses are in internal/testutils/integration/testdata.

Files moved with git mv, so git log --follow keeps their history. No case is added, removed or changed. The test list across the three packages matches the one before the move.

-p 1 for the integration tests: once the cases were split into three packages, go test ran them in parallel, and three suites rendering through Docker at once timed out. nix/apps.nix now runs integration packages one at a time, and each package's cases still run in parallel. Before the move, the simulate cases were all in one package, so CI's integration job should take about as long as before.

ProjectResult becomes Result: every simulate command emits it for -o json and -o yaml, not only project simulate. NewProjectResult becomes NewResult. The JSON output is unchanged.

Related:

I have:

  • Read and followed Crossplane's contribution process.
  • Run ./nix.sh flake check to ensure this PR is ready for review.
  • Added or updated unit tests. A pure move and rename.
  • Linked a PR or a docs tracking issue to document this change. No user-facing change.
  • Added backport release-x.y labels to auto-backport this PR.

🤖 Generated with Claude Code

jcogilvie and others added 19 commits November 6, 2026 20:35
Restore PerformDiff with its input validator, ValidatedInput, the
WithInputValidatorFactory option, their mocks, test helpers and tests
from the state before the XR-only path was removed. Keep the
TestManagedByManagerWithNoName case that the managedBy/boundToClaim
table port added and the restored tests lack.

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Inputs that are neither Compositions nor project files are composite
resource candidates, which checkComposites confirms against the
cluster's XRDs. Every rejection uses RejectInput's template, so
composition and xr simulate point at each other symmetrically. The
runner gains a Composites input that runs PerformDiff and renders
through renderXRReport.

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
xr simulate previews composite resource or claim files against the
cluster with its Compositions and functions, through the shared
simulate runner. It takes no selection flags or --max-concurrency.

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Restore TestDiffIntegration, TestSimulateProviderPlan, the XR plan-output
cases of TestSimulatePlanOutput and the remaining testdata. The harness
now runs XRDiffTest cases as `xr simulate` with -f per file, and the
TestCompDiffIntegration comments that point at TestDiffIntegration are
restored.

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Restore simArgs.FunctionCredentials with its --function-credentials argv,
which the XR cases of TestDiffIntegration use. simulateArgv maps
XRDiffTest to xr simulate and still fails on any other unknown test type.
The admission-policy gate uses integration.AwaitAdmissionDenial.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Move the build step of Run into Flags.build and test that both
Composition and composite resource inputs take imageConfigs only from
--image-configs, never from ./crossplane-project.yaml.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Point project, composition and xr simulate help at each other, and
resource simulate help at the three. Mark xr simulate as added in the
design doc and name the right commands in the integration testdata README.

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…Reports

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ments

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…osites

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d test

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rated list

xr simulate owns which inputs it accepts, and -f matches resource simulate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
With --skip-plan nothing fetches packages, and --cache-dir is already
reported as ignored, so don't create (and fail on) the cache directory.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Match composition and project simulate: the create and patch permissions
come in an Important callout straight after the summary, with the reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie
jcogilvie force-pushed the jco-simulate-integration-split branch from c64aaa8 to 43fb7f1 Compare November 7, 2026 01:47
jcogilvie and others added 9 commits November 7, 2026 00:10
Errors, resource plans, validation failures and field errors were matched
first-wins, so two expectations could be satisfied by one result while the
count check still passed. Track used results as the warnings matcher does,
and match per-XR errorIDs by ref so same-named XRs in different namespaces
do not fail spuriously.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
WithFieldAbsent on a delete read only leaf changes, so an empty map or
list in Before passed. WithDryRunStorageVersion was silently unchecked
without WithDryRunSkipped. WithXRs matches regardless of order, so say so.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
…s in the footer

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
A claim or namespaced composite resource with no metadata.namespace now
takes the context namespace, as kubectl apply would. Cluster-scoped
composite resources are left alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
…nternal/testutils

The simulate argv translation, case runner and fixtures shared by the
composition, xr and project integration suites move to simharness and
internal/testutils/integration/testdata so each command can own its suite.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Each suite already runs its cases in parallel; three suites rendering
through Docker at once starve each other into timeouts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie
jcogilvie force-pushed the jco-simulate-integration-split branch from 43fb7f1 to 5ad7bcc Compare November 7, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant