test: integration tests for the tier 1 release fixes - #703
Draft
NickJosevski wants to merge 9 commits into
Draft
Conversation
`--deployment-target "ABC,XYZ"` was sent to the server as a single target name because the flag is a pflag StringArray, while its legacy aliases (`--target`, `--specificMachines`) are StringSlice and already split on commas. Expand comma-separated values for the environment, tenant, tenant-tag and target flags on `release deploy` and `runbook run`, so the comma form matches the repeat-the-flag form. Values that can legitimately contain a comma (--variable, --skip, package/git-resource specs) are left alone. Fixes #556 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`release create --no-prompt` sends the create request straight to the server without resolving package versions first. When a package has no version in its feed the server raises a null reference exception, which surfaces as "Octopus API error: Object reference not set to an instance of an object. []". On a 5xx failure the CLI now repeats the package version resolution the server does, and reports the packages, steps and feeds that have no version available. Where it can't identify a specific package, an unhandled server error now carries a hint about the likely causes. Fixes #426 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`release deploy` passed --version straight to the executions API, which answers an unknown version with "Object reference not set to an instance of an object". Resolve the release before deploying so a version that doesn't exist is reported by name, and call out `latest` explicitly since it is not a supported alias. Refs #294 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…enant The executions API only matches channels, environments and tenants by name, so `release create`, `release deploy` and `runbook run` passed whatever the caller typed straight through and the server rejected IDs. `--project` already worked because the server accepts a project ID or name. Resolve those identifiers client side through the shared selectors package before handing them to the executor, preferring an ID match over a name match so it behaves the same way as `--project`. Fixes #250 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # pkg/cmd/release/deploy/deploy_test.go
The four fixes are green individually but their mock request sequences disagree once merged: #294 adds a release pre-flight lookup and removes the post-deploy web URL lookups, #250 adds an environment lookup, and the tests #250 and #556 introduce expect neither. Two of those cases deadlock the mock server rather than failing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Covers behaviour that only a real server exercises: unknown release versions, packages with no version in their feed, channel and environment IDs on the executions API, and comma-separated deployment targets. Refs #294, #426, #250, #556 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds end-to-end integration tests for the four "Tier 1" fixes — the ones whose correctness depends on how the real Octopus Server behaves, which
testutil.MockHttpServercannot validate by construction.Refs #294, #426, #250, #556.
Why this branch stacks the four fixes
The tests assert post-fix behaviour, so they need the fixes present to pass. This branch merges the four feature branches and adds the tests on top:
nj/issue-294nj/issue-426nj/issue-250nj/issue-556This branch is not for merging as-is. It exists to prove the four compose and to carry the new tests. Once the four land on
main, the last commit here rebases ontomainon its own.Tests added
All in
test/integration/release_test.go, following the existing harness (integration.RunCli,CreateCommonProject,t.Cleanupteardown).TestReleaseDeployUnknownVersion— release deploy returned error when using latest as input param for version #294. Asserts the API premise directly (an unknown version yields no usable release), then thatrelease deploynames the version it could not find, and thatlatestis explained rather than passed through.TestReleaseCreateMissingPackageVersion— Unhelpful output when attempting to create a release with a package that doesn't exist #426. Project with a package step whose package has no version in the built-in feed; asserts the failure names the package and the step.TestReleaseCreateAndDeployByID— Some arguments do not accept the ID instead of the name #250.release create --channel <Channels-N>lands on that channel;release deploy --environment <Environments-N>produces a deployment in that environment.TestReleaseDeployCommaSeparatedTargets— Support comma-delimited values on octopus release deploy --deployment-target command #556. Two cloud-region targets,--deployment-target "A,B", asserts the resulting deployment'sSpecificMachineIdscontains both.Verification
Run against a real Octopus Server (local dev instance, server
main):mainwith the same test file: all 4 fail. They are genuine regression tests, not tests that pass either way.go build ./...clean;go test ./pkg/...green (63 packages).Finding: the null-reference symptom no longer reproduces
#294 and #426 both describe
Octopus API error: Object reference not set to an instance of an object. []. On a current server that is not what happens:Octopus API error: Release 9.9.9 for project <name> was not found. []Octopus API error: There are no viable release plans in any channels using the provided arguments... Cannot resolveThe server-side defect appears to have been fixed since those issues were filed (2022.3 and 2024.4 respectively). Both CLI fixes still improve the message materially, and older servers still exhibit the original behaviour — but the premise that the server null-refs is no longer true on current versions. Two consequences:
assert.NotContains(..., "Object reference not set")lines in these tests are not load-bearing on a current server. They are kept as regression guards for older ones; the positive assertions are what carry the tests.Finding: the four fixes do not compose without test changes
Each of the four is green on its own branch, but merged they break each other's unit tests — invisible on the individual branches by construction. Fixed in the first commit here:
pkg/cmd/release/deploy/deploy_test.go, 8 conflict hunks: release deploy returned error when using latest as input param for version #294 adds a release pre-flight lookup and Some arguments do not accept the ID instead of the name #250 adds an environment lookup to the same request sequences. Resolved by expecting both, release first, matching the merged resolution order indeployRun.MockHttpServerdeadlocked waiting for a request that never came — the full unit suite hung rather than failed.release deploy specifying project, environment and tenant by IDstill expected the two post-deploy web-URL lookups that release deploy returned error when using latest as input param for version #294 removes.environments/alllookup.None of these are defects in the individual PRs; they are ordinary merge fallout. Flagging them because whichever of the four merges last will hit exactly this, and the failure mode for two of them is a hang, not a red test.
Notes
test/integrationhas no build tag andGetApiClientcallsos.Exit(999)whenOCTOPUS_TEST_URL/OCTOPUS_TEST_APIKEYare unset, so a barego test ./...from the repo root hard-exits. Run the suite fromtest/integration.allowDeploymentsTorestores the fixture lifecycle's phases on cleanup, otherwise the environment cannot be deleted.🤖 Generated with Claude Code