Skip to content

Commit

Permalink
Add initial ibu post upgrade validations structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornea committed Jan 30, 2024
1 parent 74a18d2 commit ba1c2f1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/openshift-kni/eco-goinfra v0.0.0-20240119165249-4757abb333e9
github.com/openshift-kni/k8sreporter v1.0.5
github.com/openshift/cluster-node-tuning-operator v0.0.0-20231225123609-e63d2c9626fe
github.com/openshift/machine-config-operator v0.0.1-0.20230807154212-886c5c3fc7a9
gonum.org/v1/gonum v0.14.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.28.4
Expand Down Expand Up @@ -118,7 +119,6 @@ require (
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a // indirect
github.com/openshift/library-go v0.0.0-20231027143522-b8cd45d2d2c8 // indirect
github.com/openshift/local-storage-operator v0.0.0-20231220121151-4e580bd14c46 // indirect
github.com/openshift/machine-config-operator v0.0.1-0.20230807154212-886c5c3fc7a9 // indirect
github.com/openshift/ptp-operator v0.0.0-20231220185604-29113b41981b // indirect
github.com/operator-framework/api v0.20.0 // indirect
github.com/operator-framework/operator-lifecycle-manager v0.26.0 // indirect
Expand Down
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("99999"), Label("ValidateClusterID"), func() {
By("Validate cluster ID remains the same", 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")
})
})
})
}
2 changes: 0 additions & 2 deletions vendor/github.com/openshift-kni/eco-goinfra/pkg/mco/mcp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba1c2f1

Please sign in to comment.