Skip to content

Commit 03400fa

Browse files
committed
OCM-13892 | test: fix ids: 57094,57444,75445,37499 and some negative cases failure as nil pointer of clusterHandler
1 parent 1e9bad7 commit 03400fa

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

tests/e2e/test_rosacli_cluster.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,7 @@ var _ = Describe("HCP cluster creation negative testing",
21162116
command string
21172117
rosalCommand config.Command
21182118
clusterHandler handler.ClusterHandler
2119+
err error
21192120
)
21202121
BeforeEach(func() {
21212122

@@ -2131,7 +2132,7 @@ var _ = Describe("HCP cluster creation negative testing",
21312132
}
21322133
profile = profilesMap[profilesNames[helper.RandomInt(len(profilesNames))]]
21332134
profile.NamePrefix = constants.DefaultNamePrefix
2134-
clusterHandler, err := handler.NewTempClusterHandler(rosaClient, profile)
2135+
clusterHandler, err = handler.NewTempClusterHandler(rosaClient, profile)
21352136
Expect(err).To(BeNil())
21362137

21372138
By("Prepare creation command")

tests/e2e/test_rosacli_upgrade.go

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ var _ = Describe("Cluster Upgrade testing",
4242
const versionTagName = "rosa_openshift_version"
4343

4444
BeforeEach(func() {
45+
46+
arbitraryPoliciesToClean = []string{}
47+
4548
By("Get the cluster")
4649
clusterID = config.GetClusterID()
4750
Expect(clusterID).ToNot(Equal(""), "ClusterID is required. Please export CLUSTER_ID")
@@ -315,15 +318,17 @@ var _ = Describe("Cluster Upgrade testing",
315318

316319
clusterVersionList, err := versionService.ListAndReflectVersions(profile.ChannelGroup, false)
317320
Expect(err).To(BeNil())
318-
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(profile.ChannelGroup, clusterVersion)
321+
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(
322+
profile.ChannelGroup, clusterVersion,
323+
)
319324
Expect(err).To(BeNil())
320325
if upgradingVersion == "" {
321326
Skip("Skip this case as the cluster is being upgraded.")
322327
}
323328

324329
By("Upgrade cluster")
325330
scheduledDate := time.Now().Format("2006-01-02")
326-
scheduledTime := time.Now().Add(10 * time.Minute).UTC().Format("15:04")
331+
scheduledTime := time.Now().Add(200 * time.Minute).UTC().Format("15:04")
327332
output, err := upgradeService.Upgrade(
328333
"-c", clusterID,
329334
"--version", upgradingVersion,
@@ -351,7 +356,9 @@ var _ = Describe("Cluster Upgrade testing",
351356

352357
clusterVersionList, err := versionService.ListAndReflectVersions(profile.ChannelGroup, false)
353358
Expect(err).To(BeNil())
354-
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(profile.ChannelGroup, clusterVersion)
359+
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(
360+
profile.ChannelGroup, clusterVersion,
361+
)
355362
Expect(err).To(BeNil())
356363
if upgradingVersion == "" {
357364
Skip("Skip this case as no available upgrade version.")
@@ -633,7 +640,8 @@ var _ = Describe("Describe/List rosa upgrade",
633640
upgradeService rosacli.UpgradeService
634641
versionService rosacli.VersionService
635642
clusterID string
636-
profile *handler.Profile
643+
clusterConfig *config.ClusterConfig
644+
err error
637645
)
638646

639647
BeforeEach(func() {
@@ -648,11 +656,12 @@ var _ = Describe("Describe/List rosa upgrade",
648656
versionService = rosaClient.Version
649657

650658
By("Load the profile")
651-
profile = handler.LoadProfileYamlFileByENV()
659+
clusterConfig, err = config.ParseClusterProfile()
660+
Expect(err).ToNot(HaveOccurred())
652661
})
653662

654663
AfterEach(func() {
655-
if profile.Version == constants.YStreamPreviousVersion {
664+
if clusterConfig.Version.VersionRequirement == constants.YStreamPreviousVersion {
656665
By("Delete cluster upgrade")
657666
_, err := upgradeService.DeleteUpgrade("-c", clusterID, "-y")
658667
Expect(err).ToNot(HaveOccurred())
@@ -675,15 +684,15 @@ var _ = Describe("Describe/List rosa upgrade",
675684
Expect(output.String()).To(ContainSubstring("--machinepool"))
676685
Expect(output.String()).To(ContainSubstring("-y, --yes"))
677686

678-
if profile.Version == "latest" {
687+
if clusterConfig.Version.VersionRequirement == "latest" {
679688
By("Check list upgrade for the cluster with latest version")
680689
output, err = upgradeService.ListUpgrades("-c", clusterID)
681690
Expect(err).To(BeNil())
682691
Expect(output.String()).To(ContainSubstring("There are no available upgrades for cluster "+
683692
"'%s'", clusterID))
684693
}
685694

686-
if profile.Version == constants.YStreamPreviousVersion {
695+
if clusterConfig.Version.VersionRequirement == constants.YStreamPreviousVersion {
687696
By("Upgrade cluster and check list/describe upgrade")
688697
scheduledDate := time.Now().Format("2006-01-02")
689698
scheduledTime := time.Now().Add(20 * time.Minute).UTC().Format("15:04")
@@ -693,14 +702,18 @@ var _ = Describe("Describe/List rosa upgrade",
693702
clusterVersion := jsonData.DigString("version", "raw_id")
694703

695704
By("Find upper Y stream version")
696-
clusterVersionList, err := versionService.ListAndReflectVersions(profile.ChannelGroup, false)
705+
clusterVersionList, err := versionService.ListAndReflectVersions(
706+
clusterConfig.Version.ChannelGroup, false,
707+
)
697708
Expect(err).To(BeNil())
698-
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(profile.ChannelGroup, clusterVersion)
709+
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(
710+
clusterConfig.Version.ChannelGroup, clusterVersion,
711+
)
699712
Expect(err).To(BeNil())
700713
Expect(upgradingVersion).NotTo(BeEmpty())
701714

702715
By("Upgrade cluster")
703-
if profile.ClusterConfig.STS {
716+
if clusterConfig.Sts {
704717
Expect(err).ToNot(HaveOccurred())
705718

706719
output, errSTSUpgrade := upgradeService.Upgrade(
@@ -746,8 +759,8 @@ var _ = Describe("Describe/List rosa upgrade",
746759
labels.Medium, labels.Runtime.Day2,
747760
func() {
748761
By("Skip testing if the cluster is not a y-1 STS classic cluster")
749-
if profile.Version != constants.YStreamPreviousVersion || !profile.ClusterConfig.STS ||
750-
profile.ClusterConfig.HCP {
762+
if clusterConfig.Version.VersionRequirement != constants.YStreamPreviousVersion || !clusterConfig.Sts ||
763+
clusterConfig.Hypershift {
751764
Skip("Skip this case as the version defined in profile is not y-1 for sts cluster upgrade " +
752765
"testing")
753766
}
@@ -757,9 +770,13 @@ var _ = Describe("Describe/List rosa upgrade",
757770
clusterVersion := jsonData.DigString("version", "raw_id")
758771

759772
By("Find upper Y stream version")
760-
clusterVersionList, err := versionService.ListAndReflectVersions(profile.ChannelGroup, false)
773+
clusterVersionList, err := versionService.ListAndReflectVersions(
774+
clusterConfig.Version.ChannelGroup, false,
775+
)
761776
Expect(err).To(BeNil())
762-
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(profile.ChannelGroup, clusterVersion)
777+
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(
778+
clusterConfig.Version.ChannelGroup, clusterVersion,
779+
)
763780
Expect(err).To(BeNil())
764781
Expect(upgradingVersion).NotTo(BeEmpty())
765782

@@ -1153,7 +1170,9 @@ var _ = Describe("Create cluster upgrade policy validation", labels.Feature.Clus
11531170
By("Find upper Y stream version")
11541171
clusterVersionList, err := versionService.ListAndReflectVersions(profile.ChannelGroup, false)
11551172
Expect(err).To(BeNil())
1156-
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(profile.ChannelGroup, clusterVersion)
1173+
upgradingVersion, _, err := clusterVersionList.FindUpperYStreamVersion(
1174+
profile.ChannelGroup, clusterVersion,
1175+
)
11571176
Expect(err).To(BeNil())
11581177
Expect(upgradingVersion).NotTo(BeEmpty())
11591178

tests/utils/config/cluster.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
)
1111

1212
type Version struct {
13-
ChannelGroup string `json:"channel_group,omitempty"`
14-
RawID string `json:"raw_id,omitempty"`
13+
ChannelGroup string `json:"channel_group,omitempty"`
14+
RawID string `json:"raw_id,omitempty"`
15+
VersionRequirement string `json:"version_requirement,omitempty"`
1516
}
1617

1718
type Encryption struct {

tests/utils/handler/cluster_handler.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
192192
err = fmt.Errorf("cannot find a version match the condition %s", ch.profile.Version)
193193
return flags, err
194194
}
195-
ch.profile.Version = version.Version
195+
// ch.profile.Version = version.Version
196196
flags = append(flags, "--version", version.Version)
197197

198198
ch.clusterConfig.Version = &ClusterConfigure.Version{
199-
ChannelGroup: ch.profile.ChannelGroup,
200-
RawID: version.Version,
199+
ChannelGroup: ch.profile.ChannelGroup,
200+
RawID: version.Version,
201+
VersionRequirement: ch.profile.Version,
201202
}
202203
}
203204
if ch.profile.ChannelGroup != "" {
@@ -249,7 +250,7 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
249250
accRoles, err = resourcesHandler.PrepareAccountRoles(
250251
accountRolePrefix,
251252
ch.profile.ClusterConfig.HCP,
252-
ch.profile.Version,
253+
ch.clusterConfig.Version.RawID,
253254
ch.profile.ChannelGroup,
254255
ch.profile.AccountRoleConfig.Path,
255256
ch.profile.AccountRoleConfig.PermissionBoundary,
@@ -260,7 +261,7 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
260261
accRoles, err = resourcesHandler.PrepareAccountRoles(
261262
accountRolePrefix,
262263
ch.profile.ClusterConfig.HCP,
263-
ch.profile.Version,
264+
ch.clusterConfig.Version.RawID,
264265
ch.profile.ChannelGroup,
265266
ch.profile.AccountRoleConfig.Path,
266267
ch.profile.AccountRoleConfig.PermissionBoundary,

0 commit comments

Comments
 (0)