Search in sources :

Example 1 with UNDEFINED_CALL_METADATA

use of com.netflix.titus.api.jobmanager.service.JobManagerConstants.UNDEFINED_CALL_METADATA in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayTest method singleJobUpdates.

@Test
public void singleJobUpdates() {
    Random random = new Random();
    List<String> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobs(12)).stream().map(job -> job.getId()).collect(Collectors.toList());
    List<String> cellTwoSnapshot = new ArrayList<>(dataGenerator.newBatchJobs(7)).stream().map(job -> job.getId()).collect(Collectors.toList());
    CellWithJobIds cellOneService = new CellWithJobIds(cellOneSnapshot);
    CellWithJobIds cellTwoService = new CellWithJobIds(cellTwoSnapshot);
    cellOne.getServiceRegistry().addService(cellOneService);
    cellTwo.getServiceRegistry().addService(cellTwoService);
    String cellOneJobId = cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size()));
    String cellTwoJobId = cellTwoSnapshot.get(random.nextInt(cellTwoSnapshot.size()));
    assertThat(cellOneService.containsCapacityUpdates(cellOneJobId)).isFalse();
    assertThat(cellTwoService.containsCapacityUpdates(cellOneJobId)).isFalse();
    JobCapacityUpdate cellOneUpdate = JobCapacityUpdate.newBuilder().setJobId(cellOneJobId).setCapacity(Capacity.newBuilder().setMax(1).setDesired(2).setMax(3).build()).build();
    AssertableSubscriber<Void> testSubscriber = service.updateJobCapacity(cellOneUpdate, UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertNoValues();
    testSubscriber.assertCompleted();
    assertThat(cellOneService.containsCapacityUpdates(cellOneJobId)).isTrue();
    assertThat(cellTwoService.containsCapacityUpdates(cellOneJobId)).isFalse();
    testSubscriber.unsubscribe();
    JobCapacityUpdate cellTwoUpdate = JobCapacityUpdate.newBuilder().setJobId(cellTwoJobId).setCapacity(Capacity.newBuilder().setMax(2).setDesired(2).setMax(2).build()).build();
    testSubscriber = service.updateJobCapacity(cellTwoUpdate, UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertNoValues();
    testSubscriber.assertCompleted();
    assertThat(cellOneService.containsCapacityUpdates(cellTwoJobId)).isFalse();
    assertThat(cellTwoService.containsCapacityUpdates(cellTwoJobId)).isTrue();
    testSubscriber.unsubscribe();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ServiceTests.walkAllPages(com.netflix.titus.federation.service.ServiceTests.walkAllPages) Arrays(java.util.Arrays) NOT_FOUND(io.grpc.Status.NOT_FOUND) ObserveJobsQuery(com.netflix.titus.grpc.protogen.ObserveJobsQuery) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) JOB_ATTRIBUTES_STACK(com.netflix.titus.api.jobmanager.JobAttributes.JOB_ATTRIBUTES_STACK) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) Capacity(com.netflix.titus.grpc.protogen.Capacity) TaskUpdate(com.netflix.titus.grpc.protogen.JobChangeNotification.TaskUpdate) JobQueryResult(com.netflix.titus.grpc.protogen.JobQueryResult) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) TitusRuntimes(com.netflix.titus.common.runtime.TitusRuntimes) JobCapacityUpdate(com.netflix.titus.grpc.protogen.JobCapacityUpdate) Map(java.util.Map) After(org.junit.After) Status(io.grpc.Status) UNDEFINED_CALL_METADATA(com.netflix.titus.api.jobmanager.service.JobManagerConstants.UNDEFINED_CALL_METADATA) UNAVAILABLE(io.grpc.Status.UNAVAILABLE) TaskKillRequest(com.netflix.titus.grpc.protogen.TaskKillRequest) JobDescriptor(com.netflix.titus.grpc.protogen.JobDescriptor) ImmutableMap(com.google.common.collect.ImmutableMap) TaskQueryResult(com.netflix.titus.grpc.protogen.TaskQueryResult) Cell(com.netflix.titus.api.federation.model.Cell) Task(com.netflix.titus.grpc.protogen.Task) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) JobUpdate(com.netflix.titus.grpc.protogen.JobChangeNotification.JobUpdate) Optional(java.util.Optional) GrpcServerRule(io.grpc.testing.GrpcServerRule) TestClock(com.netflix.titus.common.util.time.TestClock) JobManagementServiceStub(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub) Mockito.any(org.mockito.Mockito.any) PublishSubject(rx.subjects.PublishSubject) ApplicationCellRouter(com.netflix.titus.federation.service.router.ApplicationCellRouter) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) JobId(com.netflix.titus.grpc.protogen.JobId) Assertions.assertThatCode(org.assertj.core.api.Assertions.assertThatCode) Mockito.mock(org.mockito.Mockito.mock) Iterables(com.google.common.collect.Iterables) JobManagerConstants(com.netflix.titus.api.jobmanager.service.JobManagerConstants) JobStatus(com.netflix.titus.grpc.protogen.JobStatus) Job(com.netflix.titus.grpc.protogen.Job) EventPropagationUtil(com.netflix.titus.common.util.event.EventPropagationUtil) ArrayList(java.util.ArrayList) AssertableSubscriber(rx.observers.AssertableSubscriber) TitusFederationConfiguration(com.netflix.titus.federation.startup.TitusFederationConfiguration) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) JobQuery(com.netflix.titus.grpc.protogen.JobQuery) INTERNAL(io.grpc.Status.INTERNAL) Pair(com.netflix.titus.common.util.tuple.Pair) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) LinkedList(java.util.LinkedList) SnapshotEnd(com.netflix.titus.grpc.protogen.JobChangeNotification.SnapshotEnd) TaskQuery(com.netflix.titus.grpc.protogen.TaskQuery) Before(org.junit.Before) Clocks(com.netflix.titus.common.util.time.Clocks) JobManagementServiceGrpc(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc) Test(org.junit.Test) GrpcJobManagementModelConverters(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters) Mockito.when(org.mockito.Mockito.when) DEADLINE_EXCEEDED(io.grpc.Status.DEADLINE_EXCEEDED) TimeUnit(java.util.concurrent.TimeUnit) StatusRuntimeException(io.grpc.StatusRuntimeException) GrpcJobQueryModelConverters.toGrpcPage(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobQueryModelConverters.toGrpcPage) Rule(org.junit.Rule) JobManagerCursors(com.netflix.titus.runtime.jobmanager.JobManagerCursors) Page(com.netflix.titus.api.model.Page) JOB_ATTRIBUTES_CELL(com.netflix.titus.api.jobmanager.JobAttributes.JOB_ATTRIBUTES_CELL) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) Collections(java.util.Collections) JobCapacityUpdate(com.netflix.titus.grpc.protogen.JobCapacityUpdate) Random(java.util.Random) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables (com.google.common.collect.Iterables)1 Cell (com.netflix.titus.api.federation.model.Cell)1 JOB_ATTRIBUTES_CELL (com.netflix.titus.api.jobmanager.JobAttributes.JOB_ATTRIBUTES_CELL)1 JOB_ATTRIBUTES_STACK (com.netflix.titus.api.jobmanager.JobAttributes.JOB_ATTRIBUTES_STACK)1 JobManagerConstants (com.netflix.titus.api.jobmanager.service.JobManagerConstants)1 UNDEFINED_CALL_METADATA (com.netflix.titus.api.jobmanager.service.JobManagerConstants.UNDEFINED_CALL_METADATA)1 Page (com.netflix.titus.api.model.Page)1 TitusServiceException (com.netflix.titus.api.service.TitusServiceException)1 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)1 TitusRuntimes (com.netflix.titus.common.runtime.TitusRuntimes)1 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)1 EventPropagationUtil (com.netflix.titus.common.util.event.EventPropagationUtil)1 Clocks (com.netflix.titus.common.util.time.Clocks)1 TestClock (com.netflix.titus.common.util.time.TestClock)1 Pair (com.netflix.titus.common.util.tuple.Pair)1 ServiceTests.walkAllPages (com.netflix.titus.federation.service.ServiceTests.walkAllPages)1 ApplicationCellRouter (com.netflix.titus.federation.service.router.ApplicationCellRouter)1 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)1 TitusFederationConfiguration (com.netflix.titus.federation.startup.TitusFederationConfiguration)1