public void testBackfillTaskJob() throws Exception {
TaskConfig task = defaultTask();
ConfigurationManager.applyDefaultsIfUnset(task);
task.unsetJob();
IScheduledTask noJobKey = IScheduledTask.build(new ScheduledTask()
.setStatus(RUNNING)
.setAssignedTask(new AssignedTask()
.setInstanceId(0)
.setTaskId("nojobkey")
.setTask(task)));
IScheduledTask nullJobKeyFields = IScheduledTask.build(new ScheduledTask()
.setStatus(RUNNING)
.setAssignedTask(new AssignedTask()
.setInstanceId(1)
.setTaskId("nulled_fields")
.setTask(task.setJob(new JobKey()))));
final Set<IScheduledTask> backfilledTasks = ImmutableSet.of(noJobKey, nullJobKeyFields);
storage.write(new Storage.MutateWork.NoResult.Quiet() {
@Override
protected void execute(Storage.MutableStoreProvider storeProvider) {
storeProvider.getUnsafeTaskStore().saveTasks(backfilledTasks);
}
});
backfill();
ScheduledTask noJobKeyBackfilled = noJobKey.newBuilder();
noJobKeyBackfilled.getAssignedTask().getTask()
.setJob(new JobKey(OWNER.getRole(), ENV, JOB_NAME));
ScheduledTask nullJobKeyFieldsBackfilled = nullJobKeyFields.newBuilder();
nullJobKeyFieldsBackfilled.getAssignedTask().getTask()
.setJob(new JobKey(OWNER.getRole(), ENV, JOB_NAME));
assertEquals(
ImmutableSet.of(
IScheduledTask.build(noJobKeyBackfilled),