}
@Test
public void testRewriteShard() throws Exception {
TaskConfig storedConfig = productionTask();
ITaskConfig modifiedConfig = ITaskConfig.build(
storedConfig.deepCopy().setExecutorConfig(new ExecutorConfig("aurora", "rewritten")));
String taskId = "task_id";
IScheduledTask storedTask = IScheduledTask.build(new ScheduledTask().setAssignedTask(
new AssignedTask()
.setTaskId(taskId)
.setTask(storedConfig)));
InstanceKey instanceKey = new InstanceKey(
JobKeys.from(
storedConfig.getOwner().getRole(),
storedConfig.getEnvironment(),
storedConfig.getJobName()).newBuilder(),
0);
expectAuth(ROOT, true);
storageUtil.expectTaskFetch(Query.instanceScoped(instanceKey).active(), storedTask);
expect(storageUtil.taskStore.unsafeModifyInPlace(
taskId,
ITaskConfig.build(ConfigurationManager.applyDefaultsIfUnset(modifiedConfig.newBuilder()))))
.andReturn(true);
control.replay();
RewriteConfigsRequest request = new RewriteConfigsRequest(
ImmutableList.of(ConfigRewrite.instanceRewrite(
new InstanceConfigRewrite(instanceKey, storedConfig, modifiedConfig.newBuilder()))));
assertOkResponse(thrift.rewriteConfigs(request, SESSION));
}