aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject incubator-aurora git commit: Deny attempts to create a job update with a non-service job.
Date Wed, 04 Feb 2015 01:20:25 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 2742120e2 -> 9fe6d5408


Deny attempts to create a job update with a non-service job.

Bugs closed: AURORA-330

Reviewed at https://reviews.apache.org/r/30389/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/9fe6d540
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/9fe6d540
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/9fe6d540

Branch: refs/heads/master
Commit: 9fe6d5408d4aed113a239f22fa5c43aa4f9ae338
Parents: 2742120
Author: Bill Farner <wfarner@apache.org>
Authored: Tue Feb 3 17:05:58 2015 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue Feb 3 17:05:58 2015 -0800

----------------------------------------------------------------------
 .../thrift/SchedulerThriftInterface.java        |  4 +
 .../python/apache/aurora/client/cli/jobs.py     | 10 ++-
 .../thrift/SchedulerThriftInterfaceTest.java    | 93 ++++++++++++--------
 .../apache/aurora/client/cli/test_inspect.py    |  3 +-
 .../apache/aurora/client/cli/test_update.py     | 93 ++++++++++++++------
 .../python/apache/aurora/client/cli/util.py     |  5 +-
 6 files changed, 137 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 8c19f3b..2b5383f 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -1361,6 +1361,10 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
         .setEnvironment(mutableRequest.getTaskConfig().getEnvironment())
         .setName(mutableRequest.getTaskConfig().getJobName())));
 
+    if (!mutableRequest.getTaskConfig().isIsService()) {
+      return invalidResponse("Updates are not supported for non-service tasks.");
+    }
+
     JobUpdateSettings settings = requireNonNull(mutableRequest.getSettings());
     if (settings.getUpdateGroupSize() <= 0) {
       return invalidResponse("updateGroupSize must be positive.");

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/main/python/apache/aurora/client/cli/jobs.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/jobs.py b/src/main/python/apache/aurora/client/cli/jobs.py
index 7c53744..f18a791 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -734,11 +734,17 @@ class UpdateCommand(Verb):
     instances = (None if context.options.instance_spec.instance == ALL_INSTANCES else
         context.options.instance_spec.instance)
     config = context.get_job_config(job, context.options.config_file)
+
+    if not config.job().taskConfig.isService and not config.job().cronSchedule:
+      raise context.CommandError(
+          EXIT_COMMAND_FAILURE,
+          "Only service and cron jobs may be updated this way, "
+          "please kill and re-create your job instead.")
+
     api = context.get_api(config.cluster())
     if not context.options.force:
       self.warn_if_dangerous_change(context, api, job, config)
-    resp = api.update_job(config, context.options.healthcheck_interval_seconds,
-        instances)
+    resp = api.update_job(config, context.options.healthcheck_interval_seconds, instances)
     context.log_response_and_raise(resp, err_code=EXIT_COMMAND_FAILURE,
         err_msg="Update failed due to error:")
     context.print_out("Update completed successfully")

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 03d1fba..c6fe218 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -699,11 +699,18 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), DEFAULT_LOCK, SESSION));
   }
 
