|
13 | 13 | package io.kubernetes.client.informer.cache;
|
14 | 14 |
|
15 | 15 | import static org.junit.Assert.assertFalse;
|
| 16 | +import static org.junit.Assert.assertTrue; |
16 | 17 | import static org.mockito.Mockito.any;
|
17 | 18 | import static org.mockito.Mockito.never;
|
18 | 19 | import static org.mockito.Mockito.times;
|
@@ -255,4 +256,34 @@ public void testReflectorListShouldHandleExpiredResourceVersion() throws ApiExce
|
255 | 256 | reflectorRunnable.stop();
|
256 | 257 | }
|
257 | 258 | }
|
| 259 | + |
| 260 | + @Test |
| 261 | + public void testReflectorListShouldHandleExpiredResourceVersionFromWatchHandler() |
| 262 | + throws ApiException { |
| 263 | + String expectedResourceVersion = "100"; |
| 264 | + when(listerWatcher.list(any())) |
| 265 | + .thenReturn( |
| 266 | + new V1PodList().metadata(new V1ListMeta().resourceVersion(expectedResourceVersion))); |
| 267 | + |
| 268 | + V1Status v1Status = new V1Status(); |
| 269 | + v1Status.setMessage("dummy-error-message"); |
| 270 | + v1Status.setCode(410); |
| 271 | + when(listerWatcher.watch(any())) |
| 272 | + .thenReturn(new MockWatch<>(new Watch.Response("Error", v1Status))); |
| 273 | + ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = |
| 274 | + new ReflectorRunnable<>(V1Pod.class, listerWatcher, deltaFIFO); |
| 275 | + try { |
| 276 | + Thread thread = new Thread(reflectorRunnable::run); |
| 277 | + thread.setDaemon(true); |
| 278 | + thread.start(); |
| 279 | + Awaitility.await() |
| 280 | + .atMost(Duration.ofSeconds(1)) |
| 281 | + .pollInterval(Duration.ofMillis(100)) |
| 282 | + .until( |
| 283 | + () -> expectedResourceVersion.equals(reflectorRunnable.getLastSyncResourceVersion())); |
| 284 | + assertTrue(reflectorRunnable.isLastSyncResourceVersionUnavailable()); |
| 285 | + } finally { |
| 286 | + reflectorRunnable.stop(); |
| 287 | + } |
| 288 | + } |
258 | 289 | }
|
0 commit comments