🌱 Add e2e tests for forced detachment#3072
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
13bb2e2 to
aaac6ac
Compare
15d7cef to
7e82b68
Compare
4adac2c to
c97da29
Compare
|
/retest Whole bunch of timeouts when registering. Unrelated? |
|
/retest A case of #3195 again. Let's collect some statistics. |
|
/retest |
There was a problem hiding this comment.
Pull request overview
Adds new end-to-end coverage for “forced detachment” behavior during provisioning, including scenarios for deleting after detachment and re-attaching to continue provisioning. To make the tests less timing-dependent, it introduces a direct Ironic API polling helper and wires a new e2e namespace/overlay for the test suite.
Changes:
- Add forced-detachment e2e tests that detach during provisioning and validate follow-up behaviors (delete/re-attach/continue).
- Introduce an Ironic client + polling helper (via Gophercloud) to observe Ironic node provision state during tests.
- Extend e2e overlay/config to include the new
force-detachnamespace and test-specific intervals.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/go.mod | Adds Gophercloud dependency for direct Ironic API access in e2e tests. |
| test/go.sum | Updates sums for the new test-module dependency. |
| test/e2e/ironic_helpers.go | New helper for creating an Ironic client and polling node provision state. |
| test/e2e/forced_detachment_test.go | New e2e test cases covering forced detachment during provisioning (delete and re-attach flows). |
| test/e2e/config/ironic.yaml | Adds force-detach-specific polling intervals to reduce flakes with real Ironic timing. |
| config/overlays/e2e/namespaced-manager-patch.yaml | Adds force-detach to WATCH_NAMESPACE for namespaced e2e runs. |
| config/overlays/e2e/kustomization.yaml | Registers the new force-detach overlay in the e2e overlay set. |
| config/overlays/e2e/force-detach/namespace.yaml | Creates the force-detach namespace for e2e runs. |
| config/overlays/e2e/force-detach/kustomization.yaml | New kustomization overlay to apply RBAC + namespace for the test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if bmh.Annotations == nil { | ||
| bmh.Annotations = make(map[string]string, 1) | ||
| } | ||
| bmh.Annotations["baremetalhost.metal3.io/detached"] = "{\"force\": true}" | ||
|
|
||
| Expect(helper.Patch(ctx, &bmh)).To(Succeed()) |
There was a problem hiding this comment.
This avoids drift if the annotation schema changes
This is exactly a thing I'd prefer to catch in the tests. I'll update the constants though.
c97da29 to
1168b29
Compare
Exercise forced detachment followed by deletion, new enrollment and finished provisioning. Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
The test must wait for the Ironic Node to leave the "available" state, otherwise it won't test the forced detachment, but rather the regular one. Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
1168b29 to
b503e67
Compare
| UndesiredStates: []metal3api.OperationalStatus{ | ||
| metal3api.OperationalStatusError, | ||
| }, | ||
| }, e2eConfig.GetIntervals(specName, "wait-detached")...) |
| default/wait-detached: [ "20s", "10ms" ] | ||
| # NOTE(dtantsur) since provisionRequeueDelay is 10s, 20s may not be enough for forced detachment on real Ironic. | ||
| default/wait-force-detached: [ "40s", "1s" ] |
| By("Adding the detached annotation") | ||
| helper, err := patch.NewHelper(&bmh, clusterProxy.GetClient()) | ||
| Expect(err).NotTo(HaveOccurred()) |
This change adds tests for two aspects of forced detachment:
To be able to run the verification at the right moment, the test
accesses Ironic directly and checks its internal state. A new helper
is introduced for that.
Follow-up to #2955
Assisted-By: Claude Code (commercial license)