@@ -12,6 +12,8 @@ import {
12
12
InfraEnvKind ,
13
13
ManagedClusterApiVersion ,
14
14
ManagedClusterKind ,
15
+ NodePoolApiVersion ,
16
+ NodePoolKind ,
15
17
SecretApiVersion ,
16
18
SecretKind ,
17
19
} from '../resources'
@@ -137,7 +139,7 @@ const mockCluster3: Cluster = {
137
139
isManaged : true ,
138
140
isCurator : true ,
139
141
hasAutomationTemplate : false ,
140
- isHostedCluster : true ,
142
+ isHostedCluster : false ,
141
143
isHypershift : false ,
142
144
isSNOCluster : false ,
143
145
owner : { } ,
@@ -146,6 +148,198 @@ const mockCluster3: Cluster = {
146
148
isRegionalHubCluster : false ,
147
149
}
148
150
151
+ const mockHostedCluster : Cluster = {
152
+ name : 'hosted-cluster1' ,
153
+ displayName : 'hosted-cluster1' ,
154
+ namespace : 'clusters' ,
155
+ uid : 'hosted-cluster1-uid' ,
156
+ provider : Provider . kubevirt ,
157
+ status : ClusterStatus . ready ,
158
+ distribution : {
159
+ ocp : {
160
+ version : '4.11.12' ,
161
+ availableUpdates : [ ] ,
162
+ desiredVersion : '4.11.12' ,
163
+ upgradeFailed : false ,
164
+ } ,
165
+ isManagedOpenShift : false ,
166
+ } ,
167
+ labels : { abc : '123' } ,
168
+ nodes : undefined ,
169
+ kubeApiServer : '' ,
170
+ consoleURL : '' ,
171
+ hive : {
172
+ isHibernatable : false ,
173
+ clusterPool : undefined ,
174
+ secrets : {
175
+ installConfig : '' ,
176
+ } ,
177
+ } ,
178
+ hypershift : {
179
+ agent : false ,
180
+ hostingNamespace : 'clusters' ,
181
+ nodePools : [
182
+ {
183
+ apiVersion : 'hypershift.openshift.io/v1beta1' ,
184
+ kind : 'NodePool' ,
185
+ metadata : {
186
+ annotations : {
187
+ 'hypershift.openshift.io/nodePoolCurrentConfig' : '814967cb' ,
188
+ 'hypershift.openshift.io/nodePoolCurrentConfigVersion' : '0e8b8078' ,
189
+ 'hypershift.openshift.io/nodePoolPlatformMachineTemplate' : 'hosted-cluster1-304faa18' ,
190
+ } ,
191
+ finalizers : [ 'hypershift.openshift.io/finalizer' ] ,
192
+ labels : {
193
+ 'hypershift.openshift.io/auto-created-for-infra' : 'hosted-cluster1-qvl8m' ,
194
+ } ,
195
+ name : 'hosted-cluster1-nodepool' ,
196
+ namespace : 'clusters' ,
197
+ } ,
198
+ spec : {
199
+ clusterName : 'hosted-cluster1' ,
200
+ management : {
201
+ autoRepair : false ,
202
+ replace : {
203
+ rollingUpdate : {
204
+ maxSurge : 1 ,
205
+ maxUnavailable : 0 ,
206
+ } ,
207
+ strategy : 'RollingUpdate' ,
208
+ } ,
209
+ upgradeType : 'Replace' ,
210
+ } ,
211
+ platform : {
212
+ aws : {
213
+ instanceProfile : 'test' ,
214
+ instanceType : 'test' ,
215
+ rootVolume : {
216
+ size : 10 ,
217
+ type : 'Persistent' ,
218
+ } ,
219
+ securityGroups : [ ] ,
220
+ subnet : {
221
+ id : 'string' ,
222
+ } ,
223
+ } ,
224
+ type : 'AWS' ,
225
+ } ,
226
+ release : {
227
+ image : 'quay.io/openshift-release-dev/ocp-release:4.15.10-x86_64' ,
228
+ } ,
229
+ replicas : 2 ,
230
+ } ,
231
+ status : {
232
+ conditions : [
233
+ {
234
+ lastTransitionTime : '2024-06-14T15:55:12Z' ,
235
+ observedGeneration : 1 ,
236
+ reason : 'AsExpected' ,
237
+ status : 'False' ,
238
+ type : 'AutoscalingEnabled' ,
239
+ } ,
240
+ {
241
+ lastTransitionTime : '2024-06-14T15:55:12Z' ,
242
+ observedGeneration : 1 ,
243
+ reason : 'AsExpected' ,
244
+ status : 'True' ,
245
+ type : 'UpdateManagementEnabled' ,
246
+ } ,
247
+ {
248
+ lastTransitionTime : '2024-06-18T00:17:55Z' ,
249
+ message : 'Using release image: quay.io/openshift-release-dev/ocp-release:4.15.10-x86_64' ,
250
+ observedGeneration : 1 ,
251
+ reason : 'AsExpected' ,
252
+ status : 'True' ,
253
+ type : 'ValidReleaseImage' ,
254
+ } ,
255
+ {
256
+ lastTransitionTime : '2024-06-14T15:58:54Z' ,
257
+ message : 'Payload generated successfully' ,
258
+ observedGeneration : 1 ,
259
+ reason : 'AsExpected' ,
260
+ status : 'True' ,
261
+ type : 'ValidGeneratedPayload' ,
262
+ } ,
263
+ {
264
+ lastTransitionTime : '2024-06-14T15:59:47Z' ,
265
+ observedGeneration : 1 ,
266
+ reason : 'AsExpected' ,
267
+ status : 'True' ,
268
+ type : 'ReachedIgnitionEndpoint' ,
269
+ } ,
270
+ {
271
+ lastTransitionTime : '2024-06-14T15:57:52Z' ,
272
+ observedGeneration : 1 ,
273
+ reason : 'AsExpected' ,
274
+ status : 'True' ,
275
+ type : 'ValidTuningConfig' ,
276
+ } ,
277
+ {
278
+ lastTransitionTime : '2024-06-14T15:57:52Z' ,
279
+ message : 'Reconciliation active on resource' ,
280
+ observedGeneration : 1 ,
281
+ reason : 'ReconciliationActive' ,
282
+ status : 'True' ,
283
+ type : 'ReconciliationActive' ,
284
+ } ,
285
+ {
286
+ lastTransitionTime : '2024-07-10T07:58:00Z' ,
287
+ message : 'All is well' ,
288
+ observedGeneration : 1 ,
289
+ reason : 'AsExpected' ,
290
+ status : 'True' ,
291
+ type : 'AllMachinesReady' ,
292
+ } ,
293
+ {
294
+ lastTransitionTime : '2024-06-14T16:07:05Z' ,
295
+ message : 'All is well' ,
296
+ observedGeneration : 1 ,
297
+ reason : 'AsExpected' ,
298
+ status : 'True' ,
299
+ type : 'AllNodesHealthy' ,
300
+ } ,
301
+ {
302
+ lastTransitionTime : '2024-06-14T15:57:52Z' ,
303
+ observedGeneration : 1 ,
304
+ reason : 'AsExpected' ,
305
+ status : 'False' ,
306
+ type : 'AutorepairEnabled' ,
307
+ } ,
308
+ {
309
+ lastTransitionTime : '2024-06-14T16:07:05Z' ,
310
+ observedGeneration : 1 ,
311
+ reason : 'AsExpected' ,
312
+ status : 'True' ,
313
+ type : 'Ready' ,
314
+ } ,
315
+ {
316
+ lastTransitionTime : '2024-07-10T15:39:26Z' ,
317
+ observedGeneration : 1 ,
318
+ reason : 'AsExpected' ,
319
+ status : 'True' ,
320
+ type : 'ValidMachineConfig' ,
321
+ } ,
322
+ ] ,
323
+ replicas : 2 ,
324
+ version : '4.15.10' ,
325
+ } ,
326
+ } ,
327
+ ] ,
328
+ secretNames : [ 'secret1' ] ,
329
+ } ,
330
+ isHive : false ,
331
+ isManaged : true ,
332
+ isCurator : true ,
333
+ hasAutomationTemplate : false ,
334
+ isHostedCluster : true ,
335
+ isHypershift : true ,
336
+ isSNOCluster : false ,
337
+ owner : { } ,
338
+ kubeadmin : '' ,
339
+ kubeconfig : '' ,
340
+ isRegionalHubCluster : false ,
341
+ }
342
+
149
343
const getDetatchNocks = ( name : string , namespace : string ) => [
150
344
nockPatch (
151
345
{
@@ -372,3 +566,56 @@ describe('deleteCluster', () => {
372
566
await waitForNocks ( deleteNocks )
373
567
} )
374
568
} )
569
+
570
+ const deleteHostedClusterNocks = ( ) => [
571
+ nockDelete ( {
572
+ apiVersion : ManagedClusterApiVersion ,
573
+ kind : ManagedClusterKind ,
574
+ metadata : {
575
+ name : mockHostedCluster . name ,
576
+ } ,
577
+ } ) ,
578
+ nockDelete ( {
579
+ apiVersion : HostedClusterApiVersion ,
580
+ kind : HostedClusterKind ,
581
+ metadata : {
582
+ name : mockHostedCluster . name ,
583
+ namespace : mockHostedCluster . namespace ,
584
+ } ,
585
+ } ) ,
586
+ nockDelete ( {
587
+ apiVersion : NodePoolApiVersion ,
588
+ kind : NodePoolKind ,
589
+ metadata : {
590
+ name : 'hosted-cluster1-nodepool' ,
591
+ namespace : 'clusters' ,
592
+ } ,
593
+ } ) ,
594
+ nockDelete ( {
595
+ apiVersion : SecretApiVersion ,
596
+ kind : SecretKind ,
597
+ metadata : {
598
+ name : 'secret1' ,
599
+ namespace : 'clusters' ,
600
+ } ,
601
+ } ) ,
602
+ ]
603
+
604
+ describe ( 'deleteCluster hostedcluster' , ( ) => {
605
+ beforeEach ( ( ) => {
606
+ jest . clearAllMocks ( )
607
+ nockIgnoreApiPaths ( )
608
+ } )
609
+
610
+ it ( 'delete Hosted cluster' , async ( ) => {
611
+ const nocks = deleteHostedClusterNocks ( )
612
+ deleteCluster ( {
613
+ cluster : mockHostedCluster ,
614
+ deletePullSecret : false ,
615
+ infraEnvs : [ ] ,
616
+ ignoreClusterDeploymentNotFound : true ,
617
+ } )
618
+
619
+ await waitForNocks ( nocks )
620
+ } )
621
+ } )
0 commit comments