-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lca: add negative test for patching the stage from idle to rollback.
Adding a test per the title. Signed-off-by: Alexander Chuzhoy <[email protected]>
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
76 changes: 76 additions & 0 deletions
76
tests/lca/imagebasedupgrade/mgmt/negative/tests/ibu-invalid-next-stage.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package negative_test | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/openshift-kni/eco-goinfra/pkg/lca" | ||
"github.com/openshift-kni/eco-goinfra/pkg/reportxml" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/internal/nodestate" | ||
. "github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/mgmt/internal/mgmtinittools" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/mgmt/negative/internal/tsparams" | ||
"golang.org/x/exp/slices" | ||
) | ||
|
||
var _ = Describe( | ||
"Patching ibu stage from Idle to Rollback", | ||
Ordered, | ||
Label(tsparams.LabelStageTransitionIdleToRollback), func() { | ||
var ( | ||
ibu *lca.ImageBasedUpgradeBuilder | ||
err error | ||
) | ||
|
||
BeforeAll(func() { | ||
By("Pull the imagebasedupgrade from the cluster") | ||
ibu, err = lca.PullImageBasedUpgrade(APIClient) | ||
Expect(err).NotTo(HaveOccurred(), "error pulling ibu resource from cluster") | ||
|
||
By("Ensure that imagebasedupgrade stage is set to Idle") | ||
Expect(string(ibu.Object.Spec.Stage)).To(Equal("Idle"), "error: ibu resource contains unexpected state") | ||
}) | ||
|
||
AfterAll(func() { | ||
By("Revert IBU resource back to Idle stage") | ||
ibu, err = lca.PullImageBasedUpgrade(APIClient) | ||
Expect(err).NotTo(HaveOccurred(), "error pulling imagebasedupgrade resource") | ||
|
||
if ibu.Object.Spec.Stage == "Upgrade" { | ||
By("Set IBU stage to Rollback") | ||
_, err = ibu.WithStage("Rollback").Update() | ||
Expect(err).NotTo(HaveOccurred(), "error setting ibu to rollback stage") | ||
|
||
By("Wait for IBU resource to be available") | ||
err = nodestate.WaitForIBUToBeAvailable(APIClient, ibu, time.Minute*10) | ||
Expect(err).NotTo(HaveOccurred(), "error waiting for ibu resource to become available") | ||
|
||
By("Wait until Rollback stage has completed") | ||
_, err = ibu.WaitUntilStageComplete("Rollback") | ||
Expect(err).NotTo(HaveOccurred(), "error waiting for rollback stage to complete") | ||
} | ||
|
||
if slices.Contains([]string{"Prep", "Rollback"}, string(ibu.Object.Spec.Stage)) { | ||
By("Set IBU stage to Idle") | ||
_, err = ibu.WithStage("Idle").Update() | ||
Expect(err).NotTo(HaveOccurred(), "error setting ibu to idle stage") | ||
|
||
By("Wait until IBU has become Idle") | ||
_, err = ibu.WaitUntilStageComplete("Idle") | ||
Expect(err).NotTo(HaveOccurred(), "error waiting for idle stage to complete") | ||
} | ||
|
||
Expect(string(ibu.Object.Spec.Stage)).To(Equal("Idle"), "error: ibu resource contains unexpected state") | ||
|
||
}) | ||
|
||
It("fails because from Idle it's not possible to move to Rollback stage", reportxml.ID("71738"), func() { | ||
|
||
By("Setting the IBU stage to Rollback") | ||
|
||
_, err := ibu.WithStage("Rollback").Update() | ||
Expect(err.Error()).To(ContainSubstring("the stage transition is not permitted"), | ||
"error: ibu seedimage updated with wrong next stage") | ||
|
||
}) | ||
}) |