Skip to content

Commit

Permalink
Merge pull request #58 from mcornea/ibu_validation
Browse files Browse the repository at this point in the history
Add initial ibu post upgrade validations structure
  • Loading branch information
mcornea authored Feb 2, 2024
2 parents 01c784b + 883e499 commit aa93445
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
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")
})
})
})
}

0 comments on commit aa93445

Please sign in to comment.