-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft: ibu cnf: add upgrade abort test case
- Loading branch information
Showing
2 changed files
with
112 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
110 changes: 110 additions & 0 deletions
110
tests/lca/imagebasedupgrade/cnf/upgrade-talm/tests/upgrade-abort-test.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,110 @@ | ||
package upgrade_test | ||
|
||
import ( | ||
"time" | ||
|
||
"k8s.io/utils/ptr" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/openshift-kni/eco-goinfra/pkg/cgu" | ||
"github.com/openshift-kni/eco-goinfra/pkg/reportxml" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/cnf/internal/cnfclusterinfo" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/cnf/internal/cnfhelper" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/cnf/internal/cnfinittools" | ||
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/cnf/upgrade-talm/internal/tsparams" | ||
) | ||
|
||
var _ = Describe( | ||
"Validating abort at IBU upgrade stage", | ||
Label(tsparams.LabelUpgradeAbortFlow), func() { | ||
|
||
BeforeEach(func() { | ||
By("Fetching target sno cluster name", func() { | ||
err := cnfclusterinfo.PreUpgradeClusterInfo.SaveClusterInfo() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to extract target sno cluster name") | ||
|
||
tsparams.TargetSnoClusterName = cnfclusterinfo.PreUpgradeClusterInfo.Name | ||
}) | ||
}) | ||
|
||
AfterEach(func() { | ||
// Deleting CGUs created for validating the test case. | ||
By("Deleting pre-prep cgu created on target hub cluster", func() { | ||
err := cnfhelper.DeleteIbuTestCguOnTargetHub(cnfinittools.TargetHubAPIClient, tsparams.PrePrepCguName, | ||
tsparams.IbuCguNamespace) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to delete pre-prep cgu on target hub cluster") | ||
}) | ||
|
||
By("Deleting prep cgu created on target hub cluster", func() { | ||
err := cnfhelper.DeleteIbuTestCguOnTargetHub(cnfinittools.TargetHubAPIClient, tsparams.PrepCguName, | ||
tsparams.IbuCguNamespace) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to delete prep cgu on target hub cluster") | ||
}) | ||
|
||
By("Deleting upgrade cgu created on target hub cluster", func() { | ||
err := cnfhelper.DeleteIbuTestCguOnTargetHub(cnfinittools.TargetHubAPIClient, tsparams.UpgradeCguName, | ||
tsparams.IbuCguNamespace) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to delete upgrade cgu on target hub cluster") | ||
}) | ||
}) | ||
|
||
It("Abort at IBU upgrade stage", reportxml.ID("69055"), func() { | ||
By("Creating, enabling ibu pre-prep CGU and waiting for CGU status to report completed", func() { | ||
prePrepCguBuilder := cgu.NewCguBuilder(cnfinittools.TargetHubAPIClient, | ||
tsparams.PrePrepCguName, tsparams.IbuCguNamespace, 1). | ||
WithCluster(tsparams.TargetSnoClusterName). | ||
WithManagedPolicy(tsparams.PrePrepPolicyName). | ||
WithCanary(tsparams.TargetSnoClusterName) | ||
prePrepCguBuilder.Definition.Spec.Enable = ptr.To(true) | ||
|
||
prePrepCguBuilder, err := prePrepCguBuilder.Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create pre-prep CGU.") | ||
|
||
_, err = prePrepCguBuilder.WaitUntilComplete(10 * time.Minute) | ||
Expect(err).ToNot(HaveOccurred(), "Pre-prep CGU did not complete in time.") | ||
}) | ||
|
||
By("Creating, enabling ibu prep CGU and waiting for CGU status to report completed", func() { | ||
prepCguBuilder := cgu.NewCguBuilder(cnfinittools.TargetHubAPIClient, | ||
tsparams.PrepCguName, tsparams.IbuCguNamespace, 1). | ||
WithCluster(tsparams.TargetSnoClusterName). | ||
WithManagedPolicy(tsparams.PrepPolicyName). | ||
WithCanary(tsparams.TargetSnoClusterName) | ||
prepCguBuilder.Definition.Spec.Enable = ptr.To(true) | ||
|
||
prepCguBuilder, err := prepCguBuilder.Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create prep CGU.") | ||
|
||
_, err = prepCguBuilder.WaitUntilComplete(25 * time.Minute) | ||
Expect(err).ToNot(HaveOccurred(), "Prep CGU did not complete in time.") | ||
}) | ||
|
||
By("Creating, and enabling ibu upgrade CGU", func() { | ||
upgradeCguBuilder := cgu.NewCguBuilder(cnfinittools.TargetHubAPIClient, | ||
tsparams.UpgradeCguName, tsparams.IbuCguNamespace, 1). | ||
WithCluster(tsparams.TargetSnoClusterName). | ||
WithManagedPolicy(tsparams.UpgradePolicyName). | ||
WithCanary(tsparams.TargetSnoClusterName) | ||
upgradeCguBuilder.Definition.Spec.Enable = ptr.To(true) | ||
|
||
_, err := upgradeCguBuilder.Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create upgrade CGU.") | ||
}) | ||
|
||
By("Creating, enabling ibu finalize CGU and waiting for CGU status to report completed", func() { | ||
finalizeCguBuilder := cgu.NewCguBuilder(cnfinittools.TargetHubAPIClient, | ||
tsparams.FinalizeCguName, tsparams.IbuCguNamespace, 1). | ||
WithCluster(tsparams.TargetSnoClusterName). | ||
WithManagedPolicy(tsparams.FinalizePolicyName). | ||
WithCanary(tsparams.TargetSnoClusterName) | ||
finalizeCguBuilder.Definition.Spec.Enable = ptr.To(true) | ||
|
||
finalizeCguBuilder, err := finalizeCguBuilder.Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create finalize CGU.") | ||
|
||
_, err = finalizeCguBuilder.WaitUntilComplete(5 * time.Minute) | ||
Expect(err).ToNot(HaveOccurred(), "Finalize CGU did not complete in time.") | ||
}) | ||
}) | ||
}) |