Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial ibu post upgrade validations structure #58

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/imagebasedupgrade/internal/ibuclusterinfo/ibuclusterinfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ibuclusterinfo

import (
"github.com/golang/glog"
. "github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeinittools"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeparams"
"github.com/openshift-kni/eco-gosystem/tests/internal/cluster"
)

// SaveClusterInfo is a dedicated func to save cluster info.
func SaveClusterInfo(upgradeVar *imagebasedupgradeparams.ClusterStruct) error {
clusterVersion, err := cluster.GetClusterVersion(TargetSNOAPIClient)

if err != nil {
glog.V(100).Infof("Could not retrieve cluster version")

return err
}

clusterID, err := cluster.GetClusterID(TargetSNOAPIClient)

if err != nil {
glog.V(100).Infof("Could not retrieve cluster id")

return err
}

*upgradeVar = imagebasedupgradeparams.ClusterStruct{
Version: clusterVersion,
ID: clusterID,
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package imagebasedupgradeparams

// ClusterStruct is a struct that holds the cluster version and id.
type ClusterStruct struct {
Version string
ID string
}

var (
// PreUpgradeClusterInfo holds the cluster info pre upgrade.
PreUpgradeClusterInfo = ClusterStruct{}

// PostUpgradeClusterInfo holds the cluster info post upgrade.
PostUpgradeClusterInfo = ClusterStruct{}
)
13 changes: 13 additions & 0 deletions tests/imagebasedupgrade/tests/happy-path-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/lca"
"github.com/openshift-kni/eco-goinfra/pkg/polarion"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/ibuclusterinfo"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeinittools"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeparams"
ibuvalidations "github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/validations"
)

// IbuCr is a dedicated var to use and act on it.
Expand All @@ -22,6 +24,11 @@ var _ = Describe(
By("Generating seed image", func() {
// Test Automation Code Implementation is to be done.
})

By("Saving pre upgrade cluster info", func() {
err := ibuclusterinfo.SaveClusterInfo(&imagebasedupgradeparams.PreUpgradeClusterInfo)
Expect(err).ToNot(HaveOccurred(), "Failed to save pre upgrade cluster info")
})
})

AfterAll(func() {
Expand Down Expand Up @@ -52,4 +59,10 @@ var _ = Describe(

})
})

err := ibuclusterinfo.SaveClusterInfo(&imagebasedupgradeparams.PostUpgradeClusterInfo)
Expect(err).ToNot(HaveOccurred(), "Failed to save post upgrade cluster info")

ibuvalidations.PostUpgradeValidations()

})
28 changes: 28 additions & 0 deletions tests/imagebasedupgrade/validations/post_ibu_validations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ibuvalidations

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/polarion"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeparams"
)

// PostUpgradeValidations is a dedicated func to run post upgrade test validations.
func PostUpgradeValidations() {
Describe(
"PostIBUValidations",
Label("PostIBUValidations"), func() {
It("Validate Cluster version", polarion.ID("99998"), Label("ValidateClusterVersion"), func() {
By("Validate upgraded cluster version reports correct version", func() {
Expect(imagebasedupgradeparams.PreUpgradeClusterInfo.Version).
ToNot(Equal(imagebasedupgradeparams.PostUpgradeClusterInfo.Version), "Cluster version hasn't changed")
})
})
It("Validate Cluster ID", polarion.ID("99999"), Label("ValidateClusterID"), func() {
By("Validate cluster ID remains the same", func() {
Expect(imagebasedupgradeparams.PreUpgradeClusterInfo.ID).
To(Equal(imagebasedupgradeparams.PostUpgradeClusterInfo.ID), "Cluster ID has changed")
})
})
})
}
Loading