Search in sources :

Example 11 with Cell

use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.

the class AggregatingHealthServiceTest method singleCell.

@Test
public void singleCell() {
    reset(connector);
    when(connector.getChannels()).thenReturn(Collections.singletonMap(new Cell("one", "1"), cellOne.getChannel()));
    when(connector.getChannelForCell(any())).thenReturn(Optional.of(cellOne.getChannel()));
    HealthCheckResponse one = HealthCheckResponse.newBuilder().setStatus(NOT_SERVING).addDetails(ServerStatus.newBuilder().setDetails(Details.newBuilder().setCell("one").setLeader(false).setActive(true).setUptime(Durations.fromMillis(clock.wallTime())).build()).build()).build();
    cellOne.getServiceRegistry().addService(new CellWithHealthStatus(one));
    AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
    subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
    subscriber.assertNoErrors();
    subscriber.assertValueCount(1);
    HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
    assertThat(response.getStatus()).isEqualTo(NOT_SERVING);
    assertThat(response.getDetailsCount()).isEqualTo(1);
    assertThat(response.getDetails(0).hasDetails()).isTrue();
    assertThat(response.getDetails(0).getDetails().getCell()).isEqualTo("one");
    assertThat(response.getDetails(0).getDetails().getLeader()).isFalse();
}
Also used : HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) Cell(com.netflix.titus.api.federation.model.Cell) Test(org.junit.Test)

Example 12 with Cell

use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayTest method createJobInjectsFederatedStackName.

@Test
public void createJobInjectsFederatedStackName() {
    Cell firstCell = cells.get(0);
    CellWithCachedJobsService cachedJobsService = new CellWithCachedJobsService(firstCell.getName());
    cellToServiceMap.get(firstCell).getServiceRegistry().addService(cachedJobsService);
    // Create the job and let it get routed
    JobDescriptor jobDescriptor = JobDescriptor.newBuilder().setApplicationName("app1").setCapacityGroup("app1CapGroup").build();
    String jobId = service.createJob(jobDescriptor, JobManagerConstants.UNDEFINED_CALL_METADATA).toBlocking().first();
    Optional<JobDescriptor> createdJob = cachedJobsService.getCachedJob(jobId);
    assertThat(createdJob).isPresent();
    assertThat(createdJob.get().getAttributesMap()).containsEntry(JOB_ATTRIBUTES_STACK, stackName);
}
Also used : JobDescriptor(com.netflix.titus.grpc.protogen.JobDescriptor) Cell(com.netflix.titus.api.federation.model.Cell) Test(org.junit.Test)

Example 13 with Cell

use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayTest method setUp.

@Before
public void setUp() {
    stackName = UUID.randomUUID().toString();
    GrpcConfiguration grpcConfiguration = mock(GrpcConfiguration.class);
    when(grpcConfiguration.getRequestTimeoutMs()).thenReturn(GRPC_REQUEST_TIMEOUT_MS);
    when(grpcConfiguration.getPrimaryFallbackTimeoutMs()).thenReturn(GRPC_PRIMARY_FALLBACK_TIMEOUT_MS);
    when(titusFederationConfiguration.getStack()).thenReturn(stackName);
    when(titusFederationConfiguration.getCells()).thenReturn("one=1;two=2");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("one=(app1.*|app2.*);two=(app3.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    cells = cellInfoResolver.resolve();
    cellToServiceMap = ImmutableMap.of(cells.get(0), cellOne, cells.get(1), cellTwo);
    RemoteFederationConnector fedConnector = mock(RemoteFederationConnector.class);
    when(fedConnector.getChannel()).thenReturn(remoteFederationRule.getChannel());
    CellConnector cellConnector = mock(CellConnector.class);
    when(cellConnector.getChannels()).thenReturn(cellToServiceMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, cellPairEntry -> cellPairEntry.getValue().getChannel())));
    when(cellConnector.getChannelForCell(any(Cell.class))).thenAnswer(invocation -> Optional.ofNullable(cellToServiceMap.get(invocation.<Cell>getArgument(0))).map(GrpcServerRule::getChannel));
    final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(cellConnector);
    service = new AggregatingJobServiceGateway(grpcConfiguration, titusFederationConfiguration, cellConnector, cellRouter, aggregatingCellClient, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcConfiguration), titusRuntime);
    clock = Clocks.test();
    dataGenerator = new ServiceDataGenerator(clock, TASKS_IN_GENERATED_JOBS);
}
Also used : ApplicationCellRouter(com.netflix.titus.federation.service.router.ApplicationCellRouter) Cell(com.netflix.titus.api.federation.model.Cell) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 14 with Cell

