Search in sources :

Example 1 with WatcherException

use of io.fabric8.kubernetes.client.WatcherException in project flink by apache.

the class KubernetesPodsWatcherTest method testClosingWithException.

@Test
public void testClosingWithException() {
    final AtomicBoolean called = new AtomicBoolean(false);
    final KubernetesPodsWatcher podsWatcher = new KubernetesPodsWatcher(new TestingCallbackHandler(e -> called.set(true)));
    podsWatcher.onClose(new WatcherException("exception"));
    assertThat(called.get(), is(true));
}
Also used : KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) StatusBuilder(io.fabric8.kubernetes.api.model.StatusBuilder) FlinkMatchers(org.apache.flink.core.testutils.FlinkMatchers) Watcher(io.fabric8.kubernetes.client.Watcher) Matchers(org.hamcrest.Matchers) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) WatcherException(io.fabric8.kubernetes.client.WatcherException) List(java.util.List) TestLogger(org.apache.flink.util.TestLogger) Is.is(org.hamcrest.core.Is.is) HTTP_GONE(java.net.HttpURLConnection.HTTP_GONE) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assert(org.junit.Assert) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WatcherException(io.fabric8.kubernetes.client.WatcherException) Test(org.junit.Test)

Example 2 with WatcherException

use of io.fabric8.kubernetes.client.WatcherException in project flink by apache.

the class KubernetesPodsWatcherTest method testClosingWithTooOldResourceVersion.

@Test
public void testClosingWithTooOldResourceVersion() {
    final String errMsg = "too old resource version";
    final KubernetesPodsWatcher podsWatcher = new KubernetesPodsWatcher(new TestingCallbackHandler(e -> {
        assertThat(e, Matchers.instanceOf(KubernetesTooOldResourceVersionException.class));
        assertThat(e, FlinkMatchers.containsMessage(errMsg));
    }));
    podsWatcher.onClose(new WatcherException(errMsg, new KubernetesClientException(errMsg, HTTP_GONE, new StatusBuilder().build())));
}
Also used : KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) StatusBuilder(io.fabric8.kubernetes.api.model.StatusBuilder) FlinkMatchers(org.apache.flink.core.testutils.FlinkMatchers) Watcher(io.fabric8.kubernetes.client.Watcher) Matchers(org.hamcrest.Matchers) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) WatcherException(io.fabric8.kubernetes.client.WatcherException) List(java.util.List) TestLogger(org.apache.flink.util.TestLogger) Is.is(org.hamcrest.core.Is.is) HTTP_GONE(java.net.HttpURLConnection.HTTP_GONE) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assert(org.junit.Assert) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) StatusBuilder(io.fabric8.kubernetes.api.model.StatusBuilder) WatcherException(io.fabric8.kubernetes.client.WatcherException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) Test(org.junit.Test)

Aggregations

StatusBuilder (io.fabric8.kubernetes.api.model.StatusBuilder)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 Watcher (io.fabric8.kubernetes.client.Watcher)2 WatcherException (io.fabric8.kubernetes.client.WatcherException)2 HTTP_GONE (java.net.HttpURLConnection.HTTP_GONE)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Consumer (java.util.function.Consumer)2 FlinkMatchers (org.apache.flink.core.testutils.FlinkMatchers)2 FlinkKubeClient (org.apache.flink.kubernetes.kubeclient.FlinkKubeClient)2 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)2 TestLogger (org.apache.flink.util.TestLogger)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 Matchers (org.hamcrest.Matchers)2 Is.is (org.hamcrest.core.Is.is)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2