|
8 | 8 | appsv1 "k8s.io/api/apps/v1"
|
9 | 9 | corev1 "k8s.io/api/core/v1"
|
10 | 10 | rbacv1 "k8s.io/api/rbac/v1"
|
| 11 | + k8serrors "k8s.io/apimachinery/pkg/api/errors" |
11 | 12 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
12 | 13 | "k8s.io/apimachinery/pkg/types"
|
13 | 14 | "k8s.io/apiserver/pkg/storage/names"
|
@@ -99,6 +100,57 @@ var _ = Describe("The OperatorConditionsGenerator Controller", func() {
|
99 | 100 | }, timeout, interval).Should(Succeed())
|
100 | 101 | })
|
101 | 102 |
|
| 103 | + It("does not create an OperatorCondition for a Copied CSV", func() { |
| 104 | + depName := genName("dep-") |
| 105 | + csv := &operatorsv1alpha1.ClusterServiceVersion{ |
| 106 | + TypeMeta: metav1.TypeMeta{ |
| 107 | + Kind: operatorsv1alpha1.ClusterServiceVersionKind, |
| 108 | + APIVersion: operatorsv1alpha1.ClusterServiceVersionAPIVersion, |
| 109 | + }, |
| 110 | + ObjectMeta: metav1.ObjectMeta{ |
| 111 | + Name: genName("csv-"), |
| 112 | + Namespace: namespace, |
| 113 | + Labels: map[string]string{ |
| 114 | + operatorsv1alpha1.CopiedLabelKey: "", |
| 115 | + }, |
| 116 | + }, |
| 117 | + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ |
| 118 | + InstallModes: []operatorsv1alpha1.InstallMode{ |
| 119 | + { |
| 120 | + Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, |
| 121 | + Supported: true, |
| 122 | + }, |
| 123 | + { |
| 124 | + Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, |
| 125 | + Supported: true, |
| 126 | + }, |
| 127 | + { |
| 128 | + Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, |
| 129 | + Supported: true, |
| 130 | + }, |
| 131 | + { |
| 132 | + Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, |
| 133 | + Supported: true, |
| 134 | + }, |
| 135 | + }, |
| 136 | + InstallStrategy: newNginxInstallStrategy(depName, nil, nil), |
| 137 | + }, |
| 138 | + } |
| 139 | + |
| 140 | + Expect(k8sClient.Create(ctx, csv)).To(Succeed()) |
| 141 | + namespacedName := types.NamespacedName{Name: csv.GetName(), Namespace: csv.GetNamespace()} |
| 142 | + operatorCondition := &operatorsv1.OperatorCondition{} |
| 143 | + |
| 144 | + // Wait 10 seconds |
| 145 | + // Background: This test could pass simply because the controller hasn't reconciled the Copied CSV yet. |
| 146 | + // However, this test does sound an alarm if the controller ever reconciles a copied CSV. |
| 147 | + // TODO: Improve this test by identifying a way to identify that the controller has not reconciling a resource. |
| 148 | + time.Sleep(time.Second * 10) |
| 149 | + err := k8sClient.Get(ctx, namespacedName, operatorCondition) |
| 150 | + Expect(err).ToNot(BeNil()) |
| 151 | + Expect(k8serrors.IsNotFound(err)).To(BeTrue()) |
| 152 | + }) |
| 153 | + |
102 | 154 | It("creates an OperatorCondition for a CSV with multiple ServiceAccounts and Deployments", func() {
|
103 | 155 | depName := genName("dep-")
|
104 | 156 | csv := &operatorsv1alpha1.ClusterServiceVersion{
|
|
0 commit comments