use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class ReflectorRunnableTest method testReflectorRunnableShouldPardonList410ApiException.
@Test
public void testReflectorRunnableShouldPardonList410ApiException() throws ApiException {
ApiException expectedException = new ApiException(410, "noxu");
AtomicReference<Throwable> actualException = new AtomicReference<>();
when(listerWatcher.list(any())).thenThrow(expectedException);
ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>(V1Pod.class, listerWatcher, deltaFIFO, (apiType, t) -> {
actualException.set(t);
});
try {
Thread thread = new Thread(reflectorRunnable::run);
thread.setDaemon(true);
thread.start();
Awaitility.await().atMost(Duration.ofSeconds(1)).pollInterval(Duration.ofMillis(100)).until(() -> {
return reflectorRunnable.isLastSyncResourceVersionUnavailable();
});
} finally {
reflectorRunnable.stop();
}
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class ReflectorRunnableTest method testReflectorListShouldHandleExpiredResourceVersion.
@Test
public void testReflectorListShouldHandleExpiredResourceVersion() throws ApiException {
String expectedResourceVersion = "100";
when(listerWatcher.list(any())).thenReturn(new V1PodList().metadata(new V1ListMeta().resourceVersion(expectedResourceVersion)));
// constantly failing watches will make the reflector run only one time
when(listerWatcher.watch(any())).thenThrow(new ApiException(HttpURLConnection.HTTP_GONE, ""));
ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>(V1Pod.class, listerWatcher, deltaFIFO);
CompletableFuture<Void> future = CompletableFuture.runAsync(reflectorRunnable::run);
Awaitility.await().atMost(Duration.ofSeconds(2)).pollInterval(Duration.ofMillis(100)).until(() -> future.isDone());
assertFalse(future.isCompletedExceptionally());
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class ReflectorRunnableTest method testReflectorWatchConnectionCloseOnError.
@Test
public void testReflectorWatchConnectionCloseOnError() throws InterruptedException {
Watchable<V1Pod> watch = new MockWatch<V1Pod>(new Watch.Response<V1Pod>(EventType.ERROR.name(), new V1Status().status("403")));
ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>(V1Pod.class, new ListerWatcher<V1Pod, V1PodList>() {
@Override
public V1PodList list(CallGeneratorParams params) throws ApiException {
return new V1PodList().metadata(new V1ListMeta());
}
@Override
public Watchable<V1Pod> watch(CallGeneratorParams params) throws ApiException {
return watch;
}
}, deltaFIFO);
try {
Thread thread = new Thread(reflectorRunnable::run);
thread.setDaemon(true);
thread.start();
Awaitility.await().atMost(Duration.ofSeconds(1)).pollInterval(Duration.ofMillis(100)).until(() -> ((MockWatch<V1Pod>) watch).isClosed());
} finally {
reflectorRunnable.stop();
}
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class ReflectorRunnableTest method testReflectorWatchShouldRelistUponExpiredWatchItem.
@Test
public void testReflectorWatchShouldRelistUponExpiredWatchItem() throws ApiException {
String expectedResourceVersion = "100";
Watchable<V1Pod> expiredWatchable = mock(Watchable.class);
when(expiredWatchable.hasNext()).thenReturn(true);
when(expiredWatchable.next()).thenReturn(new Watch.Response<>(EventType.ERROR.name(), new V1Status().code(HttpURLConnection.HTTP_GONE)));
when(listerWatcher.list(any())).thenReturn(new V1PodList().metadata(new V1ListMeta().resourceVersion(expectedResourceVersion)));
// constantly failing watches will make the reflector run only one time
when(listerWatcher.watch(any())).thenReturn(expiredWatchable);
ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>(V1Pod.class, listerWatcher, deltaFIFO);
CompletableFuture<Void> future = CompletableFuture.runAsync(reflectorRunnable::run);
Awaitility.await().atMost(Duration.ofSeconds(2)).pollInterval(Duration.ofMillis(100)).until(() -> future.isDone());
assertFalse(future.isCompletedExceptionally());
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class CoreV1Api method readNamespacedPodEphemeralcontainersAsync.
/**
* (asynchronously) read ephemeralcontainers of the specified Pod
*
* @param name name of the Pod (required)
* @param namespace object name and auth scope, such as for teams and projects (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
* </table>
*/
public okhttp3.Call readNamespacedPodEphemeralcontainersAsync(String name, String namespace, String pretty, final ApiCallback<V1Pod> _callback) throws ApiException {
okhttp3.Call localVarCall = readNamespacedPodEphemeralcontainersValidateBeforeCall(name, namespace, pretty, _callback);
Type localVarReturnType = new TypeToken<V1Pod>() {
}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
Aggregations