use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.
the class JobClusterTest method testGetLastSubmittedJobSubject.
// //////////////////////////////// JOB SUBMIT OPERATIONS END/////////////////////////////////////////////////////////////
// //////////////////////////////// OTHER JOB OPERATIONS //////////////////////////////////////////////////////////////
@Test
public void testGetLastSubmittedJobSubject() {
TestKit probe = new TestKit(system);
String clusterName = "testGetLastSubmittedJobSubject";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
try {
jobClusterActor.tell(new GetLastSubmittedJobIdStreamRequest(clusterName), probe.getRef());
GetLastSubmittedJobIdStreamResponse getLastSubmittedJobIdStreamResponse = probe.expectMsgClass(GetLastSubmittedJobIdStreamResponse.class);
assertEquals(SUCCESS, getLastSubmittedJobIdStreamResponse.responseCode);
CountDownLatch jobIdLatch = new CountDownLatch(1);
assertTrue(getLastSubmittedJobIdStreamResponse.getjobIdBehaviorSubject().isPresent());
BehaviorSubject<JobId> jobIdBehaviorSubject = getLastSubmittedJobIdStreamResponse.getjobIdBehaviorSubject().get();
jobIdBehaviorSubject.subscribeOn(Schedulers.io()).subscribe((jId) -> {
System.out.println("Got Jid ------> " + jId);
String jIdStr = jId.getId();
assertEquals(clusterName + "-1", jIdStr);
jobIdLatch.countDown();
});
final JobDefinition jobDefn = createJob(clusterName, 1, MantisJobDurationType.Transient);
String jobId = clusterName + "-1";
JobTestHelper.submitJobAndVerifySuccess(probe, clusterName, jobClusterActor, jobDefn, jobId);
JobTestHelper.getJobDetailsAndVerify(probe, jobClusterActor, jobId, SUCCESS, JobState.Accepted);
jobIdLatch.await(1000, TimeUnit.SECONDS);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail();
}
// Mockito.doThrow(IOException.class).when(jobStoreMock).storeNewJob(any());
}
use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.
the class JobClusterTest method testJobClusterCreate.
// CLUSTER CRUD TESTS ///////////////////////////////////////////////////////////////////////////
@Test
public void testJobClusterCreate() throws Exception {
String name = "testJobClusterCreate";
TestKit probe = new TestKit(system);
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(name);
ActorRef jobClusterActor = system.actorOf(props(name, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
jobClusterActor.tell(new GetJobClusterRequest(name), probe.getRef());
GetJobClusterResponse resp2 = probe.expectMsgClass(GetJobClusterResponse.class);
System.out.println("resp2 " + resp2);
assertEquals(SUCCESS, resp2.responseCode);
assertEquals(name, resp2.getJobCluster().get().getName());
assertEquals("Nick", resp2.getJobCluster().get().getOwner().getName());
assertTrue(resp2.getJobCluster().get().getLabels().isEmpty());
assertEquals(1, resp2.getJobCluster().get().getJars().size());
jobClusterActor.tell(new JobClusterProto.DeleteJobClusterRequest(user, name, probe.getRef()), probe.getRef());
JobClusterProto.DeleteJobClusterResponse resp3 = probe.expectMsgClass(JobClusterProto.DeleteJobClusterResponse.class);
assertEquals(SUCCESS, resp3.responseCode);
assertEquals(jobClusterActor, probe.getLastSender());
// verify(jobStoreMock, times(1)).storeNewJob(any());
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(1)).deleteJobCluster(name);
probe.getSystem().stop(jobClusterActor);
}
use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.
the class JobClusterTest method testJobSubmit.
// //////////////////////////////////// CLUSTER UPDATE FLAVORS END ////////////////////////////////////////////////////
// //////////////////////////////////// JOB SUBMIT OPERATIONS /////////////////////////////////////////////////////////////
@Test
public void testJobSubmit() {
TestKit probe = new TestKit(system);
String clusterName = "testJobSubmit";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
try {
final JobDefinition jobDefn = createJob(clusterName, 1, MantisJobDurationType.Transient);
String jobId = clusterName + "-1";
JobTestHelper.submitJobAndVerifySuccess(probe, clusterName, jobClusterActor, jobDefn, jobId);
JobTestHelper.getJobDetailsAndVerify(probe, jobClusterActor, jobId, SUCCESS, JobState.Accepted);
JobTestHelper.killJobSendWorkerTerminatedAndVerify(probe, clusterName, new JobId(clusterName, 1), jobClusterActor, new WorkerId(jobId, 0, 1));
Thread.sleep(500);
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(1)).updateJobCluster(any());
verify(jobStoreMock, timeout(2000).times(1)).archiveJob(any());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail();
}
// Mockito.doThrow(IOException.class).when(jobStoreMock).storeNewJob(any());
}
use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.
the class JobClusterTest method testJobClusterDeletePurgesCompletedJobs.
@Test
public void testJobClusterDeletePurgesCompletedJobs() throws Exception {
TestKit probe = new TestKit(system);
List<Label> labels = Lists.newLinkedList();
Label l = new Label("labelname", "labelvalue");
labels.add(l);
String clusterName = "testJobClusterDeletePurgesCompletedJobs";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName, labels);
ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
final JobDefinition jobDefn = createJob(clusterName, 1, MantisJobDurationType.Transient);
String jobId = clusterName + "-1";
JobTestHelper.submitJobAndVerifySuccess(probe, clusterName, jobClusterActor, jobDefn, jobId);
JobTestHelper.getJobDetailsAndVerify(probe, jobClusterActor, jobId, SUCCESS, JobState.Accepted);
jobClusterActor.tell(new DisableJobClusterRequest(clusterName, "user"), probe.getRef());
DisableJobClusterResponse disableResp = probe.expectMsgClass(DisableJobClusterResponse.class);
assertEquals(SUCCESS, disableResp.responseCode);
Thread.sleep(1000);
jobClusterActor.tell(new JobClusterProto.DeleteJobClusterRequest(user, clusterName, probe.getRef()), probe.getRef());
JobClusterProto.DeleteJobClusterResponse resp4 = probe.expectMsgClass(JobClusterProto.DeleteJobClusterResponse.class);
assertEquals(SUCCESS, resp4.responseCode);
assertEquals(jobClusterActor, probe.getLastSender());
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(2)).updateJobCluster(any());
verify(jobStoreMock, times(1)).deleteJobCluster(clusterName);
verify(jobStoreMock, times(1)).storeCompletedJobForCluster(any(), any());
verify(jobStoreMock, times(1)).deleteJob("testJobClusterDeletePurgesCompletedJobs-1");
}
use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.
the class JobClusterTest method testJobClusterArtifactUpdateNotUniqueFails.
@Test
public void testJobClusterArtifactUpdateNotUniqueFails() throws Exception {
TestKit probe = new TestKit(system);
String clusterName = "testJobClusterArtifactUpdateNotUniqueFails";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
UpdateJobClusterArtifactRequest req = new UpdateJobClusterArtifactRequest(clusterName, "a1", "0.0.1", true, "user");
jobClusterActor.tell(req, probe.getRef());
UpdateJobClusterArtifactResponse resp = probe.expectMsgClass(UpdateJobClusterArtifactResponse.class);
assertEquals(CLIENT_ERROR, resp.responseCode);
assertEquals(jobClusterActor, probe.getLastSender());
jobClusterActor.tell(new GetJobClusterRequest(clusterName), probe.getRef());
GetJobClusterResponse resp3 = probe.expectMsgClass(GetJobClusterResponse.class);
assertEquals(SUCCESS, resp3.responseCode);
assertTrue(resp3.getJobCluster() != null);
System.out.println("Job cluster " + resp3.getJobCluster());
assertEquals(clusterName, resp3.getJobCluster().get().getName());
System.out.println("job cluster " + resp3.getJobCluster());
assertEquals(1, resp3.getJobCluster().get().getJars().size());
// assertEquals("a1", resp3.getJobCluster().getJobClusterDefinition().getJobClusterConfig().getArtifactName());
assertEquals("0.0.1", resp3.getJobCluster().get().getLatestVersion());
verify(jobStoreMock, times(0)).updateJobCluster(any());
verify(jobStoreMock, times(1)).createJobCluster(any());
}
Aggregations