use of io.fabric8.kubernetes.client.Watch in project zeppelin by apache.
the class PodPhaseWatcherTest method testPhaseWithError.
@Test
@Ignore("Reamer - ZEPPELIN-5403")
public void testPhaseWithError() throws InterruptedException {
KubernetesClient client = server.getClient();
// CREATE
client.pods().inNamespace("ns1").create(new PodBuilder().withNewMetadata().withName("pod1").endMetadata().build());
// READ
PodList podList = client.pods().inNamespace("ns1").list();
assertNotNull(podList);
assertEquals(1, podList.getItems().size());
// WATCH
PodPhaseWatcher podWatcher = new PodPhaseWatcher(phase -> StringUtils.equalsAnyIgnoreCase(phase, "Succeeded", "Failed", "Running"));
Watch watch = client.pods().inNamespace("ns1").withName("pod1").watch(podWatcher);
// In the case of close, we do not block thread execution
watch.close();
assertTrue(podWatcher.getCountDownLatch().await(1, TimeUnit.SECONDS));
}
use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class KubernetesConfigAdminBridgeTest method testAndOr.
@Test
public void testAndOr() {
System.setProperty("fabric8.pid.filters", "appName=A;B,database.name=my.oracle.datasource");
KubernetesMockServer plainServer = new KubernetesMockServer(false);
plainServer.expect().get().withPath("/api/v1/namespaces/test/configmaps?labelSelector=karaf.pid,appName%20in%20(A,B),database.name%20in%20(my.oracle.datasource)&watch=true").andReturnChunked(200).always();
plainServer.expect().get().withPath("/api/v1/namespaces/test/configmaps?labelSelector=karaf.pid,appName%20in%20(A,B),database.name%20in%20(my.oracle.datasource)").andReturn(200, cmEmptyList).once();
KubernetesConfigAdminBridge kcab = new KubernetesConfigAdminBridge();
kcab.bindConfigAdmin(caService);
kcab.bindKubernetesClient(plainServer.createClient());
kcab.activate();
}
use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class KubernetesConfigAdminBridgeTest method testAand.
@Test
public void testAand() {
System.setProperty("fabric8.pid.filters", "appName=A,database.name=my.oracle.datasource");
KubernetesMockServer plainServer = new KubernetesMockServer(false);
plainServer.expect().get().withPath("/api/v1/namespaces/test/configmaps?labelSelector=karaf.pid,appName%20in%20(A),database.name%20in%20(my.oracle.datasource)&watch=true").andReturnChunked(200).always();
plainServer.expect().get().withPath("/api/v1/namespaces/test/configmaps?labelSelector=karaf.pid,appName%20in%20(A),database.name%20in%20(my.oracle.datasource)").andReturn(200, cmEmptyList).once();
KubernetesConfigAdminBridge kcab = new KubernetesConfigAdminBridge();
kcab.bindConfigAdmin(caService);
kcab.bindKubernetesClient(plainServer.createClient());
kcab.activate();
}
use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class PodSelectionAssert method isPodReadyForPeriod.
/**
* Asserts that a pod is ready for this deployment all become ready within the given time and that each one keeps being ready for the given time
*/
public PodSelectionAssert isPodReadyForPeriod(long notReadyTimeoutMS, long readyPeriodMS) {
if (replicas.intValue() <= 0) {
LOG.warn("Not that the pod selection for: " + description + " has no replicas defined so we cannot assert there is a pod ready");
return this;
}
try (PodWatcher podWatcher = new PodWatcher(this, notReadyTimeoutMS, readyPeriodMS);
Watch watch = client.pods().withLabels(matchLabels).watch(podWatcher)) {
podWatcher.loadCurrentPods();
podWatcher.waitForPodReady();
}
return this;
}
use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class WatchPodsExample method main.
public static void main(String... args) throws Exception {
KubernetesClient client = new DefaultKubernetesClient();
client.pods().watch(new io.fabric8.kubernetes.client.Watcher<Pod>() {
@Override
public void eventReceived(Action action, Pod pod) {
System.out.println(action + ": " + pod);
}
@Override
public void onClose(KubernetesClientException e) {
System.out.println("Closed: " + e);
}
});
client.close();
}
Aggregations