use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest in project mantis by Netflix.
the class JobClusterTest method testZombieWorkerKilledOnMessage.
@Test
public void testZombieWorkerKilledOnMessage() {
String clusterName = "testZombieWorkerKilledOnMessage";
TestKit probe = new TestKit(system);
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 {
String jobId = clusterName + "-1";
WorkerId workerId = new WorkerId(clusterName, jobId, 0, 1);
WorkerEvent heartBeat2 = new WorkerHeartbeat(new Status(jobId, 1, workerId.getWorkerIndex(), workerId.getWorkerNum(), TYPE.HEARTBEAT, "", MantisJobState.Started, System.currentTimeMillis()));
jobClusterActor.tell(heartBeat2, probe.getRef());
jobClusterActor.tell(new GetJobClusterRequest(clusterName), probe.getRef());
GetJobClusterResponse resp = probe.expectMsgClass(GetJobClusterResponse.class);
assertEquals(clusterName, resp.getJobCluster().get().getName());
verify(schedulerMock, times(1)).unscheduleAndTerminateWorker(workerId, empty());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest in project mantis by Netflix.
the class JobClusterTest method testJobClusterUpdateAndDelete.
@Test
public void testJobClusterUpdateAndDelete() throws Exception {
TestKit probe = new TestKit(system);
List<Label> labels = Lists.newLinkedList();
Label l = new Label("labelname", "labelvalue");
labels.add(l);
String clusterName = "testJobClusterUpdateAndDelete";
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);
JobClusterConfig clusterConfig = new JobClusterConfig.Builder().withArtifactName("myart").withSchedulingInfo(SINGLE_WORKER_SCHED_INFO).withVersion("0.0.2").build();
final JobClusterDefinitionImpl updatedJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(clusterConfig).withName(clusterName).withParameters(Lists.newArrayList()).withLabels(labels).withUser(user).withIsReadyForJobMaster(true).withOwner(DEFAULT_JOB_OWNER).withMigrationConfig(WorkerMigrationConfig.DEFAULT).withSla(NO_OP_SLA).build();
jobClusterActor.tell(new UpdateJobClusterRequest(updatedJobCluster, "user"), probe.getRef());
UpdateJobClusterResponse resp = probe.expectMsgClass(UpdateJobClusterResponse.class);
assertEquals(SUCCESS, 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("Updated job cluster " + resp3.getJobCluster());
assertEquals(1, resp3.getJobCluster().get().getLabels().size());
assertEquals("labelname", resp3.getJobCluster().get().getLabels().get(0).getName());
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(1)).updateJobCluster(any());
verify(jobStoreMock, times(1)).deleteJobCluster(clusterName);
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest in project mantis by Netflix.
the class JobClusterTest method testJobClusterDisable.
@Test
public void testJobClusterDisable() throws InterruptedException {
TestKit probe = new TestKit(system);
CountDownLatch storeCompletedCalled = new CountDownLatch(1);
String clusterName = "testJobClusterDisable";
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";
IMantisJobMetadata completedJobMock = new MantisJobMetadataImpl.Builder().withJobId(new JobId(clusterName, 1)).withJobDefinition(jobDefn).withJobState(JobState.Completed).build();
when(jobStoreMock.getArchivedJob(any())).thenReturn(of(completedJobMock));
doAnswer((Answer) invocation -> {
storeCompletedCalled.countDown();
return null;
}).when(jobStoreMock).storeCompletedJobForCluster(any(), any());
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);
jobClusterActor.tell(new GetJobClusterRequest(clusterName), probe.getRef());
GetJobClusterResponse getJobClusterResp = probe.expectMsgClass(GetJobClusterResponse.class);
assertTrue(getJobClusterResp.getJobCluster().get().isDisabled());
jobClusterActor.tell(new GetJobDetailsRequest(clusterName, JobId.fromId(jobId).get()), probe.getRef());
GetJobDetailsResponse jobDetailsResp = probe.expectMsgClass(GetJobDetailsResponse.class);
assertEquals(SUCCESS, jobDetailsResp.responseCode);
assertEquals(jobId, jobDetailsResp.getJobMetadata().get().getJobId().getId());
assertEquals(JobState.Completed, jobDetailsResp.getJobMetadata().get().getState());
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(2)).updateJobCluster(any());
verify(jobStoreMock, times(1)).storeNewJob(any());
verify(jobStoreMock, times(1)).updateStage(any());
verify(jobStoreMock, times(2)).updateJob(any());
verify(jobStoreMock, times(1)).storeNewWorkers(any(), any());
storeCompletedCalled.await(1, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest in project mantis by Netflix.
the class JobClusterTest method testJobClusterInvalidSLAUpdateIgnored.
@Test
public void testJobClusterInvalidSLAUpdateIgnored() throws Exception {
TestKit probe = new TestKit(system);
String clusterName = "testJobClusterInvalidSLAUpdateIgnored";
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);
UpdateJobClusterSLARequest updateSlaReq = new UpdateJobClusterSLARequest(clusterName, 2, 1, "user");
jobClusterActor.tell(updateSlaReq, probe.getRef());
UpdateJobClusterSLAResponse resp = probe.expectMsgClass(UpdateJobClusterSLAResponse.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());
// No changes to original SLA
assertEquals(0, resp3.getJobCluster().get().getSla().getMin());
assertEquals(0, resp3.getJobCluster().get().getSla().getMax());
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(0)).updateJobCluster(any());
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest in project mantis by Netflix.
the class JobClusterTest method testJobClusterSLAUpdate.
// /////////////////////////////////////////// CLUSTER CRUD END ///////////////////////////////////////////////////////
// //////////////////////////// CLUSTER UPDATE FLAVORS ///////////////////////////////////////////////////////////////
@Test
public void testJobClusterSLAUpdate() throws Exception {
TestKit probe = new TestKit(system);
String clusterName = "testJobClusterSLAUpdate";
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);
SLA newSLA = new SLA(0, 10, null, null);
UpdateJobClusterSLARequest updateSlaReq = new UpdateJobClusterSLARequest(clusterName, newSLA.getMin(), newSLA.getMax(), "user");
jobClusterActor.tell(updateSlaReq, probe.getRef());
UpdateJobClusterSLAResponse resp = probe.expectMsgClass(UpdateJobClusterSLAResponse.class);
assertEquals(SUCCESS, 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("Updated job cluster " + resp3.getJobCluster());
assertEquals(newSLA, DataFormatAdapter.convertToSLA(resp3.getJobCluster().get().getSla()));
verify(jobStoreMock, times(1)).updateJobCluster(any());
verify(jobStoreMock, times(1)).createJobCluster(any());
}
Aggregations