use of io.mantisrx.server.core.NamedJobInfo in project mantis by Netflix.
the class JobDiscoveryStreamRouteTest method testLastSubmittedJobIdStreamForNonExistentJob.
@Test
public void testLastSubmittedJobIdStreamForNonExistentJob() throws InterruptedException {
// The current behavior of Mantis client is to retry non-200 responses
// This test overrides the default retry/repeat behavior to test a namedjob info observable would complete if the job cluster requested is non-existent
final CountDownLatch latch = new CountDownLatch(1);
Observable<NamedJobInfo> jobSchedulingInfoObservable = mantisClient.namedJobInfo("testJobCluster", obs -> Observable.just(1), obs -> Observable.empty());
jobSchedulingInfoObservable.doOnNext(x -> logger.info("onNext {}", x)).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> {
logger.info("onCompleted");
latch.countDown();
}).subscribe();
latch.await();
}
use of io.mantisrx.server.core.NamedJobInfo in project mantis by Netflix.
the class SourceJobWorkerMetricsSubscriptionTest method testGetResultsForAllSourceJobs.
@Test
public void testGetResultsForAllSourceJobs() throws Exception {
List<SourceJobParameters.TargetInfo> infos = ImmutableList.of(new SourceJobParameters.TargetInfoBuilder().withSourceJobName("jobA").withQuery("criterion").withClientId("client1").build(), new SourceJobParameters.TargetInfoBuilder().withSourceJobName("jobA").withQuery("criterion").withClientId("client2").build(), new SourceJobParameters.TargetInfoBuilder().withSourceJobName("jobB").withQuery("criterion").withClientId("client1").build(), new SourceJobParameters.TargetInfoBuilder().withSourceJobName("jobB").withQuery("criterion").withClientId("client3").build());
MantisMasterClientApi masterClient = mock(MantisMasterClientApi.class);
SourceJobWorkerMetricsSubscription sub = spy(new SourceJobWorkerMetricsSubscription(infos, masterClient, null, new AutoScaleMetricsConfig()));
when(masterClient.namedJobInfo("jobA")).thenReturn(Observable.just(new NamedJobInfo("jobA", "jobA-1")));
when(masterClient.namedJobInfo("jobB")).thenReturn(Observable.just(new NamedJobInfo("jobA", "jobB-2")));
doReturn(Observable.just(Observable.just(new MantisServerSentEvent("jobA-event")))).when(sub).getResultsForJobId(eq("jobA-1"), any());
doReturn(Observable.just(Observable.just(new MantisServerSentEvent("jobB-event")))).when(sub).getResultsForJobId(eq("jobB-2"), any());
CountDownLatch latch = new CountDownLatch(2);
Observable.merge(sub.getResults()).doOnNext(event -> {
if ("jobA-event".equals(event.getEventAsString()) || "jobB-event".equals(event.getEventAsString())) {
latch.countDown();
}
}).subscribe();
latch.await(10, TimeUnit.SECONDS);
assertEquals(0, latch.getCount());
Set<String> jobAMetrics = ImmutableSet.of("PushServerSse:clientId=client1:*", "PushServerSse:clientId=client2:*", "ServerSentEventRequestHandler:clientId=client1:*", "ServerSentEventRequestHandler:clientId=client2:*");
verify(sub, times(1)).getResultsForJobId("jobA-1", jobAMetrics);
jobAMetrics = ImmutableSet.of("PushServerSse:clientId=client1:*", "PushServerSse:clientId=client3:*", "ServerSentEventRequestHandler:clientId=client1:*", "ServerSentEventRequestHandler:clientId=client3:*");
verify(sub, times(1)).getResultsForJobId("jobB-2", jobAMetrics);
}
use of io.mantisrx.server.core.NamedJobInfo in project mantis by Netflix.
the class JobDiscoveryRouteTest method testNamedJobInfoStreamForNonExistentJob.
@Test
public void testNamedJobInfoStreamForNonExistentJob() throws InterruptedException {
// The current behavior of Mantis client is to retry non-200 responses
// This test overrides the default retry/repeat behavior to test a namedjob info observable would complete if the job cluster requested is non-existent
final CountDownLatch latch = new CountDownLatch(1);
Observable<NamedJobInfo> jobSchedulingInfoObservable = mantisClient.namedJobInfo("testJobCluster", obs -> Observable.just(1), obs -> Observable.empty());
jobSchedulingInfoObservable.doOnNext(x -> logger.info("onNext {}", x)).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> {
logger.info("onCompleted");
latch.countDown();
}).subscribe();
latch.await();
}
use of io.mantisrx.server.core.NamedJobInfo in project mantis by Netflix.
the class JobRouteTest method testNamedJobInfoStream.
@Test(dependsOnMethods = { "testJobClusterGetJobsCompact" })
public void testNamedJobInfoStream() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String jobCluster = "sine-function";
Observable<NamedJobInfo> namedJobInfo = mantisClient.namedJobInfo(jobCluster);
namedJobInfo.doOnNext(lastSubmittedJobId -> {
logger.info("namedJobInfo {} {}", lastSubmittedJobId.getName(), lastSubmittedJobId.getJobId());
try {
lastSubmittedJobId.getName();
assertEquals("sine-function", lastSubmittedJobId.getName());
assertEquals("sine-function-1", lastSubmittedJobId.getJobId());
} catch (Exception e) {
logger.error("caught exception", e);
org.testng.Assert.fail("testNamedJobInfoStream test failed with exception " + e.getMessage(), e);
}
latch.countDown();
}).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> logger.info("onCompleted")).doAfterTerminate(() -> latch.countDown()).subscribe();
latch.await();
}
Aggregations