Skip to content

Commit

Permalink
Merge branch 'main' into con_talm
Browse files Browse the repository at this point in the history
  • Loading branch information
shaior authored Jan 31, 2024
2 parents 74a4b2a + 74a18d2 commit af3c3d1
Show file tree
Hide file tree
Showing 8 changed files with 787 additions and 0 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
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")

})
})
})
Loading

0 comments on commit af3c3d1

Please sign in to comment.