Search in sources :

Example 1 with CellAssertions.assertCellInfo

use of com.netflix.titus.master.integration.v3.job.CellAssertions.assertCellInfo in project titus-control-plane by Netflix.

the class JobObserveTest method observeJobs.

@Test(timeout = LONG_TEST_TIMEOUT_MS)
public void observeJobs() throws InterruptedException {
    TestStreamObserver<JobChangeNotification> subscriber = subscribe(ObserveJobsQuery.getDefaultInstance());
    for (int i = 0; i < 2; i++) {
        String jobId = jobsScenarioBuilder.scheduleAndReturnJob(oneTaskBatchJobDescriptor(), jobScenarioBuilder -> jobScenarioBuilder.template(startTasksInNewJob()).template(ScenarioTemplates.killJob())).getId();
        JobChangeNotification event;
        while (true) {
            event = subscriber.takeNext(SHORT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
            if (event.hasJobUpdate()) {
                Job job = event.getJobUpdate().getJob();
                assertThat(job.getId()).isEqualTo(jobId);
                CellAssertions.assertCellInfo(job, EmbeddedTitusMaster.CELL_NAME);
                if (job.getStatus().getState() == JobState.Finished) {
                    break;
                }
            }
        }
    }
    subscriber.cancel();
}
Also used : Arrays(java.util.Arrays) JobDescriptorGenerator.serviceJobDescriptors(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.serviceJobDescriptors) JobModel(com.netflix.titus.api.jobmanager.model.job.JobModel) ObserveJobsQuery(com.netflix.titus.grpc.protogen.ObserveJobsQuery) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Job(com.netflix.titus.grpc.protogen.Job) ScenarioTemplates(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates) ScenarioTemplates.startTasksInNewJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.startTasksInNewJob) Image(com.netflix.titus.grpc.protogen.Image) ScenarioTemplates.killJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.killJob) JobState(com.netflix.titus.grpc.protogen.JobStatus.JobState) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) Owner(com.netflix.titus.api.jobmanager.model.job.Owner) SERVICE(com.netflix.titus.grpc.protogen.JobDescriptor.JobSpecCase.SERVICE) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TaskState(com.netflix.titus.grpc.protogen.TaskStatus.TaskState) EmbeddedTitusCells(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells) ImmutableMap(com.google.common.collect.ImmutableMap) Task(com.netflix.titus.grpc.protogen.Task) JobDescriptorGenerator.oneTaskBatchJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor) CellAssertions(com.netflix.titus.master.integration.v3.job.CellAssertions) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) RuleChain(org.junit.rules.RuleChain) TitusStackResource(com.netflix.titus.testkit.junit.master.TitusStackResource) Rule(org.junit.Rule) JobDescriptorGenerator.batchJobDescriptors(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.batchJobDescriptors) EmbeddedTitusMaster(com.netflix.titus.testkit.embedded.cell.master.EmbeddedTitusMaster) JobsScenarioBuilder(com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder) JobManagementServiceStub(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) Job(com.netflix.titus.grpc.protogen.Job) ScenarioTemplates.startTasksInNewJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.startTasksInNewJob) ScenarioTemplates.killJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.killJob) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)1 JobModel (com.netflix.titus.api.jobmanager.model.job.JobModel)1 Owner (com.netflix.titus.api.jobmanager.model.job.Owner)1 Image (com.netflix.titus.grpc.protogen.Image)1 Job (com.netflix.titus.grpc.protogen.Job)1 JobChangeNotification (com.netflix.titus.grpc.protogen.JobChangeNotification)1 SERVICE (com.netflix.titus.grpc.protogen.JobDescriptor.JobSpecCase.SERVICE)1 JobManagementServiceStub (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub)1 JobState (com.netflix.titus.grpc.protogen.JobStatus.JobState)1 ObserveJobsQuery (com.netflix.titus.grpc.protogen.ObserveJobsQuery)1 Task (com.netflix.titus.grpc.protogen.Task)1 TaskState (com.netflix.titus.grpc.protogen.TaskStatus.TaskState)1 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)1 CellAssertions (com.netflix.titus.master.integration.v3.job.CellAssertions)1 JobsScenarioBuilder (com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder)1 ScenarioTemplates (com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates)1 ScenarioTemplates.killJob (com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.killJob)1 ScenarioTemplates.startTasksInNewJob (com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.startTasksInNewJob)1 EmbeddedTitusCells (com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells)1