Skip to content

chore: add deployment version e2e tests#903

Merged
adityachoudhari26 merged 2 commits intomainfrom
version-e2e-tests
Apr 2, 2026
Merged

chore: add deployment version e2e tests#903
adityachoudhari26 merged 2 commits intomainfrom
version-e2e-tests

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Apr 2, 2026

Summary by CodeRabbit

  • Tests
    • Added comprehensive tests covering version selection and lifecycle: release creation and job dispatch to targets, pause/resume and rejected-version rollbacks, approval gating, metadata-based filtering, cooldowns to prevent rapid flapping, rapid-succession behavior (only latest dispatched), and deployability rules for non-ready statuses.

Copilot AI review requested due to automatic review settings April 2, 2026 03:34
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff0745c2-cf1c-4a90-a195-36a8dc7e8747

📥 Commits

Reviewing files that changed from the base of the PR and between 3e88b85 and 9e68eb4.

📒 Files selected for processing (1)
  • apps/workspace-engine/test/controllers/version_test.go

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

Adds a new Go test suite apps/workspace-engine/test/controllers/version_test.go with ~26 integration-style tests exercising version selection, release creation, job dispatch, pause/reject behavior, cooldowns, approval gating, and metadata/config propagation.

Changes

Cohort / File(s) Summary
Version Controller Tests
apps/workspace-engine/test/controllers/version_test.go
Adds a single comprehensive test file (~941 lines) containing ~26 tests validating end-to-end version selection and dispatch behavior: release creation, job generation across targets/agents, pause/reject logic and rollbacks, cooldowns, approval gating, readiness filtering, metadata-based selection, and propagation of config/metadata into releases and jobs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰
Hopping through tests with zest and cheer,
Versions picked and jobs appear,
Pauses, rollbacks, approvals in sight,
Releases marching through the night,
A rabbit pats the code — all clear! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: add deployment version e2e tests' accurately describes the PR's main purpose of adding end-to-end tests for deployment version functionality, directly matching the addition of 942 lines of comprehensive test coverage in version_test.go.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch version-e2e-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new end-to-end style controller pipeline test suite to validate deployment version behavior (selection, rollout gating, and job dispatch) in workspace-engine.

Changes:

  • Introduces version_test.go covering version selection (paused/rejected/building/failed), ordering, and metadata-based filtering.
  • Adds re-evaluation scenarios (new version added, active version rejected) and rollout gating scenarios (approval gate, cooldown, gradual rollout).
  • Validates job dispatch behavior across multiple resources and agents, plus job-agent config propagation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

p.AssertReleaseVersion(t, 0, "v3.0.0")
p.AssertJobCreated(t)

release := p.Releases()[0]
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestVersion_ReleaseLinkedToCorrectVersion asserts job.ReleaseId == release.Id.String(), but in the current test harness the desired-release controller/mock setter does not populate oapi.Release.Id (jobs are created with ReleaseId: r.Id.String()), so both values are typically the zero UUID. This makes the assertion effectively vacuous and won’t catch broken job↔release linkage. Suggestion: update the harness to assign a stable non-zero release ID (e.g., r.Id = r.UUID() or equivalent) and set job.ReleaseId accordingly, or change the test to assert against that stable ID so the linkage is actually verified.

Suggested change
release := p.Releases()[0]
release := p.Releases()[0]
require.NotEqual(t, uuid.Nil, release.Id, "release ID must be non-zero to validate job linkage")

Copilot uses AI. Check for mistakes.
Comment on lines +558 to +563
p.ReleaseGetter.Releases = map[string]*oapi.Release{
release.Id.String(): release,
}
p.ReleaseGetter.JobVerificationStatuses = map[string]oapi.JobVerificationStatus{
job.Id: oapi.JobVerificationStatusPassed,
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test keys ReleaseGetter.Releases by release.Id.String(). In the current harness, releases typically have an unset/zero Id, so this map will use the same key for every release and can hide issues when multiple releases are involved. Prefer keying by a stable non-zero release ID (and ensure the harness sets it, e.g., via deterministic Release.UUID()) so GetReleaseByJobID/cooldown evaluation can’t accidentally resolve the wrong release.

Copilot uses AI. Check for mistakes.
Comment on lines +807 to +830
func TestVersion_ConfigAndMetadataFlowToRelease(t *testing.T) {
p := NewTestPipeline(t,
WithDeployment(DeploymentSelector("true")),
WithEnvironment(EnvironmentName("production")),
WithResource(ResourceName("srv"), ResourceKind("Server")),
WithVersion(
VersionTag("v1.0.0"),
VersionMetadata(map[string]string{
"git-sha": "abc123",
"build-url": "https://ci.example.com/builds/42",
"image-repo": "ghcr.io/myorg/myapp",
}),
),
)

p.Run()

p.AssertReleaseCreated(t)
release := p.Releases()[0]
assert.Equal(t, "v1.0.0", release.Version.Tag)
assert.Equal(t, "abc123", release.Version.Metadata["git-sha"])
assert.Equal(t, "https://ci.example.com/builds/42", release.Version.Metadata["build-url"])
assert.Equal(t, "ghcr.io/myorg/myapp", release.Version.Metadata["image-repo"])
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name says “ConfigAndMetadataFlowToRelease”, but the setup/assertions only cover VersionMetadata and never set/assert DeploymentVersion.Config. Either rename the test to reflect metadata-only behavior, or add a VersionOption that sets v.Config and assert the config is present on release.Version.Config as well.

Copilot uses AI. Check for mistakes.
Comment on lines +862 to +882
func TestVersion_VersionConfigFlowsToRelease(t *testing.T) {
p := NewTestPipeline(t,
WithDeployment(DeploymentSelector("true")),
WithEnvironment(EnvironmentName("production")),
WithResource(ResourceName("srv"), ResourceKind("Server")),
WithVersion(
VersionTag("v1.0.0"),
VersionMetadata(map[string]string{"deploy-strategy": "blue-green"}),
),
WithJobAgent("deployer"),
)

p.Run()

p.AssertReleaseCreated(t)
p.AssertJobCreated(t)

release := p.Releases()[0]
assert.Equal(t, "blue-green", release.Version.Metadata["deploy-strategy"])
p.AssertJobReleaseID(t, 0, release.Id.String())
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestVersion_VersionConfigFlowsToRelease only sets/asserts metadata (VersionMetadata / release.Version.Metadata) and then asserts job↔release linkage via release.Id, which is typically unset/zero in the harness. Consider renaming this test to “...Metadata...” (or actually set/assert DeploymentVersion.Config), and avoid asserting linkage via release.Id until the harness assigns stable non-zero IDs (e.g., release.UUID()).

Copilot uses AI. Check for mistakes.
@adityachoudhari26 adityachoudhari26 merged commit a8af2f1 into main Apr 2, 2026
9 of 10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the version-e2e-tests branch April 2, 2026 03:53
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.

2 participants