@@ -1762,13 +1762,15 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
17621762 })
17631763 })
17641764
1765+ // These tests can run in an Ordered container as long as no other tests install the
1766+ // same operator at the same time. These tests will delete and recreate the operator's CRD.
1767+ // The relative order of the inner Describe containers does not matter.
17651768 Describe ("Testing CRD behaviors" , Ordered , func () {
1766- // These tests are wrapped in an Ordered Describe block because they
1767- // delete and recreate the same CRD. The order doesn't matter as long
1768- // as these tests are not run in parallel with each other.
17691769 Describe ("Testing full installation behavior, including CRD reporting" , Ordered , func () {
17701770 const (
1771- opPolYAML = "../resources/case38_operator_install/operator-policy-no-group-one-version.yaml"
1771+ opPolYAML = "../resources/case38_operator_install/operator-policy-no-group-one-version.yaml"
1772+ deploymentName = "apicast-operator-controller-manager-v2"
1773+ crdName = "apicasts.apps.3scale.net"
17721774 )
17731775 var (
17741776 opPolTestNS string
@@ -1782,7 +1784,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
17821784 parentPolicyName = getParentPolicyName ()
17831785
17841786 preFunc ()
1785- KubectlTarget ("delete" , "crd" , "--selector=olm.managed=true " )
1787+ KubectlTarget ("delete" , "crd" , crdName , "--ignore-not-found " )
17861788 setupPolicy (opPolYAML , opPolName , parentPolicyName )
17871789 })
17881790 It ("Should initially not report on CRDs because they won't exist yet" , func () {
@@ -1815,15 +1817,15 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
18151817 By ("Waiting for a CRD to appear, which should indicate the operator is installing" )
18161818 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
18171819 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
1818- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
1820+ crdName , metav1.GetOptions {})
18191821
18201822 return crd
18211823 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
18221824
18231825 By ("Waiting for the Deployment to be available, indicating the installation is complete" )
18241826 Eventually (func (g Gomega ) {
18251827 dep , err := targetK8sDynamic .Resource (gvrDeployment ).Namespace (opPolTestNS ).Get (
1826- ctx , "quay-operator-tng" , metav1.GetOptions {})
1828+ ctx , deploymentName , metav1.GetOptions {})
18271829 g .Expect (err ).NotTo (HaveOccurred ())
18281830 g .Expect (dep ).NotTo (BeNil ())
18291831
@@ -1844,7 +1846,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
18441846 Kind : "CustomResourceDefinition" ,
18451847 APIVersion : "apiextensions.k8s.io/v1" ,
18461848 Metadata : policyv1.ObjectMetadata {
1847- Name : "quayregistries.quay.redhat.com" ,
1849+ Name : crdName ,
18481850 },
18491851 },
18501852 Compliant : "Compliant" ,
@@ -1885,8 +1887,10 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
18851887 Describe ("Testing general OperatorPolicy mustnothave behavior" , Ordered , func () {
18861888 const (
18871889 opPolYAML = "../resources/case38_operator_install/operator-policy-mustnothave.yaml"
1888- subName = "project-quay"
1889- deploymentName = "quay-operator-tng"
1890+ subName = "apicast-community-operator"
1891+ deploymentName = "apicast-operator-controller-manager-v2"
1892+ crdName = "apicasts.apps.3scale.net"
1893+ csvName = "apicast-community-operator.v0.7.1"
18901894 catSrcName = "operatorhubio-catalog"
18911895 catSrcNS = "olm"
18921896 )
@@ -1902,7 +1906,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
19021906 parentPolicyName = getParentPolicyName ()
19031907
19041908 preFunc ()
1905- KubectlTarget ("delete" , "crd" , "--selector=olm.managed=true " )
1909+ KubectlTarget ("delete" , "crd" , crdName , "--ignore-not-found " )
19061910 setupPolicy (opPolYAML , opPolName , parentPolicyName )
19071911 })
19081912
@@ -1939,7 +1943,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
19391943 APIVersion : "operators.coreos.com/v1alpha1" ,
19401944 Metadata : policyv1.ObjectMetadata {
19411945 Namespace : opPolTestNS ,
1942- Name : "project-quay" ,
1946+ Name : subName ,
19431947 },
19441948 },
19451949 Compliant : "Compliant" ,
@@ -2058,7 +2062,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
20582062 By ("Waiting for a CRD to appear, which should indicate the operator is installing" )
20592063 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
20602064 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
2061- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
2065+ crdName , metav1.GetOptions {})
20622066
20632067 return crd
20642068 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -2100,7 +2104,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
21002104 APIVersion : "operators.coreos.com/v1alpha1" ,
21012105 Metadata : policyv1.ObjectMetadata {
21022106 Namespace : opPolTestNS ,
2103- Name : "project-quay" ,
2107+ Name : subName ,
21042108 },
21052109 },
21062110 Compliant : "NonCompliant" ,
@@ -2154,9 +2158,9 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
21542158 Type : "ClusterServiceVersionCompliant" ,
21552159 Status : metav1 .ConditionFalse ,
21562160 Reason : "ClusterServiceVersionPresent" ,
2157- Message : "the ClusterServiceVersion (quay-operator.v3.10.0 ) is present" ,
2161+ Message : "the ClusterServiceVersion (" + csvName + " ) is present" ,
21582162 },
2159- regexp .QuoteMeta ("the ClusterServiceVersion (quay-operator.v3.10.0 ) is present" ),
2163+ regexp .QuoteMeta ("the ClusterServiceVersion (" + csvName + " ) is present" ),
21602164 )
21612165 check (
21622166 opPolName ,
@@ -2166,7 +2170,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
21662170 Kind : "CustomResourceDefinition" ,
21672171 APIVersion : "apiextensions.k8s.io/v1" ,
21682172 Metadata : policyv1.ObjectMetadata {
2169- Name : "quayregistries.quay.redhat.com" ,
2173+ Name : crdName ,
21702174 },
21712175 },
21722176 Compliant : "NonCompliant" ,
@@ -2263,7 +2267,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
22632267 APIVersion : "operators.coreos.com/v1alpha1" ,
22642268 Metadata : policyv1.ObjectMetadata {
22652269 Namespace : opPolTestNS ,
2266- Name : "project-quay" ,
2270+ Name : subName ,
22672271 },
22682272 },
22692273 Reason : "The Subscription is attached to a mustnothave policy, but does not need to be removed" ,
@@ -2306,7 +2310,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
23062310 Kind : "CustomResourceDefinition" ,
23072311 APIVersion : "apiextensions.k8s.io/v1" ,
23082312 Metadata : policyv1.ObjectMetadata {
2309- Name : "quayregistries.quay.redhat.com" ,
2313+ Name : crdName ,
23102314 },
23112315 },
23122316 Reason : "The CustomResourceDefinition is attached to a mustnothave policy, but " +
@@ -2431,11 +2435,11 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
24312435 )
24322436
24332437 By ("Checking that certain (named) resources are still there" )
2434- utils .GetWithTimeout (targetK8sDynamic , gvrClusterServiceVersion , "quay-operator.v3.10.0" ,
2438+ utils .GetWithTimeout (targetK8sDynamic , gvrClusterServiceVersion , csvName ,
24352439 opPolTestNS , true , eventuallyTimeout )
24362440 utils .GetWithTimeout (targetK8sDynamic , gvrSubscription , subName ,
24372441 opPolTestNS , true , eventuallyTimeout )
2438- utils .GetWithTimeout (targetK8sDynamic , gvrCRD , "quayregistries.quay.redhat.com" ,
2442+ utils .GetWithTimeout (targetK8sDynamic , gvrCRD , crdName ,
24392443 "" , true , eventuallyTimeout )
24402444 })
24412445 It ("Should report a special status when the resources are stuck" , func (ctx SpecContext ) {
@@ -2529,7 +2533,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
25292533 APIVersion : "operators.coreos.com/v1alpha1" ,
25302534 Metadata : policyv1.ObjectMetadata {
25312535 Namespace : opPolTestNS ,
2532- Name : "project-quay" ,
2536+ Name : subName ,
25332537 },
25342538 },
25352539 Compliant : "NonCompliant" ,
@@ -2618,11 +2622,11 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
26182622 })
26192623 It ("Should report things as gone after the finalizers are removed" , func () {
26202624 By ("Checking that certain (named) resources are not there, indicating the removal was completed" )
2621- utils .GetWithTimeout (targetK8sDynamic , gvrClusterServiceVersion , "quay-operator.v3.10.0" ,
2625+ utils .GetWithTimeout (targetK8sDynamic , gvrClusterServiceVersion , csvName ,
26222626 opPolTestNS , false , eventuallyTimeout )
26232627 utils .GetWithTimeout (targetK8sDynamic , gvrSubscription , subName ,
26242628 opPolTestNS , false , eventuallyTimeout )
2625- utils .GetWithTimeout (targetK8sDynamic , gvrCRD , "quayregistries.quay.redhat.com" ,
2629+ utils .GetWithTimeout (targetK8sDynamic , gvrCRD , crdName ,
26262630 "" , false , eventuallyTimeout )
26272631
26282632 By ("Checking the OperatorPolicy status" )
@@ -2658,7 +2662,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
26582662 APIVersion : "operators.coreos.com/v1alpha1" ,
26592663 Metadata : policyv1.ObjectMetadata {
26602664 Namespace : opPolTestNS ,
2661- Name : "project-quay" ,
2665+ Name : subName ,
26622666 },
26632667 },
26642668 Compliant : "Compliant" ,
@@ -2716,7 +2720,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
27162720 Reason : "ClusterServiceVersionNotPresent" ,
27172721 Message : "the ClusterServiceVersion is not present" ,
27182722 },
2719- regexp .QuoteMeta ("the ClusterServiceVersion (quay-operator.v3.10.0 ) was deleted" ),
2723+ regexp .QuoteMeta ("the ClusterServiceVersion (" + csvName + " ) was deleted" ),
27202724 )
27212725 check (
27222726 opPolName ,
@@ -2794,8 +2798,9 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
27942798
27952799 Describe ("Test CRD deletion delayed because of a finalizer" , Ordered , func () {
27962800 const (
2797- opPolYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version.yaml"
2798- subName = "project-quay"
2801+ opPolYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version-apicast.yaml"
2802+ subName = "apicast-community-operator"
2803+ crdName = "apicasts.apps.3scale.net"
27992804 )
28002805 var (
28012806 opPolName string
@@ -2807,18 +2812,18 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28072812 parentPolicyName = getParentPolicyName ()
28082813
28092814 preFunc ()
2810- KubectlTarget ("delete" , "crd" , "--selector=olm.managed=true " )
2815+ KubectlTarget ("delete" , "crd" , crdName , "--ignore-not-found " )
28112816 setupPolicy (opPolYAML , opPolName , parentPolicyName )
28122817 })
28132818 AfterAll (func (ctx SpecContext ) {
28142819 crd , err := targetK8sDynamic .Resource (gvrCRD ).Get (
2815- ctx , "quayregistries.quay.redhat.com" , metav1.GetOptions {})
2820+ ctx , crdName , metav1.GetOptions {})
28162821 if k8serrors .IsNotFound (err ) {
28172822 return
28182823 }
28192824 Expect (crd ).NotTo (BeNil ())
28202825
2821- KubectlTarget ("patch" , "crd" , "quayregistries.quay.redhat.com" , "--type=json" , "-p" ,
2826+ KubectlTarget ("patch" , "crd" , crdName , "--type=json" , "-p" ,
28222827 `[{"op": "remove", "path": "/metadata/finalizers"}]` )
28232828 })
28242829 It ("Initially behaves correctly as musthave" , func (ctx SpecContext ) {
@@ -2830,7 +2835,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28302835 By ("Waiting for a CRD to appear, which should indicate the operator is installing" )
28312836 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
28322837 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
2833- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
2838+ crdName , metav1.GetOptions {})
28342839
28352840 return crd
28362841 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -2845,7 +2850,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28452850 Kind : "CustomResourceDefinition" ,
28462851 APIVersion : "apiextensions.k8s.io/v1" ,
28472852 Metadata : policyv1.ObjectMetadata {
2848- Name : "quayregistries.quay.redhat.com" ,
2853+ Name : crdName ,
28492854 },
28502855 },
28512856 Compliant : "Compliant" ,
@@ -2861,7 +2866,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28612866 )
28622867
28632868 By ("Adding a finalizer to the CRD" )
2864- KubectlTarget ("patch" , "crd" , "quayregistries.quay.redhat.com" , "--type=json" , "-p" ,
2869+ KubectlTarget ("patch" , "crd" , crdName , "--type=json" , "-p" ,
28652870 `[{"op": "add", "path": "/metadata/finalizers", "value": ["donutdelete"]}]` )
28662871 // cleanup for this is handled in an AfterAll
28672872 })
@@ -2878,7 +2883,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28782883 Kind : "CustomResourceDefinition" ,
28792884 APIVersion : "apiextensions.k8s.io/v1" ,
28802885 Metadata : policyv1.ObjectMetadata {
2881- Name : "quayregistries.quay.redhat.com" ,
2886+ Name : crdName ,
28822887 },
28832888 },
28842889 Compliant : "NonCompliant" ,
@@ -2894,7 +2899,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
28942899 )
28952900 })
28962901 It ("Should become compliant after the finalizer is removed" , func () {
2897- KubectlTarget ("patch" , "crd" , "quayregistries.quay.redhat.com" , "--type=json" , "-p" ,
2902+ KubectlTarget ("patch" , "crd" , crdName , "--type=json" , "-p" ,
28982903 `[{"op": "remove", "path": "/metadata/finalizers"}]` )
28992904
29002905 check (
@@ -2926,9 +2931,10 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
29262931
29272932 Describe ("Testing mustnothave behavior of operator groups in DeleteIfUnused mode" , Ordered , func () {
29282933 const (
2929- opPolYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version.yaml"
2934+ opPolYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version-apicast .yaml"
29302935 otherYAML = "../resources/case38_operator_install/operator-policy-authorino.yaml"
2931- subName = "project-quay"
2936+ subName = "apicast-community-operator"
2937+ crdName = "apicasts.apps.3scale.net"
29322938 )
29332939 var (
29342940 opPolTestNS string
@@ -2940,12 +2946,12 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
29402946 BeforeEach (func () {
29412947 testSuffix := getTestSuffix ()
29422948 opPolTestNS = getOpPolTestNS ()
2943- opPolName = "oppol-mustnothave" + testSuffix
2949+ opPolName = "oppol-mustnothave-apicast " + testSuffix
29442950 otherOpPolName = "oppol-authorino" + testSuffix
29452951 parentPolicyName = getParentPolicyName ()
29462952
29472953 preFunc ()
2948- KubectlTarget ("delete" , "crd" , "--selector=olm.managed=true " )
2954+ KubectlTarget ("delete" , "crd" , crdName , "--ignore-not-found " )
29492955 setupPolicy (opPolYAML , opPolName , parentPolicyName )
29502956 })
29512957
@@ -2959,7 +2965,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
29592965 By ("Waiting for a CRD to appear, which should indicate the operator is installing." )
29602966 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
29612967 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
2962- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
2968+ crdName , metav1.GetOptions {})
29632969
29642970 return crd
29652971 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -3002,7 +3008,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
30023008 By ("Waiting for a CRD to appear, which should indicate the operator is installing." )
30033009 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
30043010 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
3005- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
3011+ crdName , metav1.GetOptions {})
30063012
30073013 return crd
30083014 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -3045,7 +3051,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
30453051 By ("Waiting for a CRD to appear, which should indicate the operator is installing." )
30463052 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
30473053 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
3048- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
3054+ crdName , metav1.GetOptions {})
30493055
30503056 return crd
30513057 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -3098,7 +3104,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
30983104 By ("Waiting for a CRD to appear, which should indicate the operator is installing." )
30993105 Eventually (func (ctx SpecContext ) * unstructured.Unstructured {
31003106 crd , _ := targetK8sDynamic .Resource (gvrCRD ).Get (ctx ,
3101- "quayregistries.quay.redhat.com" , metav1.GetOptions {})
3107+ crdName , metav1.GetOptions {})
31023108
31033109 return crd
31043110 }, olmWaitTimeout , 5 , ctx ).ShouldNot (BeNil ())
@@ -3303,7 +3309,7 @@ var _ = Describe("Testing OperatorPolicy", Label("supports-hosted"), func() {
33033309 Describe ("Testing operator policies that specify the same subscription" , Serial , Ordered , func () {
33043310 const (
33053311 musthaveYAML = "../resources/case38_operator_install/operator-policy-no-group.yaml"
3306- mustnothaveYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version.yaml"
3312+ mustnothaveYAML = "../resources/case38_operator_install/operator-policy-mustnothave-any-version-quay .yaml"
33073313 )
33083314 var (
33093315 musthaveName string
0 commit comments