Skip to content

Commit

Permalink
Draft: ibu cnf: add upgrade abort test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmaruthu committed Jun 3, 2024
1 parent d48f966 commit 9af9bea
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const (
LabelSuite = "upgrade"
// LabelEndToEndUpgrade represents e2e label that can be used for test cases selection.
LabelEndToEndUpgrade = "e2e"
// LabelUpgradeAbortFlow represents upgrade-abort label that can be used for test cases selection.
LabelUpgradeAbortFlow = "ibu-upgrade-abort"

// IbuCguNamespace is the namespace where IBU CGUs created on target hub.
IbuCguNamespace = "default"
Expand Down
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.")
})
})
})

0 comments on commit 9af9bea

Please sign in to comment.