Search in sources :

Example 11 with MantisJobStore

use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.

the class JobClusterTest method testJobSubmitFails.

@Test
public void testJobSubmitFails() {
    TestKit probe = new TestKit(system);
    try {
        String clusterName = "testJobSubmitFails";
        MantisScheduler schedulerMock = mock(MantisScheduler.class);
        MantisJobStore jobStoreMock = mock(MantisJobStore.class);
        final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
        Mockito.doThrow(Exception.class).when(jobStoreMock).storeNewJob(any());
        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";
        jobClusterActor.tell(new SubmitJobRequest(clusterName, "user", Optional.ofNullable(jobDefn)), probe.getRef());
        SubmitJobResponse submitResponse = probe.expectMsgClass(SubmitJobResponse.class);
        assertEquals(SERVER_ERROR, submitResponse.responseCode);
        verify(jobStoreMock, times(1)).createJobCluster(any());
        verify(jobStoreMock, times(1)).updateJobCluster(any());
        verify(jobStoreMock, times(0)).storeNewWorker(any());
        verify(jobStoreMock, times(0)).storeNewWorkers(any(), any());
    } catch (Exception e) {
        fail();
    }
}
Also used : JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) ActorRef(akka.actor.ActorRef) SubmitJobRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobRequest) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) SubmitJobResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse) Test(org.junit.Test)

Example 12 with MantisJobStore

use of io.mantisrx.server.master.persistence.MantisJobStore 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);
}
Also used : JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) ActorRef(akka.actor.ActorRef) Label(io.mantisrx.common.Label) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) UpdateJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterRequest) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) UpdateJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterResponse) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) Test(org.junit.Test)

Example 13 with MantisJobStore

use of io.mantisrx.server.master.persistence.MantisJobStore 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();
    }
}
Also used : TestHelpers(com.netflix.mantis.master.scheduler.TestHelpers) MantisJobDurationType(io.mantisrx.runtime.MantisJobDurationType) MantisJobState(io.mantisrx.runtime.MantisJobState) Optional.of(java.util.Optional.of) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) GetLastSubmittedJobIdStreamResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLastSubmittedJobIdStreamResponse) Mockito.doThrow(org.mockito.Mockito.doThrow) ListArchivedWorkersRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListArchivedWorkersRequest) UpdateJobClusterLabelsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterLabelsResponse) ActorRef(akka.actor.ActorRef) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) UpdateJobClusterArtifactResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterArtifactResponse) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Duration(java.time.Duration) Map(java.util.Map) JobClusterProtoAdapter(io.mantisrx.master.api.akka.route.proto.JobClusterProtoAdapter) Schedulers(rx.schedulers.Schedulers) MigrationStrategyEnum(io.mantisrx.runtime.WorkerMigrationConfig.MigrationStrategyEnum) AfterClass(org.junit.AfterClass) DisableJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterResponse) ScaleStageRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ScaleStageRequest) BaseResponse(io.mantisrx.master.jobcluster.proto.BaseResponse) Matchers.any(org.mockito.Matchers.any) CountDownLatch(java.util.concurrent.CountDownLatch) SubmitJobRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobRequest) WorkerState(io.mantisrx.master.jobcluster.job.worker.WorkerState) UpdateJobClusterWorkerMigrationStrategyRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyRequest) ListJobIdsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsRequest) Assert.assertFalse(org.junit.Assert.assertFalse) NamedJob(io.mantisrx.server.master.store.NamedJob) BehaviorSubject(rx.subjects.BehaviorSubject) Mockito.mock(org.mockito.Mockito.mock) Optional.empty(java.util.Optional.empty) IMantisStorageProvider(io.mantisrx.server.master.persistence.IMantisStorageProvider) SERVER_ERROR(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.SERVER_ERROR) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) ListJobIdsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsResponse) Mockito.timeout(org.mockito.Mockito.timeout) Answer(org.mockito.stubbing.Answer) LifecycleEventPublisherImpl(io.mantisrx.master.events.LifecycleEventPublisherImpl) JobTestHelper(io.mantisrx.master.jobcluster.job.JobTestHelper) WorkerEvent(io.mantisrx.server.master.scheduler.WorkerEvent) GetLastSubmittedJobIdStreamRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLastSubmittedJobIdStreamRequest) Label(io.mantisrx.common.Label) Config(com.typesafe.config.Config) EnableJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.EnableJobClusterRequest) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) TYPE(io.mantisrx.server.core.Status.TYPE) File(java.io.File) UpdateJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterRequest) UpdateJobClusterWorkerMigrationStrategyResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) MantisStorageProviderAdapter(io.mantisrx.server.master.persistence.MantisStorageProviderAdapter) Assert.assertEquals(org.junit.Assert.assertEquals) ListJobsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobsResponse) IMantisWorkerMetadata(io.mantisrx.master.jobcluster.job.worker.IMantisWorkerMetadata) EnableJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.EnableJobClusterResponse) JobState(io.mantisrx.master.jobcluster.job.JobState) JobCompletedReason(io.mantisrx.server.core.JobCompletedReason) StageDeploymentStrategy(io.mantisrx.runtime.descriptor.StageDeploymentStrategy) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) ListJobsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobsRequest) CLIENT_ERROR(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.CLIENT_ERROR) JobOwner(io.mantisrx.runtime.JobOwner) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) JobWorker(io.mantisrx.master.jobcluster.job.worker.JobWorker) GetJobDetailsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse) Assert.fail(org.junit.Assert.fail) ResubmitWorkerResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ResubmitWorkerResponse) StatusEventSubscriberLoggingImpl(io.mantisrx.master.events.StatusEventSubscriberLoggingImpl) Status(io.mantisrx.server.core.Status) DisableJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterRequest) ResubmitWorkerRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ResubmitWorkerRequest) WorkerEventSubscriberLoggingImpl(io.mantisrx.master.events.WorkerEventSubscriberLoggingImpl) UpdateJobClusterLabelsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterLabelsRequest) WorkerId(io.mantisrx.server.core.domain.WorkerId) List(java.util.List) ActorSystem(akka.actor.ActorSystem) GetJobDetailsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsRequest) SubmitJobResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse) StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) Optional(java.util.Optional) UpdateJobClusterSLARequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLARequest) ScaleStageResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ScaleStageResponse) MantisJobMetadataView(io.mantisrx.master.jobcluster.job.MantisJobMetadataView) UpdateJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterResponse) BeforeClass(org.junit.BeforeClass) WorkerTerminate(io.mantisrx.master.jobcluster.job.worker.WorkerTerminate) WorkerMigrationConfig(io.mantisrx.runtime.WorkerMigrationConfig) ListArchivedWorkersResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListArchivedWorkersResponse) MantisJobMetadataImpl(io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl) JobSla(io.mantisrx.runtime.JobSla) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) io.mantisrx.server.master.domain(io.mantisrx.server.master.domain) HashMap(java.util.HashMap) UpdateJobClusterSLAResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLAResponse) AuditEventSubscriberLoggingImpl(io.mantisrx.master.events.AuditEventSubscriberLoggingImpl) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) ConfigFactory(com.typesafe.config.ConfigFactory) MachineDefinition(io.mantisrx.runtime.MachineDefinition) ListJobCriteria(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobCriteria) Mockito.when(org.mockito.Mockito.when) TestKit(akka.testkit.javadsl.TestKit) SUCCESS(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.SUCCESS) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) JobClusterManagerProto(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto) Mockito(org.mockito.Mockito) Lists(io.mantisrx.shaded.com.google.common.collect.Lists) UpdateJobClusterArtifactRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterArtifactRequest) JobClusterActor.props(io.mantisrx.master.jobcluster.JobClusterActor.props) IMantisStageMetadata(io.mantisrx.master.jobcluster.job.IMantisStageMetadata) DeploymentStrategy(io.mantisrx.runtime.descriptor.DeploymentStrategy) LifecycleEventPublisher(io.mantisrx.master.events.LifecycleEventPublisher) WorkerHeartbeat(io.mantisrx.master.jobcluster.job.worker.WorkerHeartbeat) JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) ActorRef(akka.actor.ActorRef) GetJobDetailsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsRequest) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) CountDownLatch(java.util.concurrent.CountDownLatch) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) GetJobDetailsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse) DisableJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterResponse) DisableJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterRequest) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) Test(org.junit.Test)

