Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove schedules from jobs made dependent when previously scheduled #635

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class DependentJobResource @Inject()(
}
jobScheduler.removeSchedule(j)
case j: ScheduleBasedJob =>
log.info("Removing schedule for job: %s".format(j))
jobScheduler.removeSchedule(j)
parents.foreach(p => jobGraph.addDependency(p.name, newJob.name))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@ class JobSchedulerIntegrationTest extends SpecificationWithJUnit with Mockito {
there was no(mockTaskManager).enqueue(TaskUtils.getTaskId(job3, DateTime.parse(vJob2.lastError), 0), highPriority = false)
}

"Tests that scheduled jobs changed to dependent jobs remove their schedules" in {
val epsilon = Minutes.minutes(1).toPeriod
val job1 = new ScheduleBasedJob(schedule = "R/2012-01-01T00:05:00.000Z/PT10M",
name = "job1", command = "fooo", epsilon = epsilon, disabled = false)
val job2 = new ScheduleBasedJob(schedule = "R/2012-01-01T00:05:00.000Z/PT10M",
name = "job2", command = "fooo", epsilon = epsilon, disabled = false)
val horizon = Minutes.minutes(5).toPeriod
val mockTaskManager = mock[TaskManager]
val graph = new JobGraph()
val mockPersistenceStore = mock[PersistenceStore]
val mockedScheduler = mock[JobScheduler]
val scheduler = mockScheduler(horizon, mockTaskManager, graph, mockPersistenceStore)
scheduler.leader.set(true)
val date = DateTime.parse("2012-01-01T00:00:00.000Z")
scheduler.registerJob(job1, persist = true, date)
scheduler.registerJob(job2, persist = true, date)
val dependentJob2 = new DependencyBasedJob(Set("job1"), name = "job2", command = "CMD", disabled = false)
val jobResource = new DependentJobResource(jobScheduler = mockedScheduler, jobGraph = graph)

jobResource.handleRequest(dependentJob2)
there was one(mockedScheduler).removeSchedule(job2)
there was one(mockedScheduler).updateJob(job2, dependentJob2)
}

"Tests that dependent jobs runs when they should after changing the jobgraph" in {
val epsilon = Minutes.minutes(20).toPeriod
val job1 = new ScheduleBasedJob(schedule = "R/2012-01-01T00:01:00.000Z/PT1M",
Expand Down