Skip to content

Commit

Permalink
ibu cnf: add prep abort test case (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmaruthu authored Jun 4, 2024
1 parent d194642 commit c962e66
Show file tree
Hide file tree
Showing 2 changed files with 101 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"
// LabelPrepAbortFlow represents prep-abort label that can be used for test cases selection.
LabelPrepAbortFlow = "ibu-prep-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,99 @@
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(
"Performing upgrade prep abort flow",
Label(tsparams.LabelPrepAbortFlow), 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.
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 finalize cgu created on target hub cluster", func() {
err := cnfhelper.DeleteIbuTestCguOnTargetHub(cnfinittools.TargetHubAPIClient, tsparams.FinalizeCguName,
tsparams.IbuCguNamespace)
Expect(err).ToNot(HaveOccurred(), "Failed to delete finalize cgu on target hub cluster")
})
})

It("Upgrade prep abort flow", reportxml.ID("68956"), 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, 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 c962e66

Please sign in to comment.