-  private IScheduledTask buildScheduledTask(int instanceId, long ramMb) {
+  private IScheduledTask buildTaskForJobUpdate(int instanceId) {
+    return buildTaskForJobUpdate(instanceId, "data");
+  }
+
+  private IScheduledTask buildTaskForJobUpdate(int instanceId, String executorData) {
     return IScheduledTask.build(new ScheduledTask()
         .setAssignedTask(new AssignedTask()
             .setInstanceId(instanceId)
-            .setTask(populatedTask().setRamMb(ramMb))));
+            .setTask(ConfigurationManager.applyDefaultsIfUnset(populatedTask()
+                .setRamMb(5)
+                .setIsService(true)
+                .setExecutorConfig(new ExecutorConfig().setData(executorData))))));
   }
 
   private IScheduledTask buildScheduledTask() {
@@ -2566,17 +2573,16 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
 
-    ITaskConfig newTask = buildScheduledTask(0, 8).getAssignedTask().getTask();
-    expect(taskIdGenerator.generate(newTask, 6))
-        .andReturn(TASK_ID);
+    ITaskConfig newTask = buildTaskForJobUpdate(0).getAssignedTask().getTask();
+    expect(taskIdGenerator.generate(newTask, 6)).andReturn(TASK_ID);
 
-    IScheduledTask oldTask1 = buildScheduledTask(0, 5);
-    IScheduledTask oldTask2 = buildScheduledTask(1, 5);
-    IScheduledTask oldTask3 = buildScheduledTask(2, 7);
-    IScheduledTask oldTask4 = buildScheduledTask(3, 7);
-    IScheduledTask oldTask5 = buildScheduledTask(4, 5);
-    IScheduledTask oldTask6 = buildScheduledTask(5, 5);
-    IScheduledTask oldTask7 = buildScheduledTask(6, 5);
+    IScheduledTask oldTask1 = buildTaskForJobUpdate(0, "old");
+    IScheduledTask oldTask2 = buildTaskForJobUpdate(1, "old");
+    IScheduledTask oldTask3 = buildTaskForJobUpdate(2, "old2");
+    IScheduledTask oldTask4 = buildTaskForJobUpdate(3, "old2");
+    IScheduledTask oldTask5 = buildTaskForJobUpdate(4, "old");
+    IScheduledTask oldTask6 = buildTaskForJobUpdate(5, "old");
+    IScheduledTask oldTask7 = buildTaskForJobUpdate(6, "old");
 
     IJobUpdate update = buildJobUpdate(6, newTask, ImmutableMap.of(
         oldTask1.getAssignedTask().getTask(), ImmutableSet.of(new Range(0, 1), new Range(4,
6)),
@@ -2612,16 +2618,17 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
 
-    ITaskConfig newTask = buildScheduledTask(0, 5).getAssignedTask().getTask();
-    expect(taskIdGenerator.generate(newTask, 1))
-        .andReturn(TASK_ID);
+    ITaskConfig newTask = buildTaskForJobUpdate(0).getAssignedTask().getTask();
+    expect(taskIdGenerator.generate(newTask, 1)).andReturn(TASK_ID);
 
-    IScheduledTask oldTask1 = buildScheduledTask(0, 5);
-    IScheduledTask oldTask2 = buildScheduledTask(1, 5);
+    IScheduledTask oldTask1 = buildTaskForJobUpdate(0);
+    IScheduledTask oldTask2 = buildTaskForJobUpdate(1);
 
     // Set instance count to 1 to generate empty desired state in diff.
-    IJobUpdate update = buildJobUpdate(1, newTask, ImmutableMap.of(
-        oldTask1.getAssignedTask().getTask(), ImmutableSet.of(new Range(0, 1))));
+    IJobUpdate update = buildJobUpdate(
+        1,
+        newTask,
+        ImmutableMap.of(oldTask1.getAssignedTask().getTask(), ImmutableSet.of(new Range(0,
1))));
 
     expect(quotaManager.checkJobUpdate(anyObject(IJobUpdate.class))).andReturn(ENOUGH_QUOTA);
 
@@ -2719,8 +2726,15 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
+  public void testStartUpdateFailsNonServiceTask() throws Exception {
+    control.replay();
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(false));
+    assertResponse(INVALID_REQUEST, thrift.startJobUpdate(request, SESSION));
+  }
+
+  @Test
   public void testStartUpdateFailsAuth() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(true));
     expectAuth(ROLE, false);
 
     control.replay();
@@ -2729,7 +2743,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testStartUpdateFailsForCronJob() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(true));
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(true);
 
@@ -2739,7 +2753,8 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testStartUpdateFailsConfigValidation() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setNumCpus(-1));
+    JobUpdateRequest request =
+        buildJobUpdateRequest(populatedTask().setIsService(true).setNumCpus(-1));
     expectAuth(ROLE, true);
 
     control.replay();
@@ -2751,9 +2766,9 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(uuidGenerator.createNew()).andReturn(UU_ID);
-    ITaskConfig newTask = buildScheduledTask(0, 5).getAssignedTask().getTask();
+    ITaskConfig newTask = buildTaskForJobUpdate(0).getAssignedTask().getTask();
 
