forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResourceTest.java
585 lines (471 loc) · 20.9 KB
/
ResourceTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.kubernetes.client.mock;
import io.fabric8.kubernetes.api.model.DeleteOptions;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodBuilder;
import io.fabric8.kubernetes.api.model.PodListBuilder;
import io.fabric8.kubernetes.api.model.Status;
import io.fabric8.kubernetes.api.model.StatusBuilder;
import io.fabric8.kubernetes.api.model.WatchEvent;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.ResourceNotFoundException;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.Applicable;
import io.fabric8.kubernetes.client.dsl.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.internal.readiness.Readiness;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.kubernetes.client.utils.Serialization;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.net.HttpURLConnection;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import static java.net.HttpURLConnection.HTTP_GONE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@EnableKubernetesMockClient
class ResourceTest {
KubernetesMockServer server;
KubernetesClient client;
@Test
void testCreateOrReplace() {
// Given
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().post().withPath("/api/v1/namespaces/test/pods").andReturn(HttpURLConnection.HTTP_CREATED, pod1).once();
// When
HasMetadata response = client.resource(pod1).createOrReplace();
// Then
assertEquals(pod1, response);
}
@Test
void testCreateOrReplaceString() {
// Given
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().post().withPath("/api/v1/namespaces/test/pods").andReturn(HttpURLConnection.HTTP_CREATED, pod1).once();
// When
HasMetadata response = client.resource(Serialization.asYaml(pod1)).createOrReplace();
// Then
assertEquals(pod1, response);
}
@Test
void testGenericResourceFails() {
assertThrows(KubernetesClientException.class, () -> client.resource(Serialization.unmarshal("apiVersion: example.io/v1\n"
+ "kind: GenericThatFails\n"
+ "metadata:\n"
+ " name: failure\n", GenericKubernetesResource.class)));
}
@Test
void testCreateOrReplaceWhenCreateFails() {
// Given
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().post().withPath("/api/v1/namespaces/test/pods").andReturn(HttpURLConnection.HTTP_BAD_REQUEST, pod1).once();
NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable<Pod> podOperation = client.resource(pod1);
// When
assertThrows(KubernetesClientException.class, podOperation::createOrReplace);
}
@Test
void testCreateWithExplicitNamespace() {
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().post().withPath("/api/v1/namespaces/ns1/pods").andReturn(HttpURLConnection.HTTP_CREATED, pod1).once();
HasMetadata response = client.resource(pod1).inNamespace("ns1").createOrReplace();
assertEquals(pod1, response);
}
@Test
void testCreateOrReplaceWithDeleteExisting() throws Exception {
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().delete().withPath("/api/v1/namespaces/ns1/pods/pod1").andReturn(HttpURLConnection.HTTP_OK, pod1).once();
server.expect().post().withPath("/api/v1/namespaces/ns1/pods").andReturn(HttpURLConnection.HTTP_CREATED, pod1).once();
HasMetadata response = client.resource(pod1).inNamespace("ns1").deletingExisting().createOrReplace();
assertEquals(pod1, response);
RecordedRequest request = server.getLastRequest();
assertEquals(2, server.getRequestCount());
assertEquals("/api/v1/namespaces/ns1/pods", request.getPath());
assertEquals("POST", request.getMethod());
}
@Test
void itPassesPropagationPolicyWithDeleteExisting() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().delete().withPath("/api/v1/namespaces/ns1/pods/pod1").andReturn(HttpURLConnection.HTTP_OK, pod1).once();
server.expect().post().withPath("/api/v1/namespaces/ns1/pods").andReturn(HttpURLConnection.HTTP_CREATED, pod1).once();
HasMetadata response = client.resource(pod1).inNamespace("ns1").withPropagationPolicy(DeletionPropagation.FOREGROUND).deletingExisting().createOrReplace();
assertEquals(pod1, response);
assertEquals(2, server.getRequestCount());
RecordedRequest deleteRequest = server.takeRequest();
assertEquals("/api/v1/namespaces/ns1/pods/pod1", deleteRequest.getPath());
assertEquals("DELETE", deleteRequest.getMethod());
DeleteOptions deleteOptions = Serialization.unmarshal(deleteRequest.getBody().readUtf8(), DeleteOptions.class);
assertEquals("Foreground", deleteOptions.getPropagationPolicy());
RecordedRequest postRequest = server.takeRequest();
assertEquals("/api/v1/namespaces/ns1/pods", postRequest.getPath());
assertEquals("POST", postRequest.getMethod());
}
@Test
void testCreateOrReplaceWithDeleteExistingWithCreateFailed() {
// Given
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
server.expect().post().withPath("/api/v1/namespaces/ns1/pods").andReturn(HttpURLConnection.HTTP_CONFLICT, pod1).once();
server.expect().delete().withPath("/api/v1/namespaces/ns1/pods/pod1").andReturn(HttpURLConnection.HTTP_OK, pod1).once();
server.expect().post().withPath("/api/v1/namespaces/ns1/pods").andReturn(HttpURLConnection.HTTP_BAD_REQUEST, pod1).once();
Applicable<Pod> podOperation = client.resource(pod1).inNamespace("ns1").deletingExisting();
// When
assertThrows(KubernetesClientException.class, podOperation::createOrReplace);
}
@Test
void testRequire() {
server.expect().get().withPath("/api/v1/namespaces/ns1/pods/pod1").andReturn(HttpURLConnection.HTTP_NOT_FOUND, "").once();
PodResource<Pod> podOp = client.pods().inNamespace("ns1").withName("pod1");
Assertions.assertThrows(ResourceNotFoundException.class, podOp::require);
}
@Test
void testDelete() {
Pod pod1 = new PodBuilder().withNewMetadata().withName("pod1").withNamespace("test").and().build();
Pod pod2 = new PodBuilder().withNewMetadata().withName("pod2").withNamespace("ns1").and().build();
Pod pod3 = new PodBuilder().withNewMetadata().withName("pod3").withNamespace("any").and().build();
server.expect().withPath("/api/v1/namespaces/test/pods/pod1").andReturn(200, pod1).once();
server.expect().withPath("/api/v1/namespaces/ns1/pods/pod2").andReturn(200, pod2).once();
Boolean deleted = client.resource(pod1).delete();
assertTrue(deleted);
deleted = client.resource(pod2).delete();
assertTrue(deleted);
deleted = client.resource(pod3).delete();
assertFalse(deleted);
}
@Test
void testWatch() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
server.expect().get().withPath("/api/v1/namespaces/test/pods").andReturn(200, pod1).once();
server.expect().post().withPath("/api/v1/namespaces/test/pods").andReturn(201, pod1).once();
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(1000).andEmit(new WatchEvent(pod1, "DELETED"))
.done()
.always();
final CountDownLatch latch = new CountDownLatch(1);
Watch watch = client.resource(pod1).watch(new Watcher<Pod>() {
@Override
public void eventReceived(Action action, Pod resource) {
latch.countDown();
}
@Override
public void onClose(WatcherException cause) {
}
});
Assert.assertTrue(latch.await(5000, MILLISECONDS));
watch.close();
}
@Test
void testWaitUntilReady() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
list(noReady);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(500).andEmit(new WatchEvent(ready, "MODIFIED"))
.done()
.always();
Pod p = client.resource(noReady).waitUntilReady(5, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
private void list(Pod pod) {
list(server, pod);
}
static void list(KubernetesMockServer server, Pod pod) {
server.expect()
.get()
.withPath("/api/v1/namespaces/"+pod.getMetadata().getNamespace()+"/pods?fieldSelector=metadata.name%3D"+pod.getMetadata().getName())
.andReturn(200,
new PodListBuilder().withItems(pod).withNewMetadata().withResourceVersion("1").endMetadata().build())
.once();
}
@Test
void testWaitUntilExistsThenReady() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
// and again so that "periodicWatchUntilReady" successfully begins
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1").andReturn(200, noReady).times(2);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(100).andEmit(new WatchEvent(ready, "MODIFIED"))
.done()
.always();
Pod p = client.pods().withName("pod1").waitUntilReady(5, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
@Test
void testWaitUntilCondition() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
Pod withConditionBeingFalse = new PodBuilder(pod1).withNewStatus()
.addNewCondition()
.withType("Ready")
.withStatus("True")
.endCondition()
.addNewCondition()
.withType("dummy")
.withStatus("False")
.endCondition()
.endStatus()
.build();
Pod withConditionBeingTrue = new PodBuilder(pod1).withNewStatus()
.addNewCondition()
.withType("Ready")
.withStatus("True")
.endCondition()
.addNewCondition()
.withType("Dummy")
.withStatus("True")
.endCondition()
.endStatus()
.build();
// at first the pod is non-ready
list(noReady);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(1000).andEmit(new WatchEvent(ready, "MODIFIED"))
.waitFor(2000).andEmit(new WatchEvent(withConditionBeingFalse, "MODIFIED"))
.waitFor(2500).andEmit(new WatchEvent(withConditionBeingTrue, "MODIFIED"))
.done()
.always();
Pod p = client.pods().withName("pod1").waitUntilCondition(
r -> r.getStatus().getConditions()
.stream()
.anyMatch(c -> "Dummy".equals(c.getType()) && "True".equals(c.getStatus())),
8, SECONDS
);
assertThat(p.getStatus().getConditions())
.extracting("type", "status")
.containsExactly(tuple("Ready", "True"), tuple("Dummy", "True"));
}
@Test
void tesErrorEventDuringWaitReturnFromAPIIfMatch() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
Status status = new StatusBuilder()
.withCode(HttpURLConnection.HTTP_FORBIDDEN)
.build();
// once not ready, to begin watch
list(noReady);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(500).andEmit(new WatchEvent(status, "ERROR"))
.waitFor(500).andEmit(new WatchEvent(ready, "MODIFIED"))
.done()
.once();
Pod p = client.resource(noReady).waitUntilReady(5, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
@Test
void testRetryOnErrorEventDuringWait() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
Status status = new StatusBuilder()
.withCode(HttpURLConnection.HTTP_FORBIDDEN)
.build();
// once not ready, to begin watch
list(noReady);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(500).andEmit(new WatchEvent(status, "ERROR"))
.done()
.once();
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(500).andEmit(new WatchEvent(ready, "MODIFIED"))
.done()
.once();
Pod p = client.resource(noReady).waitUntilReady(5, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
@Test
void testSkipWatchIfAlreadyMatchingCondition() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
// once not ready, to begin watch
list(ready);
Pod p = client.resource(noReady).waitUntilReady(5, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
@Test
void testRetryWatchOnHttpGone() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
Status status = new StatusBuilder()
.withCode(HTTP_GONE)
.build();
// once not ready, to begin watch
list(noReady);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(500).andEmit(new WatchEvent(status, "ERROR"))
.done()
.once();
list(ready);
client.resource(noReady).waitUntilReady(5, SECONDS);
}
@Test
void testWaitOnConditionDeleted() throws InterruptedException {
Pod ready = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().withNewStatus()
.addNewCondition()
.withType("Ready")
.withStatus("True")
.endCondition()
.endStatus()
.build();
list(ready);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(1000).andEmit(new WatchEvent(ready, "DELETED"))
.done()
.once();
Pod p = client.pods().withName("pod1").waitUntilCondition(Objects::isNull,8, SECONDS);
assertNull(p);
}
@Test
void testCreateAndWaitUntilReady() throws InterruptedException {
Pod pod1 = new PodBuilder().withNewMetadata()
.withName("pod1")
.withResourceVersion("1")
.withNamespace("test").and().build();
Pod noReady = createReadyFrom(pod1, "False");
Pod ready = createReadyFrom(pod1, "True");
list(noReady);
server.expect().post().withPath("/api/v1/namespaces/test/pods").andReturn(201, noReady).once();
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
.open()
.waitFor(1000).andEmit(new WatchEvent(ready, "MODIFIED"))
.done()
.always();
Pod p = client.resource(noReady).createOrReplaceAnd().waitUntilReady(10, SECONDS);
Assert.assertTrue(Readiness.isPodReady(p));
}
@Test
void testFromServerGet() {
Pod pod = new PodBuilder().withNewMetadata()
.withName("pod1")
.withNamespace("test")
.withResourceVersion("1")
.and()
.build();
server.expect().get().withPath("/api/v1/namespaces/test/pods/pod1").andReturn(200, pod).once();
HasMetadata response = client.resource(pod).fromServer().get();
assertEquals(pod, response);
}
@Test
@DisplayName("resource().waitUntilCondition(), resource forced to be reloaded from server even if condition is met by local version")
void testFromServerWaitUntilConditionAlwaysGetsResourceFromServer() throws Exception {
// Given
final Pod conditionNotMetPod = new PodBuilder().withNewMetadata()
.withName("pod")
.withNamespace("test")
.addToLabels("CONDITION", "NOT_MET")
.endMetadata().build();
final Pod conditionMetPod = new PodBuilder().withNewMetadata()
.withName("pod")
.withNamespace("test")
.withResourceVersion("1")
.addToLabels("CONDITION", "MET")
.endMetadata()
.build();
list(conditionNotMetPod);
server.expect().get().withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod&resourceVersion=1&watch=true")
.andUpgradeToWebSocket().open()
.immediately().andEmit(new WatchEvent(conditionNotMetPod, "MODIFIED"))
.waitFor(10).andEmit(new WatchEvent(conditionMetPod, "MODIFIED"))
.done()
.once();
// When
HasMetadata response = client
.resource(new PodBuilder(conditionMetPod).build())
.waitUntilCondition(p -> "MET".equals(p.getMetadata().getLabels().get("CONDITION")), 1, SECONDS);
// Then
assertEquals(conditionMetPod, response);
assertEquals(2, server.getRequestCount());
}
@Test
void testWaitNullDoesntExist() throws InterruptedException {
server.expect()
.get()
.withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3Dpod1")
.andReturn(200,
new PodListBuilder().withNewMetadata().withResourceVersion("1").endMetadata().build())
.once();
Pod p = client.pods().withName("pod1").waitUntilCondition(Objects::isNull, 1, SECONDS);
assertNull(p);
}
private static Pod createReadyFrom(Pod pod, String status) {
return new PodBuilder(pod)
.withNewStatus()
.addNewCondition()
.withType("Ready")
.withStatus(status)
.endCondition()
.endStatus()
.build();
}
}