use of com.marcnuri.yakc.api.core.v1.CoreV1Api.ListNamespacedService in project yakc by manusa.
the class ServiceService method watch.
@Override
public Observable<WatchEvent<Service>> watch() throws IOException {
final CoreV1Api api = kubernetesClient.create(CoreV1Api.class);
return tryWithFallback(() -> {
api.listServiceForAllNamespaces(new ListServiceForAllNamespaces().limit(1)).get();
return api.listServiceForAllNamespaces().watch();
}, () -> {
final String ns = kubernetesClient.getConfiguration().getNamespace();
api.listNamespacedService(ns, new ListNamespacedService().limit(1)).get();
return api.listNamespacedService(ns).watch();
});
}
use of com.marcnuri.yakc.api.core.v1.CoreV1Api.ListNamespacedService in project yakc by manusa.
the class ServiceIT method awaitCreateWatch.
@Test
@DisplayName("listNamespacedService.watch, should await for notification of newly created Service")
void awaitCreateWatch() throws IOException {
// Given
final AtomicBoolean hasError = new AtomicBoolean(false);
final AtomicBoolean hasCompleted = new AtomicBoolean(false);
// When
final Disposable d = KC.create(CoreV1Api.class).listNamespacedService(NAMESPACE).watch().filter(we -> we.getObject().getMetadata().getName().equals(serviceName)).takeUntil(we -> we.getType() == Type.ADDED).timeout(20, TimeUnit.SECONDS).subscribe(we -> hasCompleted.set(true), we -> hasError.set(true));
// Then
assertThat(d).isNotNull();
assertThat(hasError.get()).as("Watch subscribe ended with an error").isFalse();
assertThat(hasCompleted.get()).as("Watch subscribe did not complete").isTrue();
}
use of com.marcnuri.yakc.api.core.v1.CoreV1Api.ListNamespacedService in project yakc by manusa.
the class ServiceLegacyIT method awaitCreateWatch.
@Test
@DisplayName("listNamespacedService.watch, should await for notification of newly created Service")
void awaitCreateWatch() throws IOException {
// Given
final AtomicBoolean hasError = new AtomicBoolean(false);
final AtomicBoolean hasCompleted = new AtomicBoolean(false);
// When
final Disposable d = KC.create(CoreV1Api.class).listNamespacedService(NAMESPACE).watch().filter(we -> we.getObject().getMetadata().getName().equals(serviceName)).takeUntil(we -> we.getType() == Type.ADDED).timeout(20, TimeUnit.SECONDS).subscribe(we -> hasCompleted.set(true), we -> hasError.set(true));
// Then
assertThat(d).isNotNull();
assertThat(hasError.get()).as("Watch subscribe ended with an error").isFalse();
assertThat(hasCompleted.get()).as("Watch subscribe did not complete").isTrue();
}
Aggregations