-    IScheduledTask oldTask = buildScheduledTask(0, 5);
+    IScheduledTask oldTask = buildTaskForJobUpdate(0);
     storageUtil.expectTaskFetch(Query.unscoped().byJob(JOB_KEY).active(), oldTask);
 
     IJobUpdate update = buildJobUpdate(
@@ -2776,10 +2791,10 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(uuidGenerator.createNew()).andReturn(UU_ID);
 
-    IScheduledTask oldTask = buildScheduledTask(0, 5);
+    IScheduledTask oldTask = buildTaskForJobUpdate(0);
     storageUtil.expectTaskFetch(Query.unscoped().byJob(JOB_KEY).active(), oldTask);
 
-    ITaskConfig newTask = buildScheduledTask(0, 8).getAssignedTask().getTask();
+    ITaskConfig newTask = buildTaskForJobUpdate(0).getAssignedTask().getTask();
     JobUpdate builder = buildJobUpdate(
         1,
         newTask,
@@ -2795,7 +2810,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testStartUpdateFailsInstanceCountCheck() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(true));
     request.setInstanceCount(4001);
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
@@ -2810,7 +2825,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testStartUpdateFailsTaskIdLength() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(true));
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(uuidGenerator.createNew()).andReturn(UU_ID);
@@ -2826,12 +2841,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testStartUpdateFailsQuotaCheck() throws Exception {
-    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setIsService(true));
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(uuidGenerator.createNew()).andReturn(UU_ID);
 
-    IScheduledTask oldTask = buildScheduledTask(0, 5);
+    IScheduledTask oldTask = buildTaskForJobUpdate(0);
     storageUtil.expectTaskFetch(Query.unscoped().byJob(JOB_KEY).active(), oldTask);
     expect(taskIdGenerator.generate(ITaskConfig.build(request.getTaskConfig()), 6))
         .andReturn(TASK_ID);
@@ -2852,16 +2867,16 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     expectAuth(ROLE, true);
     expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
 
-    IScheduledTask oldTask = buildScheduledTask(0, 5);
-    ITaskConfig newTask = buildScheduledTask(0, 1024).getAssignedTask().getTask();
+    IScheduledTask oldTask = buildTaskForJobUpdate(0, "old");
+    ITaskConfig newTask = buildTaskForJobUpdate(0, "new").getAssignedTask().getTask();
 
-    IJobUpdate update = buildJobUpdate(1, newTask, ImmutableMap.of(
-        oldTask.getAssignedTask().getTask(), ImmutableSet.of(new Range(0, 0))
-    ));
+    IJobUpdate update = buildJobUpdate(
+        1,
+        newTask,
+        ImmutableMap.of(oldTask.getAssignedTask().getTask(), ImmutableSet.of(new Range(0,
0))));
 
     expect(uuidGenerator.createNew()).andReturn(UU_ID);
-    expect(taskIdGenerator.generate(ITaskConfig.build(populatedTask()), 1))
-        .andReturn(TASK_ID);
+    expect(taskIdGenerator.generate(newTask, 1)).andReturn(TASK_ID);
     expect(quotaManager.checkJobUpdate(update)).andReturn(ENOUGH_QUOTA);
     storageUtil.expectTaskFetch(Query.unscoped().byJob(JOB_KEY).active(), oldTask);
     jobUpdateController.start(update, USER);
