Skip to content

Commit 87ffb7a

Browse files
Merge pull request #2864 from yuwang-RH/new0411
OCM-15192 | test: automate id:81399 edit cluster channel group
2 parents 9f45f40 + 62d9f28 commit 87ffb7a

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/e2e/test_rosacli_cluster.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,78 @@ var _ = Describe("Edit cluster",
6060
By("Clean the cluster")
6161
rosaClient.CleanResources(clusterID)
6262
})
63+
It("can edit cluster channel group - [id:81399]",
64+
labels.Medium, labels.Runtime.Day2,
65+
func() {
66+
const STABLE_CHANNEL = "stable"
67+
const CANDIDATE_CHANNEL = "candidate"
68+
By("Check help message contains channel-group flag")
69+
output, err := clusterService.EditCluster("", "-h")
70+
Expect(err).To(BeNil())
71+
Expect(output.String()).To(ContainSubstring("--channel-group"))
72+
73+
By("Get original version and channel group")
74+
output, err = clusterService.DescribeCluster(clusterID)
75+
Expect(err).To(BeNil())
76+
CD, err := clusterService.ReflectClusterDescription(output)
77+
Expect(err).To(BeNil())
78+
originalVersion := CD.OpenshiftVersion
79+
originalChannelGroup := CD.ChannelGroup
6380

81+
By("Check if there is version in updating channel group")
82+
var upgradingChannelGroup string
83+
existingAvailabelVersion := false
84+
if originalChannelGroup == STABLE_CHANNEL {
85+
upgradingChannelGroup = CANDIDATE_CHANNEL
86+
} else {
87+
upgradingChannelGroup = STABLE_CHANNEL
88+
}
89+
versionService := rosaClient.Version
90+
hostedCP, err := clusterService.IsHostedCPCluster(clusterID)
91+
Expect(err).To(BeNil())
92+
versionList, err := versionService.ListAndReflectJsonVersions(upgradingChannelGroup, hostedCP)
93+
Expect(err).To(BeNil())
94+
for _, version := range versionList {
95+
if version.RAWID == originalVersion {
96+
existingAvailabelVersion = true
97+
break
98+
}
99+
continue
100+
}
101+
102+
By("Edit cluster with channel group")
103+
out, err := clusterService.EditCluster(
104+
clusterID,
105+
"--channel-group", upgradingChannelGroup,
106+
"-y",
107+
)
108+
defer func() {
109+
By("Recover the original channel group")
110+
_, err = clusterService.EditCluster(
111+
clusterID,
112+
"--channel-group", originalChannelGroup,
113+
"-y",
114+
)
115+
Expect(err).To(BeNil())
116+
}()
117+
118+
if existingAvailabelVersion {
119+
Expect(err).To(BeNil())
120+
Expect(out.String()).To(ContainSubstring("Updated cluster"))
121+
} else {
122+
Expect(err).ToNot(BeNil())
123+
Expect(out.String()).To(ContainSubstring("is not available for the desired channel group"))
124+
}
125+
126+
By("Edit cluster with the channel group which has no available version")
127+
out, err = clusterService.EditCluster(
128+
clusterID,
129+
"--channel-group", "fakecg",
130+
"-y",
131+
)
132+
Expect(err).ToNot(BeNil())
133+
Expect(out.String()).To(ContainSubstring("is not available for the desired channel group"))
134+
})
64135
It("can check the description of the cluster - [id:34102]",
65136
labels.Medium, labels.Runtime.Day2,
66137
func() {

0 commit comments

Comments
 (0)