@@ -40,6 +40,8 @@ const (
40
40
)
41
41
42
42
var _ = Describe ("Create and delete a provider with manifests that don't fit the configmap" , func () {
43
+ var ociInfrastructureConfigMap = & corev1.ConfigMap {}
44
+
43
45
It ("should successfully create a CoreProvider" , func () {
44
46
k8sclient := bootstrapClusterProxy .GetClient ()
45
47
coreProvider := & operatorv1.CoreProvider {
@@ -140,6 +142,95 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
140
142
return false
141
143
}, timeout ).Should (Equal (true ))
142
144
145
+ By ("Ensure that the created config map has correct annotation" )
146
+ cmName := fmt .Sprintf ("infrastructure-%s-%s" , ociInfrastructureProviderName , ociInfrastructureProviderVersion )
147
+ key := client.ObjectKey {Namespace : operatorNamespace , Name : cmName }
148
+
149
+ // Save config map contents to be used later.
150
+ Expect (k8sclient .Get (ctx , key , ociInfrastructureConfigMap )).To (Succeed ())
151
+
152
+ Expect (ociInfrastructureConfigMap .GetAnnotations ()[compressedAnnotation ]).To (Equal ("true" ))
153
+
154
+ Expect (ociInfrastructureConfigMap .BinaryData [componentsConfigMapKey ]).ToNot (BeEmpty ())
155
+
156
+ Expect (k8sclient .Delete (ctx , infraProvider )).To (Succeed ())
157
+
158
+ By ("Waiting for the infrastructure provider deployment to be created" )
159
+ Eventually (func () bool {
160
+ deployment := & appsv1.Deployment {}
161
+ key := client.ObjectKey {Namespace : operatorNamespace , Name : ociInfrastructureProviderDeploymentName }
162
+
163
+ return k8sclient .Get (ctx , key , deployment ) == nil
164
+ }, timeout ).Should (Equal (true ))
165
+
166
+ By ("Waiting for the infrastructure provider deployment to be deleted" )
167
+ Eventually (func () bool {
168
+ deployment := & appsv1.Deployment {}
169
+ key := client.ObjectKey {Namespace : operatorNamespace , Name : ociInfrastructureProviderDeploymentName }
170
+ isInfraProviderDeleted , err := waitForObjectToBeDeleted (k8sclient , ctx , key , deployment )
171
+ if err != nil {
172
+ return false
173
+ }
174
+ return isInfraProviderDeleted
175
+ }, timeout ).Should (Equal (true ))
176
+ })
177
+
178
+ It ("should successfully create and delete an InfrastructureProvider for OCI from a pre-created ConfigMap" , func () {
179
+ k8sclient := bootstrapClusterProxy .GetClient ()
180
+ infraProvider := & operatorv1.InfrastructureProvider {
181
+ ObjectMeta : metav1.ObjectMeta {
182
+ Name : ociInfrastructureProviderName ,
183
+ Namespace : operatorNamespace ,
184
+ },
185
+ Spec : operatorv1.InfrastructureProviderSpec {
186
+ ProviderSpec : operatorv1.ProviderSpec {
187
+ FetchConfig : & operatorv1.FetchConfiguration {
188
+ Selector : & metav1.LabelSelector {
189
+ MatchLabels : map [string ]string {
190
+ "provider.cluster.x-k8s.io/name" : "oci" ,
191
+ "provider.cluster.x-k8s.io/type" : "infrastructure" ,
192
+ },
193
+ },
194
+ },
195
+ },
196
+ },
197
+ }
198
+
199
+ // Re-use configmap created on the previous step.
200
+ Expect (k8sclient .Create (ctx , ociInfrastructureConfigMap )).To (Succeed ())
201
+
202
+ Expect (k8sclient .Create (ctx , infraProvider )).To (Succeed ())
203
+
204
+ By ("Waiting for the infrastructure provider to be ready" )
205
+ Eventually (func () bool {
206
+ infraProvider := & operatorv1.InfrastructureProvider {}
207
+ key := client.ObjectKey {Namespace : operatorNamespace , Name : ociInfrastructureProviderName }
208
+ if err := k8sclient .Get (ctx , key , infraProvider ); err != nil {
209
+ return false
210
+ }
211
+
212
+ for _ , c := range infraProvider .Status .Conditions {
213
+ if c .Type == operatorv1 .ProviderInstalledCondition && c .Status == corev1 .ConditionTrue {
214
+ return true
215
+ }
216
+ }
217
+ return false
218
+ }, timeout ).Should (Equal (true ))
219
+
220
+ By ("Waiting for status.IntalledVersion to be set" )
221
+ Eventually (func () bool {
222
+ infraProvider := & operatorv1.InfrastructureProvider {}
223
+ key := client.ObjectKey {Namespace : operatorNamespace , Name : ociInfrastructureProviderName }
224
+ if err := k8sclient .Get (ctx , key , infraProvider ); err != nil {
225
+ return false
226
+ }
227
+
228
+ if infraProvider .Status .InstalledVersion != nil && * infraProvider .Status .InstalledVersion == infraProvider .Spec .Version {
229
+ return true
230
+ }
231
+ return false
232
+ }, timeout ).Should (Equal (true ))
233
+
143
234
By ("Ensure that the created config map has correct annotation" )
144
235
cm := & corev1.ConfigMap {}
145
236
cmName := fmt .Sprintf ("infrastructure-%s-%s" , ociInfrastructureProviderName , ociInfrastructureProviderVersion )
0 commit comments