Skip to content

Commit

Permalink
Add additional test for TooManyOperatorGroups
Browse files Browse the repository at this point in the history
There was already one like this when the OperatorGroup was not being
specified in the OperatorPolicy, but this helps keep things complete.

Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
  • Loading branch information
JustinKuli committed Jan 31, 2024
1 parent da47707 commit 421bed9
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion test/e2e/case38_install_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"open-cluster-management.io/config-policy-controller/test/utils"
)

var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, func() {
var _ = FDescribe("Test installing an operator from OperatorPolicy", Ordered, func() {
const (
opPolTestNS = "operator-policy-testns"
parentPolicyYAML = "../resources/case38_operator_install/parent-policy.yaml"
Expand Down Expand Up @@ -213,6 +213,8 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun
incorrectOpGroupName = "incorrect-operator-group"
scopedOpGroupYAML = "../resources/case38_operator_install/scoped-operator-group.yaml"
scopedOpGroupName = "scoped-operator-group"
extraOpGroupYAML = "../resources/case38_operator_install/extra-operator-group.yaml"
extraOpGroupName = "extra-operator-group"
)

BeforeAll(func() {
Expand Down Expand Up @@ -344,6 +346,39 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun
"the OperatorGroup was updated to match the policy",
)
})
It("Should become NonCompliant when an extra OperatorGroup is added", func() {
utils.Kubectl("apply", "-f", extraOpGroupYAML, "-n", opPolTestNS)
check(
opPolName,
true,
[]policyv1.RelatedObject{{
Object: policyv1.ObjectResource{
Kind: "OperatorGroup",
APIVersion: "operators.coreos.com/v1",
},
Compliant: "NonCompliant",
Reason: "There is more than one OperatorGroup in this namespace",
}, {
Object: policyv1.ObjectResource{
Kind: "OperatorGroup",
APIVersion: "operators.coreos.com/v1",
Metadata: policyv1.ObjectMetadata{
Name: extraOpGroupName,
Namespace: opPolTestNS,
},
},
Compliant: "NonCompliant",
Reason: "There is more than one OperatorGroup in this namespace",
}},
metav1.Condition{
Type: "OperatorGroupCompliant",
Status: metav1.ConditionFalse,
Reason: "TooManyOperatorGroups",
Message: "there is more than one OperatorGroup in the namespace",
},
"there is more than one OperatorGroup in the namespace",
)
})
})
Describe("Testing Subscription behavior for musthave mode while enforcing", Ordered, func() {
const (
Expand Down

0 comments on commit 421bed9

Please sign in to comment.