Skip to content

Commit

Permalink
Merge pull request #54 from mpmaruthu/ibu-testauto-basic
Browse files Browse the repository at this point in the history
enabling lca pkg usage and defining ginkgo structure
  • Loading branch information
mcornea authored Jan 30, 2024
2 parents 594bb86 + 2e97b37 commit 74a18d2
Show file tree
Hide file tree
Showing 19 changed files with 1,633 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters-settings:
- github.com/onsi/ginkgo/v2
- github.com/openshift-kni/eco-gosystem/tests/internal/inittools
- github.com/openshift-kni/eco-gosystem/tests/ran-du/internal/randuinittools
- github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeinittools
# Select the Go version to target. The default is '1.13'.
go: "1.19"
# https://staticcheck.io/docs/options#checks
Expand Down Expand Up @@ -117,6 +118,10 @@ issues:
linters:
- gochecknoinits

- path: 'tests/imagebasedupgrade/internal/imagebasedupgradeinittools'
linters:
- gochecknoinits

- path: "tests/.*/tests/.*"
linters:
- depguard
Expand Down
5 changes: 3 additions & 2 deletions 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-20240109203119-975bf2617254
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
gonum.org/v1/gonum v0.14.0
Expand Down Expand Up @@ -108,14 +108,15 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nmstate/kubernetes-nmstate/api v0.0.0-20231116153922-80c6e01df02e // indirect
github.com/openshift-kni/lifecycle-agent v0.0.0-20240109211418-4489c4a1eb46 // indirect
github.com/openshift/api v3.9.1-0.20190916204813-cdbe64fb0c91+incompatible // indirect
github.com/openshift/assisted-service/api v0.0.0 // indirect
github.com/openshift/assisted-service/models v0.0.0 // indirect
github.com/openshift/client-go v0.0.1 // indirect
github.com/openshift/cluster-nfd-operator v0.0.0-20231206145954-f49a827bf617 // indirect
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 // indirect
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a // indirect
github.com/openshift/library-go v0.0.0-20231020125025-211b32f1a1f2 // 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
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,12 @@ 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-20240109203119-975bf2617254 h1:RF35GGZ0Y7bQRClgtHq0a9/X03mIOvBB2hPJrWQjOMI=
github.com/openshift-kni/eco-goinfra v0.0.0-20240109203119-975bf2617254/go.mod h1:glATkU/NliNAZZTGgFwY0rTJhrcHnXE+jjAjgQAKoNQ=
github.com/openshift-kni/eco-goinfra v0.0.0-20240119165249-4757abb333e9 h1:0WaeqNRsT7zMpGDwAlThZ6K5it7ipXAphC+/WQ8w6UQ=
github.com/openshift-kni/eco-goinfra v0.0.0-20240119165249-4757abb333e9/go.mod h1:/3PLkMxhTHtSp10aD0jD72tXgngD6x8WPWoZdlaEpmc=
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=
github.com/openshift-kni/lifecycle-agent v0.0.0-20240109211418-4489c4a1eb46/go.mod h1:+7AXvmYXtR4+UjvoMDeeRt4MrV32YK0uUHtHhEPn8MQ=
github.com/openshift/api v0.0.0-20231115210901-4c4a0a24f2fc h1:VCR7TBU90EPmz1fjW1sqdVVpe5GmOHyJTTyQ5XmnmtE=
github.com/openshift/api v0.0.0-20231115210901-4c4a0a24f2fc/go.mod h1:yimSGmjsI+XF1mr+AKBs2//fSXIOhhetHGbMlBEfXbs=
github.com/openshift/assisted-service/api v0.0.0-20230907160625-4e1a1e59cef0 h1:JRsvPEsCDGSQxLGU0faqNjVXXyruURLb3mc4F8YstRw=
Expand All @@ -1187,8 +1189,8 @@ github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87/go.mod h1:DB/Mf2oTeiAmVVX1gN+NEqweonAPY0TKUwADizj8+ZA=
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a h1:E+XPJs/aVvYsrlJzo2ED38ZTR2RTNUlFMmOaFAAdMZg=
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a/go.mod h1:E1bgquRiwfugdArdecPbpYIrAdve5kTzMaJb0+8jMXI=
github.com/openshift/library-go v0.0.0-20231020125025-211b32f1a1f2 h1:TWG/YVRhSvjYq8iIwJ2Wpoopgg0zuh+ZAl1RSm4J8Z0=
github.com/openshift/library-go v0.0.0-20231020125025-211b32f1a1f2/go.mod h1:ZFwNwC3opc/7aOvzUbU95zp33Lbxet48h80ryH3p6DY=
github.com/openshift/library-go v0.0.0-20231027143522-b8cd45d2d2c8 h1:5t2pHTyvfpy5xcKrLCj+6OITwIRdyH1CNG8Ob3vVJvc=
github.com/openshift/library-go v0.0.0-20231027143522-b8cd45d2d2c8/go.mod h1:8UzmrBMCn7+GzouL8DVYkL9COBQTB1Ggd13/mHJQCUg=
github.com/openshift/local-storage-operator v0.0.0-20231220121151-4e580bd14c46 h1:ltEp1+e1U18KCi8E+879li1FHCC+Wz/kNUPX3Y2o95o=
github.com/openshift/local-storage-operator v0.0.0-20231220121151-4e580bd14c46/go.mod h1:14iQ/wwY3MTQRMHe04Lvx8Zhbh7ESJSRsN40coqDRw8=
github.com/openshift/machine-config-operator v0.0.1-0.20230807154212-886c5c3fc7a9 h1:lEH5TQGyDjnJZocsI4FE0BcWKkKtqW3OOsBkRvGd9Rs=
Expand Down
14 changes: 14 additions & 0 deletions tests/imagebasedupgrade/imagebasedupgrade_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package imagebasedupgrade_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
_ "github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/tests"
)

