Skip to content

Commit

Permalink
Add IBU CSVs and seed node name valiation (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornea committed Feb 6, 2024
1 parent 2476b64 commit 8bf0dfe
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/onsi/ginkgo/v2 v2.13.2
github.com/onsi/gomega v1.30.0
github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20231216054307-28180628cf50
github.com/openshift-kni/eco-goinfra v0.0.0-20240130190254-d596dffca78d
github.com/openshift-kni/eco-goinfra v0.0.0-20240202154232-b24741524946
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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20231216054307-28180628cf50 h1:0Lw0f9ncgoXKo1JnQrEo4fGqYelTV+5huXzJvziDG9E=
github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20231216054307-28180628cf50/go.mod h1:vfydLuqf4QsLXI5busOIjbuvvURuE0oeLCwjvXj34Mo=
github.com/openshift-kni/eco-goinfra v0.0.0-20240130190254-d596dffca78d h1:M7mcdYdivMffoG+texuZ6cssVTuwfOHbpEnAc5iYi8U=
github.com/openshift-kni/eco-goinfra v0.0.0-20240130190254-d596dffca78d/go.mod h1:Fi2MRjD91qHEMk2YgXmTLSP+IBiWJBkGO9ARY9wx6S8=
github.com/openshift-kni/eco-goinfra v0.0.0-20240202154232-b24741524946 h1:De0RCgNi33Tw0ybdu0sBGLGNtXO2izBmwamDIFbabh4=
github.com/openshift-kni/eco-goinfra v0.0.0-20240202154232-b24741524946/go.mod h1:Fi2MRjD91qHEMk2YgXmTLSP+IBiWJBkGO9ARY9wx6S8=
github.com/openshift-kni/k8sreporter v1.0.5 h1:1GYBc/BTZyVoXilHef43v9A8BSzw700zAPZ6zsZvo6Y=
github.com/openshift-kni/k8sreporter v1.0.5/go.mod h1:fg8HI9yxiKAi6UzR6NTtrmQmA2WKzUqmkRUHwQ1+Bj8=
github.com/openshift-kni/lifecycle-agent v0.0.0-20240109211418-4489c4a1eb46 h1:I6ZcMvy98fAzd/5IySrli8inlMuUFfS0+LE57ln8lqs=
Expand Down
45 changes: 43 additions & 2 deletions tests/imagebasedupgrade/internal/ibuclusterinfo/ibuclusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ package ibuclusterinfo

import (
"github.com/golang/glog"
"github.com/openshift-kni/eco-goinfra/pkg/nodes"
"github.com/openshift-kni/eco-goinfra/pkg/olm"
. "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"
)

// itemInArray is a dedicated func to check if an item is in an array.
func itemInArray(item string, array []string) bool {
for _, v := range array {
if v == item {
return true
}
}

return false
}

// SaveClusterInfo is a dedicated func to save cluster info.
func SaveClusterInfo(upgradeVar *imagebasedupgradeparams.ClusterStruct) error {
clusterVersion, err := cluster.GetClusterVersion(TargetSNOAPIClient)
Expand All @@ -25,9 +38,37 @@ func SaveClusterInfo(upgradeVar *imagebasedupgradeparams.ClusterStruct) error {
return err
}

csvList, err := olm.ListClusterServiceVersionInAllNamespaces(TargetSNOAPIClient)

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

return err
}

var installedCSV []string

for _, csv := range csvList {
if itemInArray(csv.Object.Name, installedCSV) {
// Do nothing
} else {
installedCSV = append(installedCSV, csv.Object.Name)
}
}

node, err := nodes.List(TargetSNOAPIClient)

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

return err
}

*upgradeVar = imagebasedupgradeparams.ClusterStruct{
Version: clusterVersion,
ID: clusterID,
Version: clusterVersion,
ID: clusterID,
Operators: installedCSV,
NodeName: node[0].Object.Name,
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package imagebasedupgradeparams

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

var (
Expand Down
28 changes: 28 additions & 0 deletions tests/imagebasedupgrade/validations/post_ibu_validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,54 @@ package ibuvalidations
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/pod"
"github.com/openshift-kni/eco-goinfra/pkg/polarion"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

. "github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeinittools"
"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",
Ordered,
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")
})
})

It("Validate CSV versions", polarion.ID("99999"), Label("ValidateCSV"), func() {
By("Validate CSVs were upgraded", func() {
for _, preUpgradeOperator := range imagebasedupgradeparams.PreUpgradeClusterInfo.Operators {
for _, postUpgradeOperator := range imagebasedupgradeparams.PostUpgradeClusterInfo.Operators {
Expect(preUpgradeOperator).ToNot(Equal(postUpgradeOperator), "Operator %s was not upgraded", preUpgradeOperator)
}
}
})
})

It("Validate no pods using seed name", polarion.ID("99999"), Label("ValidatePodsSeedName"), func() {
By("Validate no pods are using seed's name", func() {
podList, err := pod.ListInAllNamespaces(TargetSNOAPIClient, v1.ListOptions{})
Expect(err).ToNot(HaveOccurred(), "Failed to list pods")

for _, pod := range podList {
Expect(pod.Object.Name).ToNot(ContainSubstring(imagebasedupgradeparams.PreUpgradeClusterInfo.NodeName),
"Pod %s is using seed's name", pod.Object.Name)
}
})
})
})
}
42 changes: 42 additions & 0 deletions vendor/github.com/openshift-kni/eco-goinfra/pkg/deployment/list.go

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

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

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ github.com/onsi/gomega/types
## explicit; go 1.20
github.com/openshift-kni/cluster-group-upgrades-operator/pkg/api/clustergroupupgrades
github.com/openshift-kni/cluster-group-upgrades-operator/pkg/api/clustergroupupgrades/v1alpha1
# github.com/openshift-kni/eco-goinfra v0.0.0-20240130190254-d596dffca78d
# github.com/openshift-kni/eco-goinfra v0.0.0-20240202154232-b24741524946
## explicit; go 1.20
github.com/openshift-kni/eco-goinfra/pkg/argocd
github.com/openshift-kni/eco-goinfra/pkg/argocd/argocdtypes
Expand Down

0 comments on commit 8bf0dfe

Please sign in to comment.