@@ -3095,7 +3110,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   private static TaskConfig populatedTask() {
-    return defaultTask(true).setConstraints(ImmutableSet.of(
+    return defaultTask(true).setConstraints(Sets.newHashSet(
         new Constraint("host", TaskConstraint.limit(new LimitConstraint(1)))));
   }
 
@@ -3120,7 +3135,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     return new JobUpdateRequest()
         .setInstanceCount(6)
         .setSettings(buildJobUpdateSettings())
-        .setTaskConfig(config);
+        .setTaskConfig(ConfigurationManager.applyDefaultsIfUnset(config));
   }
 
   private static JobUpdateSettings buildJobUpdateSettings() {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/test/python/apache/aurora/client/cli/test_inspect.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_inspect.py b/src/test/python/apache/aurora/client/cli/test_inspect.py
index ae04776..452699c 100644
--- a/src/test/python/apache/aurora/client/cli/test_inspect.py
+++ b/src/test/python/apache/aurora/client/cli/test_inspect.py
@@ -26,7 +26,7 @@ from .util import AuroraClientCommandTest
 
 class TestInspectCommand(AuroraClientCommandTest):
   def get_job_config(self):
-    config = AuroraConfig(job=Job(
+    return AuroraConfig(job=Job(
       cluster='west',
       role='bozo',
       environment='test',
@@ -41,7 +41,6 @@ class TestInspectCommand(AuroraClientCommandTest):
       instances=3,
       cron_schedule='* * * * *'
     ))
-    return config
 
   def test_inspect_job(self):
     mock_stdout = []

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/test/python/apache/aurora/client/cli/test_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_update.py b/src/test/python/apache/aurora/client/cli/test_update.py
index c470ee6..9bfbbea 100644
--- a/src/test/python/apache/aurora/client/cli/test_update.py
+++ b/src/test/python/apache/aurora/client/cli/test_update.py
@@ -15,7 +15,8 @@ import contextlib
 import functools
 
 import pytest
-from mock import create_autospec, Mock, patch
+from mock import call, create_autospec, Mock, patch
+from pystachio import Empty
 from twitter.common.contextutil import temporary_file
 
 from apache.aurora.client.api.health_check import Retriable, StatusHealthCheck
@@ -27,6 +28,8 @@ from apache.aurora.client.cli.client import AuroraCommandLine
 from apache.aurora.client.cli.jobs import UpdateCommand
 from apache.aurora.client.cli.options import TaskInstanceKey
 from apache.aurora.config import AuroraConfig
+from apache.aurora.config.schema.base import Job
+from apache.thermos.config.schema_base import MB, Process, Resources, Task
 
 from .util import AuroraClientCommandTest, FakeAuroraCommandContext, IOMock, mock_verb_options
 
@@ -60,16 +63,26 @@ class TestJobUpdateCommand(AuroraClientCommandTest):
     self._mock_api = self._fake_context.get_api("test")
 
   @classmethod
-  def create_mock_config(cls, is_cron=False):
-    mock_config = create_autospec(spec=AuroraConfig, spec_set=True, instance=True)
-    mock_raw_config = Mock()
-    mock_raw_config.has_cron_schedule.return_value = is_cron
-    mock_config.raw = Mock(return_value=mock_raw_config)
-    return mock_config
+  def get_job_config(self, is_service=True, is_cron=False):
+    return AuroraConfig(job=Job(
+      cluster='west',
+      role='bozo',
+      environment='test',
+      name='the_job',
+      service=is_service,
+      cron_schedule='* * * * *' if is_cron else Empty,
+      task=Task(
+        name='task',
+        processes=[Process(cmdline='ls -la', name='process')],
+        resources=Resources(cpu=1.0, ram=1024 * MB, disk=1024 * MB)
+      ),
+      contact='bozo@the.clown',
+      instances=3,
+    ))
 
   def test_update_with_lock(self):
-    mock_config = self.create_mock_config()
-    self._fake_context.get_job_config = Mock(return_value=mock_config)
+    config = self.get_job_config()
+    self._fake_context.get_job_config = Mock(return_value=config)
     self._mock_api.update_job.return_value = self.create_blank_response(
         ResponseCode.LOCK_ERROR, "Error.")
 
@@ -77,14 +90,14 @@ class TestJobUpdateCommand(AuroraClientCommandTest):
       self._command.execute(self._fake_context)
 
     self._mock_api.update_job.assert_called_once_with(
-      mock_config,
+      config,
       self._mock_options.healthcheck_interval_seconds,
       self._mock_options.instance_spec.instance)
     self.assert_lock_message(self._fake_context)
 
   def test_update_print_error_once(self):
-    mock_config = self.create_mock_config()
-    self._fake_context.get_job_config = Mock(return_value=mock_config)
+    config = self.get_job_config()
+    self._fake_context.get_job_config = Mock(return_value=config)
     error = "Error printed once."
     self._mock_api.update_job.return_value = self.create_blank_response(
         ResponseCode.INVALID_REQUEST,
@@ -94,7 +107,7 @@ class TestJobUpdateCommand(AuroraClientCommandTest):
       self._command.execute(self._fake_context)
 
     self._mock_api.update_job.assert_called_once_with(
-      mock_config,
+      config,
       self._mock_options.healthcheck_interval_seconds,
       self._mock_options.instance_spec.instance)
     assert self._fake_context.get_err() == ["Update failed due to error:", "\t%s" % error]
@@ -103,16 +116,36 @@ class TestJobUpdateCommand(AuroraClientCommandTest):
     self._mock_options.instance_spec = TaskInstanceKey(self.TEST_JOBKEY, [1])
     self._mock_options.strict = True
 
-    mock_config = self.create_mock_config()
-    self._fake_context.get_job_config = Mock(return_value=mock_config)
+    config = self.get_job_config()
+    self._fake_context.get_job_config = Mock(return_value=config)
     self._mock_api.update_job.return_value = self.create_simple_success_response()
 
     self._command.execute(self._fake_context)
 
-    self._mock_api.update_job.assert_called_once_with(
-      mock_config,
-      self._mock_options.healthcheck_interval_seconds,
-      self._mock_options.instance_spec.instance)
+    assert self._mock_api.update_job.mock_calls == [
+        call(
+            config,
+            self._mock_options.healthcheck_interval_seconds,
+            self._mock_options.instance_spec.instance)]
+
+  def test_update_non_service(self):
+    self._fake_context.get_job_config = Mock(return_value=self.get_job_config(is_service=False))
+
+    # Command failure is the only expectation here, as the request was invalid.
+    with pytest.raises(Context.CommandError):
+      self._command.execute(self._fake_context)
+
+  def test_update_cron(self):
+    config = self.get_job_config(is_cron=True)
+    self._fake_context.get_job_config = Mock(return_value=config)
+    self._mock_api.update_job.return_value = self.create_simple_success_response()
+
+    self._command.execute(self._fake_context)
+    assert self._mock_api.update_job.mock_calls == [
+        call(
+            config,
+            self._mock_options.healthcheck_interval_seconds,
+            self._mock_options.instance_spec.instance)]
 
 
 class TestUpdateCommand(AuroraClientCommandTest):
@@ -133,7 +166,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
       mock_api = mock_context.get_api('west')
       mock_api.update_job.return_value = self.create_simple_success_response()
       with temporary_file() as fp:
-        fp.write(self.get_valid_config())
+        fp.write(self.get_service_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'update', '--force', self.TEST_JOBSPEC, fp.name])
@@ -261,6 +294,16 @@ class TestUpdateCommand(AuroraClientCommandTest):
     mock_job_monitor.wait_until.return_value = True
     return mock_job_monitor
 
+  @classmethod
+  def get_service_config(cls):
+    return cls.get_test_config(
+      cls.CONFIG_BASE,
+      cls.TEST_CLUSTER,
+      cls.TEST_ROLE,
+      cls.TEST_ENV,
+      cls.TEST_JOB,
+      inner='service=True,')
+
   def test_updater_simple(self):
     # Test the client-side updater logic in its simplest case: everything succeeds,
     # and no rolling updates. (Rolling updates are covered by the updater tests.)
@@ -285,7 +328,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
         patch('time.sleep', return_value=None),
         patch('threading._Event.wait')):
       with temporary_file() as fp:
-        fp.write(self.get_valid_config())
+        fp.write(self.get_service_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'update', 'west/bozo/test/hello', fp.name])
@@ -324,7 +367,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
         patch('time.sleep', return_value=None),
         patch('threading._Event.wait')):
       with temporary_file() as fp:
-        fp.write(self.get_valid_config())
+        fp.write(self.get_service_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'update', 'west/bozo/test/hello/1', fp.name])
@@ -361,7 +404,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
         patch('time.sleep', return_value=None),
         patch('threading._Event.wait')):
       with temporary_file() as fp:
