use of com.netflix.titus.testkit.rx.TitusRxSubscriber in project titus-control-plane by Netflix.
the class EurekaContainerHealthServiceTest method testBadSubscriberIsolation.
@Test
public void testBadSubscriberIsolation() {
jobManagerStub.moveTaskToState(taskId1, TaskState.Started);
eurekaServer.register(newInstanceInfo(taskId1, InstanceStatus.UP));
// First event / one subscriber
TitusRxSubscriber<ContainerHealthEvent> subscriber1 = new TitusRxSubscriber<>();
healthService.events(false).subscribe(subscriber1);
eurekaServer.triggerCacheRefreshUpdate();
// Add bad subscriber
Disposable subscription2 = healthService.events(false).subscribe(next -> {
throw new RuntimeException("simulated error");
}, e -> {
throw new RuntimeException("simulated error");
}, () -> {
throw new RuntimeException("simulated error");
});
// Event 2
registerAndRefresh(InstanceStatus.DOWN);
assertThat(subscription2.isDisposed()).isTrue();
// Event 3
registerAndRefresh(InstanceStatus.UP);
assertThat(subscriber1.isDisposed()).isFalse();
assertThat(subscriber1.getAllItems()).hasSize(3);
}
use of com.netflix.titus.testkit.rx.TitusRxSubscriber in project titus-control-plane by Netflix.
the class DefaultOneOffReconcilerTest method testReconcilerCloseWithRunningReconciliationAction.
@Test(timeout = 30_000)
public void testReconcilerCloseWithRunningReconciliationAction() throws InterruptedException {
// Start reconciliation action first
CountDownLatch ready = new CountDownLatch(1);
AtomicBoolean cancelled = new AtomicBoolean();
Mono<Function<String, String>> action = Mono.<Function<String, String>>never().doOnSubscribe(s -> ready.countDown()).doOnCancel(() -> cancelled.set(true));
newReconciler(current -> Collections.singletonList(action));
ready.await();
TitusRxSubscriber<String> subscriber = new TitusRxSubscriber<>();
reconciler.apply(c -> Mono.never()).subscribe(subscriber);
assertThat(subscriber.isOpen()).isTrue();
reconciler.close().subscribe();
await().until(() -> cancelled.get() && !subscriber.isOpen());
assertThat(subscriber.getError().getMessage()).isEqualTo("cancelled");
await().until(() -> !changesSubscriber.isOpen());
}
use of com.netflix.titus.testkit.rx.TitusRxSubscriber in project titus-control-plane by Netflix.
the class AggregatingContainerHealthServiceTest method testBadSubscriberIsIsolated.
@Test
public void testBadSubscriberIsIsolated() {
// First event / one subscriber
TitusRxSubscriber<ContainerHealthEvent> goodSubscriber = new TitusRxSubscriber<>();
healthService.events(false).subscribe(goodSubscriber);
// Add bad subscriber
Disposable badSubscriber = healthService.events(false).subscribe(next -> {
throw new RuntimeException("simulated error");
}, e -> {
throw new RuntimeException("simulated error");
}, () -> {
throw new RuntimeException("simulated error");
});
downstream1.makeHealthy(taskId1);
assertThat(goodSubscriber.isOpen()).isTrue();
assertThat(badSubscriber.isDisposed()).isTrue();
}
use of com.netflix.titus.testkit.rx.TitusRxSubscriber in project titus-control-plane by Netflix.
the class DefaultManyReconcilerTest method testReconcilerCloseWithRunningReconciliationAction.
@Test
public void testReconcilerCloseWithRunningReconciliationAction() throws InterruptedException {
// Start reconciliation action first
CountDownLatch ready = new CountDownLatch(1);
AtomicBoolean cancelled = new AtomicBoolean();
Mono<Function<String, String>> action = Mono.<Function<String, String>>never().doOnSubscribe(s -> ready.countDown()).doOnCancel(() -> cancelled.set(true));
newReconcilerWithRegistrations(current -> Collections.singletonList(action), "r1", "a");
ready.await();
TitusRxSubscriber<String> subscriber = new TitusRxSubscriber<>();
reconciler.apply("r1", c -> Mono.never()).subscribe(subscriber);
assertThat(subscriber.isOpen()).isTrue();
reconciler.close().subscribe();
await().until(() -> cancelled.get() && !subscriber.isOpen());
assertThat(subscriber.getError().getMessage()).isEqualTo("cancelled");
await().until(() -> !changesSubscriber.isOpen());
}
Aggregations