Example 14 with MantisJobStore

use of io.mantisrx.server.master.persistence.MantisJobStore in project mantis by Netflix.

the class JobClusterTest method setup.

@BeforeClass
public static void setup() {
    Config config = ConfigFactory.parseString("akka {\n" + "  loggers = [\"akka.testkit.TestEventListener\"]\n" + "  loglevel = \"WARNING\"\n" + "  stdout-loglevel = \"WARNING\"\n" + "  test.single-expect-default = 1000 millis\n" + "}\n");
    system = ActorSystem.create("JobClusterTest", config.withFallback(ConfigFactory.load()));
    JobTestHelper.createDirsIfRequired();
    TestHelpers.setupMasterConfig();
    storageProvider = new MantisStorageProviderAdapter(new io.mantisrx.server.master.store.SimpleCachedFileStorageProvider(), eventPublisher);
    jobStore = new MantisJobStore(storageProvider);
}
Also used : MantisStorageProviderAdapter(io.mantisrx.server.master.persistence.MantisStorageProviderAdapter) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) Config(com.typesafe.config.Config) WorkerMigrationConfig(io.mantisrx.runtime.WorkerMigrationConfig) BeforeClass(org.junit.BeforeClass)

Example 15 with MantisJobStore

use of io.mantisrx.server.master.persistence.MantisJobStore 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());
}
Also used : JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) UpdateJobClusterSLARequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLARequest) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) ActorRef(akka.actor.ActorRef) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) UpdateJobClusterSLAResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLAResponse) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) Test(org.junit.Test)

Aggregations

MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)86 ActorRef (akka.actor.ActorRef)77 MantisScheduler (io.mantisrx.server.master.scheduler.MantisScheduler)76 Test (org.junit.Test)72 TestKit (akka.testkit.javadsl.TestKit)64 JobClusterProto (io.mantisrx.master.jobcluster.proto.JobClusterProto)47 InvalidJobException (io.mantisrx.runtime.command.InvalidJobException)45 Matchers.anyString (org.mockito.Matchers.anyString)44 WorkerId (io.mantisrx.server.core.domain.WorkerId)31 JobClusterManagerProto (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto)27 IOException (java.io.IOException)26 GetJobDetailsResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse)24 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)21 JobId (io.mantisrx.server.master.domain.JobId)19 MachineDefinition (io.mantisrx.runtime.MachineDefinition)16 GetJobClusterRequest (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest)15 GetJobClusterResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse)15 GetJobDetailsRequest (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsRequest)15 CountDownLatch (java.util.concurrent.CountDownLatch)13 FakeMantisScheduler (io.mantisrx.master.scheduler.FakeMantisScheduler)10