func TestImageBasedUpgrade(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ImageBasedUpgrade Suite")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package imagebasedupgradeinittools

import (
"os"

"github.com/golang/glog"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeparams"
"github.com/openshift-kni/eco-gosystem/tests/internal/inittools"
)

var (
// SeedHubAPIClient is the api client to the hub cluster.
SeedHubAPIClient *clients.Settings
// TargetHubAPIClient is the api client to the hub cluster.
TargetHubAPIClient *clients.Settings
// SeedSNOAPIClient is the api client to the seed SNO cluster.
SeedSNOAPIClient *clients.Settings
// TargetSNOAPIClient is the api client to the target SNO cluster.
TargetSNOAPIClient *clients.Settings
)

// init loads all variables automatically when this package is imported. Once package is imported a user has full
// access to all vars within init function. It is recommended to import this package using dot import.
func init() {
SeedHubAPIClient = inittools.APIClient
TargetHubAPIClient = inittools.APIClient
SeedSNOAPIClient = DefineAPIClient(imagebasedupgradeparams.SeedSNOKubeEnvKey)
TargetSNOAPIClient = DefineAPIClient(imagebasedupgradeparams.TargetSNOKubeEnvKey)
}

// DefineAPIClient creates new api client instance connected to given cluster.
func DefineAPIClient(kubeconfigEnvVar string) *clients.Settings {
kubeFilePath, present := os.LookupEnv(kubeconfigEnvVar)
if !present {
glog.Fatalf("can not load api client. Please check %s env var", kubeconfigEnvVar)

return nil
}

client := clients.New(kubeFilePath)
if client == nil {
glog.Fatalf("client is not set please check %s env variable", kubeconfigEnvVar)

return nil
}

return client
}
16 changes: 16 additions & 0 deletions tests/imagebasedupgrade/internal/imagebasedupgradeparams/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package imagebasedupgradeparams

const (
// SeedHubKubeEnvKey is the hub's kubeconfig env var.
SeedHubKubeEnvKey string = "KUBECONFIG_SEED_HUB"
// TargetHubKubeEnvKey is the hub's kubeconfig env var.
TargetHubKubeEnvKey string = "KUBECONFIG_TARGET_HUB"
// SeedSNOKubeEnvKey is the seed kubeconfig env var.
SeedSNOKubeEnvKey string = "KUBECONFIG_SEED_SNO"
// TargetSNOKubeEnvKey is the target kubeconfig env var.
TargetSNOKubeEnvKey string = "KUBECONFIG_TARGET_SNO"
// ImagebasedupgradeCrName is the Imagebasedupgrade CR name.
ImagebasedupgradeCrName string = "upgrade"
// ImagebasedupgradeCrNamespace is the Imagebasedupgrade CR namespace.
ImagebasedupgradeCrNamespace string = "openshift-lifecycle-agent"
)
55 changes: 55 additions & 0 deletions tests/imagebasedupgrade/tests/happy-path-upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package tests

import (
. "github.com/onsi/ginkgo/v2"
. "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/imagebasedupgradeinittools"
"github.com/openshift-kni/eco-gosystem/tests/imagebasedupgrade/internal/imagebasedupgradeparams"
)

// IbuCr is a dedicated var to use and act on it.
var IbuCr = lca.NewImageBasedUpgradeBuilder(
imagebasedupgradeinittools.TargetSNOAPIClient, imagebasedupgradeparams.ImagebasedupgradeCrName)

var _ = Describe(
"HappyPathUpgrade",
Ordered,
ContinueOnFailure,
Label("HappyPathUpgrade"), func() {
BeforeAll(func() {
By("Generating seed image", func() {
// Test Automation Code Implementation is to be done.
})
})

AfterAll(func() {
// Rollback to pre-upgrade state and reset PolicyGenTemplate.
})

It("End to end upgrade happy path", polarion.ID("68954"), Label("HappyPathUpgrade"), func() {

By("Checking ImageBasedUpgrade CR exists with Idle stage in Target SNO", func() {
crExists := IbuCr.Exists()
Expect(crExists).To(BeTrue())
})

By("Updating ImageBasedUpgrade CR with Prep stage in Target SNO", func() {
IbuCr.WithStage("Prep")
})

By("Updating ImageBasedUpgrade CR with Upgrade stage in Target SNO", func() {
IbuCr.WithStage("Upgrade")
})

By(" Verifying target SNO cluster ACM registration post upgrade", func() {

})

By("Updating ImageBasedUpgrade CR with Idle stage in Target SNO", func() {
IbuCr.WithStage("Idle")

})
})
})
10 changes: 10 additions & 0 deletions vendor/github.com/openshift-kni/eco-goinfra/pkg/clients/clients.go

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

Loading

0 comments on commit 74a18d2

Please sign in to comment.