Search in sources :

Example 1 with JobsScenarioBuilder

use of com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder in project titus-control-plane by Netflix.

the class V3JobSchedulingAndRebootTest method submitBatchJobAndRebootTitusMaster.

@Test(timeout = LONG_TEST_TIMEOUT_MS)
public void submitBatchJobAndRebootTitusMaster() {
    jobsScenarioBuilder.schedule(ONE_TASK_BATCH_JOB, jobScenarioBuilder -> jobScenarioBuilder.template(ScenarioTemplates.startTasksInNewJob()));
    jobsScenarioBuilder.stop();
    titusStackResource.getMaster().reboot();
    JobsScenarioBuilder newJobsScenarioBuilder = new JobsScenarioBuilder(titusStackResource.getOperations());
    newJobsScenarioBuilder.assertJobs(jobs -> jobs.size() == 1).takeJob(0).assertJob(JobAsserts.jobInState(JobState.Accepted)).assertTasks(tasks -> tasks.size() == 1);
}
Also used : BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) JobDescriptorGenerator.oneTaskBatchJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor) ScenarioTemplates(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates) JobAsserts(com.netflix.titus.master.integration.v3.scenario.JobAsserts) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test) V3_ENGINE_APP_PREFIX(com.netflix.titus.testkit.junit.master.TitusStackResource.V3_ENGINE_APP_PREFIX) Category(org.junit.experimental.categories.Category) RuleChain(org.junit.rules.RuleChain) TitusStackResource(com.netflix.titus.testkit.junit.master.TitusStackResource) Rule(org.junit.Rule) EmbeddedTitusCells.basicKubeCell(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells.basicKubeCell) JobState(com.netflix.titus.api.jobmanager.model.job.JobState) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobsScenarioBuilder(com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder) JobsScenarioBuilder(com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 2 with JobsScenarioBuilder

use of com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder in project titus-control-plane by Netflix.

the class JobsScenarioBuilder method schedule.

public JobsScenarioBuilder schedule(JobDescriptor<?> jobDescriptor, int times, Function<JobScenarioBuilder, JobScenarioBuilder> jobScenario) throws Exception {
    String sequence = jobDescriptor.getJobGroupInfo().getSequence();
    for (int i = 0; i < times; i++) {
        int finalI = i;
        JobDescriptor effective = sequence.isEmpty() ? jobDescriptor : jobDescriptor.but(jd -> jd.getJobGroupInfo().toBuilder().withSequence(sequence + '_' + finalI));
        schedule(effective, jobScenario);
    }
    return this;
}
Also used : TitusMasterResource(com.netflix.titus.testkit.junit.master.TitusMasterResource) LoggerFactory(org.slf4j.LoggerFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) JobQuery(com.netflix.titus.grpc.protogen.JobQuery) JobQueryResult(com.netflix.titus.grpc.protogen.JobQueryResult) EmbeddedTitusOperations(com.netflix.titus.testkit.embedded.EmbeddedTitusOperations) TIMEOUT_MS(com.netflix.titus.master.integration.v3.scenario.ScenarioBuilderUtil.TIMEOUT_MS) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) Job(com.netflix.titus.api.jobmanager.model.job.Job) Logger(org.slf4j.Logger) Predicate(java.util.function.Predicate) JobManagementServiceGrpc(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc) GrpcJobManagementModelConverters(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters) Collectors(java.util.stream.Collectors) Page(com.netflix.titus.grpc.protogen.Page) TimeUnit(java.util.concurrent.TimeUnit) TitusStackResource(com.netflix.titus.testkit.junit.master.TitusStackResource) List(java.util.List) ExternalResource(org.junit.rules.ExternalResource) Preconditions(com.google.common.base.Preconditions) ExceptionExt.rethrow(com.netflix.titus.common.util.ExceptionExt.rethrow) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) JobId(com.netflix.titus.grpc.protogen.JobId) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor)

Aggregations

JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 TitusStackResource (com.netflix.titus.testkit.junit.master.TitusStackResource)2 Preconditions (com.google.common.base.Preconditions)1 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 JobState (com.netflix.titus.api.jobmanager.model.job.JobState)1 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)1 ExceptionExt.rethrow (com.netflix.titus.common.util.ExceptionExt.rethrow)1 JobChangeNotification (com.netflix.titus.grpc.protogen.JobChangeNotification)1 JobId (com.netflix.titus.grpc.protogen.JobId)1 JobManagementServiceGrpc (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc)1 JobQuery (com.netflix.titus.grpc.protogen.JobQuery)1 JobQueryResult (com.netflix.titus.grpc.protogen.JobQueryResult)1 Page (com.netflix.titus.grpc.protogen.Page)1 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)1 JobAsserts (com.netflix.titus.master.integration.v3.scenario.JobAsserts)1 JobsScenarioBuilder (com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder)1 TIMEOUT_MS (com.netflix.titus.master.integration.v3.scenario.ScenarioBuilderUtil.TIMEOUT_MS)1 ScenarioTemplates (com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates)1 GrpcJobManagementModelConverters (com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters)1 EmbeddedTitusOperations (com.netflix.titus.testkit.embedded.EmbeddedTitusOperations)1