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();
}
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);
}
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);
}
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);
}
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");
}
Aggregations