use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayWithSingleCellTest method setUp.

@Before
public void setUp() {
    stackName = UUID.randomUUID().toString();
    GrpcConfiguration grpcClientConfiguration = mock(GrpcConfiguration.class);
    when(grpcClientConfiguration.getRequestTimeoutMs()).thenReturn(1000L);
    TitusFederationConfiguration titusFederationConfiguration = mock(TitusFederationConfiguration.class);
    when(titusFederationConfiguration.getStack()).thenReturn(stackName);
    when(titusFederationConfiguration.getCells()).thenReturn("one=1");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("one=(app1.*|app2.*);two=(app3.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    List<Cell> cells = cellInfoResolver.resolve();
    cellToServiceMap = ImmutableMap.of(cells.get(0), cell);
    RemoteFederationConnector fedConnector = mock(RemoteFederationConnector.class);
    when(fedConnector.getChannel()).thenReturn(remoteFederationRule.getChannel());
    CellConnector cellConnector = mock(CellConnector.class);
    when(cellConnector.getChannels()).thenReturn(cellToServiceMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, cellPairEntry -> cellPairEntry.getValue().getChannel())));
    when(cellConnector.getChannelForCell(any(Cell.class))).thenAnswer(invocation -> Optional.ofNullable(cellToServiceMap.get(invocation.<Cell>getArgument(0))).map(GrpcServerRule::getChannel));
    final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(cellConnector);
    final AnonymousCallMetadataResolver anonymousCallMetadataResolver = new AnonymousCallMetadataResolver();
    service = new AggregatingJobServiceGateway(grpcClientConfiguration, titusFederationConfiguration, cellConnector, cellRouter, aggregatingCellClient, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcClientConfiguration), titusRuntime);
    clock = Clocks.test();
    dataGenerator = new ServiceDataGenerator(clock, TASKS_IN_GENERATED_JOBS);
}
Also used : TitusFederationConfiguration(com.netflix.titus.federation.startup.TitusFederationConfiguration) ApplicationCellRouter(com.netflix.titus.federation.service.router.ApplicationCellRouter) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) Cell(com.netflix.titus.api.federation.model.Cell) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 15 with Cell

use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.

the class ApplicationCellRouterTest method cellsWithNoRulesCanExist.

@Test
public void cellsWithNoRulesCanExist() {
    TitusFederationConfiguration titusFederationConfiguration = mock(TitusFederationConfiguration.class);
    when(titusFederationConfiguration.getCells()).thenReturn("cell1=hostName1:7001;cell2=hostName2:7002");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("cell1=(app1.*|app2.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    Cell cell = cellRouter.routeKey(APP_2).get();
    assertThat(cell.getName()).isEqualTo("cell1");
}
Also used : TitusFederationConfiguration(com.netflix.titus.federation.startup.TitusFederationConfiguration) CellInfoResolver(com.netflix.titus.federation.service.CellInfoResolver) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) Cell(com.netflix.titus.api.federation.model.Cell) Test(org.junit.Test)

Aggregations

Cell (com.netflix.titus.api.federation.model.Cell)16 Test (org.junit.Test)7 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)6 Before (org.junit.Before)6 TitusFederationConfiguration (com.netflix.titus.federation.startup.TitusFederationConfiguration)4 JobDescriptor (com.netflix.titus.grpc.protogen.JobDescriptor)4 ManagedChannel (io.grpc.ManagedChannel)4 ApplicationCellRouter (com.netflix.titus.federation.service.router.ApplicationCellRouter)3 JobManagementServiceStub (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub)3 AnonymousCallMetadataResolver (com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver)3 HashMap (java.util.HashMap)3 CellConnectorUtil.callToCell (com.netflix.titus.federation.service.CellConnectorUtil.callToCell)2 CellInfoResolver (com.netflix.titus.federation.service.CellInfoResolver)2 DefaultCellInfoResolver (com.netflix.titus.federation.service.DefaultCellInfoResolver)2 JobId (com.netflix.titus.grpc.protogen.JobId)2 JobManagementServiceGrpc (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc)2 CallbackCountDownLatch (com.netflix.titus.common.util.concurrency.CallbackCountDownLatch)1 EmitterWithMultipleSubscriptions (com.netflix.titus.common.util.rx.EmitterWithMultipleSubscriptions)1 HealthCheckResponse (com.netflix.titus.grpc.protogen.HealthCheckResponse)1 Job (com.netflix.titus.grpc.protogen.Job)1