Skip to content

Commit

Permalink
OCM-7993 | test: Automated id:38835 List/Edit the default ingress on …
Browse files Browse the repository at this point in the history
…ROSA cluster via rosa-cli will succeed
  • Loading branch information
xueli181114 committed May 15, 2024
1 parent 80509ae commit ad25d95
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
56 changes: 55 additions & 1 deletion tests/e2e/test_rosacli_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "github.com/onsi/gomega"

"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/config"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
)
Expand Down Expand Up @@ -174,7 +175,7 @@ var _ = Describe("Edit default ingress",
ingress, _ = defaultIngress(*ingressList)
Expect(ingress.LBType).Should(ContainSubstring("classic"))
})
It("Update Ingress Controller attributes [id:65799]",
It("can update ingress controller attributes - [id:65799]",
labels.Critical,
labels.Day2,
labels.NonHCPCluster,
Expand Down Expand Up @@ -219,4 +220,57 @@ var _ = Describe("Edit default ingress",
Expect(ingress.NamespaceOwnershipPolicy).Should(ContainSubstring("Strict"))
Expect(ingress.WildcardPolicy).Should(ContainSubstring("WildcardsDisallowed"))
})
It("can change labels and private - [id:38835]",
labels.Critical,
labels.Day2,
labels.NonHCPCluster,
func() {
By("Record ingress default value")
output, err := rosaClient.Ingress.ListIngress(clusterID)
Expect(err).ToNot(HaveOccurred())
ingressList, err := rosaClient.Ingress.ReflectIngressList(output)
Expect(err).ToNot(HaveOccurred())
defaultIngress := ingressList.Ingresses[0]
originalPrivate := defaultIngress.Private == "yes"
originalRouteSelectors := defaultIngress.RouteSelectors

By("Check edit ingress help message")
output, err = rosaClient.Ingress.EditIngress(clusterID, "-h")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("--label-match string"))

By("Edit ingress with --label-match and --private")
labelMatch := "label-38835=label-value-38835,label-38835-2=label-value-38835-2"
output, err = rosaClient.Ingress.EditIngress(clusterID,
"apps",
"--label-match", labelMatch,
fmt.Sprintf("--private=%v", !originalPrivate),
"-y",
)
Expect(err).ToNot(HaveOccurred())
defer rosaClient.Ingress.EditIngress(clusterID,
"apps",
"--label-match", common.ReplaceCommaSpaceWithComma(originalRouteSelectors),
fmt.Sprintf("--private=%v", originalPrivate),
"-y",
)

By("List ingress to check")
output, err = rosaClient.Ingress.ListIngress(clusterID)
Expect(err).ToNot(HaveOccurred())
ingressList, err = rosaClient.Ingress.ReflectIngressList(output)
Expect(err).ToNot(HaveOccurred())

defaultIngress = ingressList.Ingresses[0]
Expect(defaultIngress.Private == "yes").To(Equal(!originalPrivate))

ingressRouteSelectors := common.ParseCommaSeparatedStrings(defaultIngress.RouteSelectors)
expectedRouteSelectors := common.ParseCommaSeparatedStrings(labelMatch)

Expect(len(ingressRouteSelectors)).To(Equal(len(expectedRouteSelectors)))

for _, expectLabel := range expectedRouteSelectors {
Expect(expectLabel).To(BeElementOf(ingressRouteSelectors))
}
})
})
4 changes: 4 additions & 0 deletions tests/utils/common/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ func ReplaceCommaWithCommaSpace(sourceValue string) string {
splited := ParseCommaSeparatedStrings(sourceValue)
return strings.Join(splited, ", ")
}
func ReplaceCommaSpaceWithComma(sourceValue string) string {
splited := ParseCommaSeparatedStrings(sourceValue)
return strings.Join(splited, ",")
}

0 comments on commit ad25d95

Please sign in to comment.