-        fp.write(self.get_valid_config())
+        fp.write(self.get_service_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'update', 'west/bozo/test/hello', fp.name])
@@ -375,7 +418,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
     mock_job_monitor = self.setup_job_monitor()
     fake_mux = self.FakeSchedulerMux()
     self.setup_mock_scheduler_for_simple_update(mock_api, count=2)
-    config = self.get_valid_config()
+    config = self.get_service_config()
     config = config.replace("instances = 20", "instances = 2")
     with contextlib.nested(
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
@@ -404,7 +447,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
     fake_mux = self.FakeSchedulerMux()
     self.setup_mock_scheduler_for_simple_update(mock_api, count=20)
 
-    config = self.get_valid_config()
+    config = self.get_service_config()
     config = config.replace("instances = 20", "instances = 200")
     with contextlib.nested(
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fe6d540/src/test/python/apache/aurora/client/cli/util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/util.py b/src/test/python/apache/aurora/client/cli/util.py
index 5b6207d..12360c6 100644
--- a/src/test/python/apache/aurora/client/cli/util.py
+++ b/src/test/python/apache/aurora/client/cli/util.py
@@ -327,10 +327,9 @@ jobs = [HELLO_WORLD]
     return '%s/%s' % (cls.TEST_JOBSPEC, instances_spec)
 
   @classmethod
-  def get_test_config(cls, base, cluster, role, env, job, filler=''):
+  def get_test_config(cls, base, cluster, role, env, job, inner=''):
     """Create a config from the template"""
-    return base % {'job': job, 'role': role, 'env': env, 'cluster': cluster,
-        'inner': filler}
+    return base % {'job': job, 'role': role, 'env': env, 'cluster': cluster, 'inner': inner}
 
   @classmethod
   def get_unbound_test_config(cls, role=None, env=None, job=None):


Mime
View raw message