ROSAENG-61173 | test: complete delete cluster command coverage#3373
ROSAENG-61173 | test: complete delete cluster command coverage#3373olucasfreitas wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: olucasfreitas The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRefactors Suggested reviewers: 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/dlt/cluster/cmd.go`:
- Around line 85-94: Wrap the error returned by handleClusterDelete in
runWithRuntime with operation and cluster-key context using %w, preserving the
original error for matching. Keep run’s existing reporter and exit behavior
unchanged so the centralized reporting receives the contextualized failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: caa151cc-eb84-4f79-9d67-6944c84ca026
📒 Files selected for processing (2)
cmd/dlt/cluster/cmd.gocmd/dlt/cluster/cmd_test.go
85ab16a to
0f94be2
Compare
946d65b to
e7c9126
Compare
Signed-off-by: lufreita <lufreita@redhat.com>
e7c9126 to
3c4c631
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/dlt/cluster/cmd.go (1)
136-139: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winRestore the previous warning state with
defer.Because this is package-level state, capture its prior value and defer restoration around
uninstallLogsFn. The current hard-coded reset only handles normal returns and can leak or overwrite state after callback failures.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/dlt/cluster/cmd.go` around lines 136 - 139, Update the args.watch branch around DisableRegionDeprecationWarning and uninstallLogsFn to capture the flag’s existing value, defer restoring that exact value, then temporarily set it to true while uninstallLogsFn runs; remove the hard-coded false reset so callback failures also restore package-level state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/dlt/cluster/cmd.go`:
- Around line 136-139: Update the args.watch branch around
DisableRegionDeprecationWarning and uninstallLogsFn to capture the flag’s
existing value, defer restoring that exact value, then temporarily set it to
true while uninstallLogsFn runs; remove the hard-coded false reset so callback
failures also restore package-level state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: c319e62d-08f0-4caa-9363-a32d51c5f667
📒 Files selected for processing (2)
cmd/dlt/cluster/cmd.gocmd/dlt/cluster/cmd_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/dlt/cluster/cmd_test.go
PR Summary
Complete the remaining coverage for
rosa delete clusterby adding command-level tests for the legacy delete flow and a small refactor that makes the command body testable without changing CLI behavior.Detailed Description of the Issue
PR #3298 added helper coverage for
handleClusterDelete()andbuildCommands(), but the actualrosa delete clustercommand flow was still untested. Phase 2B still required coverage for confirmation handling, best-effort output, STS cleanup messaging, uninstall log watching, and wrapper-level error propagation.This change extracts a testable
runWithRuntime(...)helper incmd/dlt/cluster/cmd.goand adds focused Ginkgo coverage for the remaining command behaviors while preserving the existingRun: runentrypoint, flags, and user-facing flow.Related Issues and PRs
Type of Change
Previous Behavior
cmd/dlt/clusterhad helper-level coverage, but the full command flow remained untested. Important behaviors like confirmation decline,--best-effort, STS cleanup output,--watch, and wrapper-level error handling were still gaps in Phase 2B.Behavior After This Change
The delete-cluster command now has focused command-level coverage for:
--best-effortwarning and passthrough behaviorGetClusterStateandDeleteClustererrors--watchinvoking uninstall logs while restoring the region deprecation warning flagThe command shape, flags, and user-facing behavior remain unchanged.
How to Test (Step-by-Step)
Preconditions
go.modGOTOOLCHAIN=local, useGOTOOLCHAIN=autofor the commands belowTest Steps
GOTOOLCHAIN=auto make fmtGOTOOLCHAIN=auto go test ./cmd/dlt/cluster/... -count=1GOTOOLCHAIN=auto make lintGOTOOLCHAIN=auto make rosaGOTOOLCHAIN=auto make testExpected Results
cmd/dlt/clusterpackage tests passrosabinary builds successfullyProof of the Fix
go test ./cmd/dlt/cluster/... -count=1passedmake lintpassed (0 issues)make rosapassedmake testpassedgit pushpre-push checks: 5/5 passed (format, build, lint, changed-files coverage, unit/integration tests)Breaking Changes
Developer Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make install-hookshas been run in this clone.make testpasses.make lintpasses.make rosapasses.Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
rosa delete clustercontrol flow, error propagation, and output when confirmation is declined.User Experience
--watchbehavior to run uninstall logs automatically and adjust messaging/hints accordingly.Tests