aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [1/2] Implementing parallel updater.
Date Wed, 23 Jul 2014 17:08:11 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 2b78affb3 -> e1c0ade29


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/cli/test_kill.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_kill.py b/src/test/python/apache/aurora/client/cli/test_kill.py
index 48badec..ee64908 100644
--- a/src/test/python/apache/aurora/client/cli/test_kill.py
+++ b/src/test/python/apache/aurora/client/cli/test_kill.py
@@ -63,7 +63,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     mock_context = FakeAuroraCommandContext()
     mock_scheduler_proxy = Mock()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
 
@@ -90,7 +90,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     mock_context = FakeAuroraCommandContext()
     mock_scheduler_proxy = Mock()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
 
@@ -119,7 +119,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     mock_context = FakeAuroraCommandContext()
     mock_scheduler_proxy = Mock()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
 
@@ -145,7 +145,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -170,7 +170,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -192,7 +192,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -217,7 +217,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -244,7 +244,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -293,7 +293,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -317,7 +317,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     (mock_api, mock_scheduler_proxy) = self.create_mock_api()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/cli/test_restart.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_restart.py b/src/test/python/apache/aurora/client/cli/test_restart.py
index e85951a..14a08e8 100644
--- a/src/test/python/apache/aurora/client/cli/test_restart.py
+++ b/src/test/python/apache/aurora/client/cli/test_restart.py
@@ -61,7 +61,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
@@ -91,7 +91,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
@@ -114,7 +114,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)):
+        patch('threading._Event.wait')):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
@@ -137,7 +137,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)) as (mock_log, _, _, _, _, _):
+        patch('threading._Event.wait')) as (mock_log, _, _, _, _, _):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
@@ -168,7 +168,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)):
+        patch('threading._Event.wait')):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/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 c6440e4..8b7d112 100644
--- a/src/test/python/apache/aurora/client/cli/test_update.py
+++ b/src/test/python/apache/aurora/client/cli/test_update.py
@@ -20,7 +20,7 @@ from twitter.common.contextutil import temporary_file
 from apache.aurora.client.api.health_check import Retriable, StatusHealthCheck
 from apache.aurora.client.api.job_monitor import JobMonitor
 from apache.aurora.client.api.quota_check import QuotaCheck
-from apache.aurora.client.api.updater import Updater
+from apache.aurora.client.api.scheduler_mux import SchedulerMux
 from apache.aurora.client.cli import EXIT_INVALID_CONFIGURATION
 from apache.aurora.client.cli.client import AuroraCommandLine
 from apache.aurora.client.cli.util import AuroraClientCommandTest, FakeAuroraCommandContext
@@ -44,24 +44,13 @@ from gen.apache.aurora.api.ttypes import (
 
 
 class TestUpdateCommand(AuroraClientCommandTest):
+  class FakeSchedulerMux(SchedulerMux):
+    def enqueue_and_wait(self, command, data, aggregator=None, timeout=None):
+      return command([data])
 
-  @classmethod
-  def setup_mock_options(cls):
-    """set up to get a mock options object."""
-    mock_options = Mock()
-    mock_options.json = False
-    mock_options.bindings = {}
-    mock_options.open_browser = False
-    mock_options.cluster = None
-    mock_options.force = True
-    mock_options.env = None
-    mock_options.shards = None
-    mock_options.health_check_interval_seconds = 3
-    return mock_options
+    def terminate(self):
+      pass
 
-  @classmethod
-  def setup_mock_updater(cls):
-    return Mock(spec=Updater)
 
   # First, we pretend that the updater isn't really client-side, and test
   # that the client makes the right API call to the updated.
@@ -194,11 +183,12 @@ class TestUpdateCommand(AuroraClientCommandTest):
 
   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 updated tests.)
+    # and no rolling updates. (Rolling updates are covered by the updater tests.)
     (mock_api, mock_scheduler_proxy) = self.create_mock_api()
     mock_health_check = self.setup_health_checks(mock_api)
     mock_quota_check = self.setup_quota_check()
     mock_job_monitor = self.setup_job_monitor()
+    fake_mux = self.FakeSchedulerMux()
     self.setup_mock_scheduler_for_simple_update(mock_api)
     # This doesn't work, because:
     # - The mock_context stubs out the API.
@@ -210,8 +200,9 @@ class TestUpdateCommand(AuroraClientCommandTest):
             return_value=mock_health_check),
         patch('apache.aurora.client.api.updater.JobMonitor', return_value=mock_job_monitor),
         patch('apache.aurora.client.api.updater.QuotaCheck', return_value=mock_quota_check),
+        patch('apache.aurora.client.api.updater.SchedulerMux', return_value=fake_mux),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)):
+        patch('threading._Event.wait')):
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
@@ -235,19 +226,19 @@ class TestUpdateCommand(AuroraClientCommandTest):
 
   @classmethod
   def assert_correct_addinstance_calls(cls, api):
-    assert api.addInstances.call_count == 4
+    assert api.addInstances.call_count == 20
     last_addinst = api.addInstances.call_args
     assert isinstance(last_addinst[0][0], AddInstancesConfig)
-    assert last_addinst[0][0].instanceIds == frozenset([15, 16, 17, 18, 19])
+    assert last_addinst[0][0].instanceIds == frozenset([19])
     assert last_addinst[0][0].key == JobKey(environment='test', role='bozo', name='hello')
 
   @classmethod
   def assert_correct_killtask_calls(cls, api):
-    assert api.killTasks.call_count == 4
+    assert api.killTasks.call_count == 20
     # Check the last call's parameters.
     api.killTasks.assert_called_with(
         TaskQuery(taskIds=None, jobName='hello', environment='test',
-            instanceIds=frozenset([16, 17, 18, 19, 15]),
+            instanceIds=frozenset([19]),
             owner=Identity(role=u'bozo', user=None),
            statuses=ACTIVE_STATES),
         'foo')
@@ -256,8 +247,9 @@ class TestUpdateCommand(AuroraClientCommandTest):
   def assert_correct_status_calls(cls, api):
     # getTasksWithoutConfigs gets called a lot of times. The exact number isn't fixed; it
loops
     # over the health checks until all of them pass for a configured period of time.
-    # The minumum number of calls is 4: once for each batch of restarts (Since the batch
size
-    # is set to 5, and the total number of jobs is 20, that's 4 batches.)
+    # The minumum number of calls is 20: once before the tasks are restarted, and then
+    # once for each batch of restarts (Since the batch size is set to 1, and the
+    # total number of tasks is 20, that's 20 batches.)
     assert api.getTasksWithoutConfigs.call_count >= 4
 
     status_calls = api.getTasksWithoutConfigs.call_args_list

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/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 fb849f0..5d2e72d 100644
--- a/src/test/python/apache/aurora/client/cli/util.py
+++ b/src/test/python/apache/aurora/client/cli/util.py
@@ -185,7 +185,7 @@ HELLO_WORLD = Job(
   instances = 20,
   %(inner)s
   update_config = UpdateConfig(
-    batch_size = 5,
+    batch_size = 1,
     restart_threshold = 60,
     watch_secs = 45,
     max_per_shard_failures = 2,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/commands/test_create.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_create.py b/src/test/python/apache/aurora/client/commands/test_create.py
index b8df1f2..7503345 100644
--- a/src/test/python/apache/aurora/client/commands/test_create.py
+++ b/src/test/python/apache/aurora/client/commands/test_create.py
@@ -143,7 +143,7 @@ class TestClientCreateCommand(AuroraClientCommandTest):
     mock_options = self.setup_mock_options()
     (mock_api, mock_scheduler_proxy) = self.create_mock_api()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.commands.core.make_client', return_value=mock_api),
         patch('twitter.common.app.get_options', return_value=mock_options)) as (sleep, make_client,
         options):
@@ -200,7 +200,7 @@ class TestClientCreateCommand(AuroraClientCommandTest):
     mock_options = self.setup_mock_options()
     (mock_api, mock_scheduler_proxy) = self.create_mock_api()
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.commands.core.make_client', return_value=mock_api),
         patch('twitter.common.app.get_options', return_value=mock_options)) as (sleep, make_client,
         options):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/commands/test_kill.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_kill.py b/src/test/python/apache/aurora/client/commands/test_kill.py
index 642ee64..3e6d048 100644
--- a/src/test/python/apache/aurora/client/commands/test_kill.py
+++ b/src/test/python/apache/aurora/client/commands/test_kill.py
@@ -113,7 +113,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     ]
     mock_scheduler_proxy.getTasksWithoutConfigs.side_effect = mock_query_results
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.factory.make_client', return_value=mock_api),
         patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
@@ -212,7 +212,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     ]
     mock_scheduler_proxy.getTasksWithoutConfigs.side_effect = mock_query_results
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.commands.core.make_client',
             return_value=mock_api),
         patch('twitter.common.app.get_options', return_value=mock_options),
@@ -352,7 +352,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     ]
     mock_scheduler_proxy.getTasksWithoutConfigs.side_effect = mock_query_results
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.factory.make_client', return_value=mock_api),
         patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
@@ -386,7 +386,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
     ]
     mock_scheduler_proxy.getTasksWithoutConfigs.side_effect = mock_query_results
     with contextlib.nested(
-        patch('time.sleep'),
+        patch('threading._Event.wait'),
         patch('apache.aurora.client.factory.make_client', return_value=mock_api),
         patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/commands/test_restart.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_restart.py b/src/test/python/apache/aurora/client/commands/test_restart.py
index b95e7ff..0b71bbb 100644
--- a/src/test/python/apache/aurora/client/commands/test_restart.py
+++ b/src/test/python/apache/aurora/client/commands/test_restart.py
@@ -113,7 +113,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ) as (options, scheduler_proxy_class, test_clusters, mock_health_check_factory,
         time_patch, sleep_patch):
 
@@ -146,7 +146,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ) as (options, scheduler_proxy_class, test_clusters, mock_health_check_factory,
         time_patch, sleep_patch):
 
@@ -175,7 +175,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ) as (options, scheduler_proxy_class, test_clusters, mock_health_check_factory,
         time_patch, sleep_patch):
 
@@ -201,7 +201,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.api.instance_watcher.StatusHealthCheck',
             return_value=mock_health_check),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
     ) as (options, scheduler_proxy_class, test_clusters, mock_health_check_factory,
         time_patch, sleep_patch):
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/commands/test_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_update.py b/src/test/python/apache/aurora/client/commands/test_update.py
index 114ac01..85b8423 100644
--- a/src/test/python/apache/aurora/client/commands/test_update.py
+++ b/src/test/python/apache/aurora/client/commands/test_update.py
@@ -21,6 +21,7 @@ from twitter.common.contextutil import temporary_file
 from apache.aurora.client.api.health_check import Retriable, StatusHealthCheck
 from apache.aurora.client.api.job_monitor import JobMonitor
 from apache.aurora.client.api.quota_check import QuotaCheck
+from apache.aurora.client.api.scheduler_mux import SchedulerMux
 from apache.aurora.client.api.updater import Updater
 from apache.aurora.client.commands.core import update
 from apache.aurora.client.commands.util import AuroraClientCommandTest
@@ -45,6 +46,12 @@ from gen.apache.aurora.api.ttypes import (
 
 
 class TestUpdateCommand(AuroraClientCommandTest):
+  class FakeSchedulerMux(SchedulerMux):
+    def enqueue_and_wait(self, command, data, aggregator=None, timeout=None):
+      return command([data])
+
+    def terminate(self):
+      pass
 
   @classmethod
   def setup_mock_options(cls):
@@ -215,6 +222,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
     mock_health_check = self.setup_health_checks(mock_api)
     mock_quota_check = self.setup_quota_check()
     mock_job_monitor = self.setup_job_monitor()
+    fake_mux = self.FakeSchedulerMux()
 
     with contextlib.nested(
         patch('twitter.common.app.get_options', return_value=mock_options),
@@ -224,11 +232,12 @@ class TestUpdateCommand(AuroraClientCommandTest):
             return_value=mock_health_check),
         patch('apache.aurora.client.api.updater.QuotaCheck', return_value=mock_quota_check),
         patch('apache.aurora.client.api.updater.JobMonitor', return_value=mock_job_monitor),
+        patch('apache.aurora.client.api.updater.SchedulerMux', return_value=fake_mux),
         patch('time.time', side_effect=functools.partial(self.fake_time, self)),
-        patch('time.sleep', return_value=None)
+        patch('threading._Event.wait')
 
     ) as (options, scheduler_proxy_class, test_clusters, mock_health_check_factory,
-          mock_quota_check_patch, mock_job_monitor_patch, time_patch, sleep_patch):
+          mock_quota_check_patch, mock_job_monitor_patch, fake_mux, time_patch, sleep_patch):
       self.setup_mock_scheduler_for_simple_update(mock_api)
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
@@ -252,19 +261,19 @@ class TestUpdateCommand(AuroraClientCommandTest):
 
   @classmethod
   def assert_correct_addinstance_calls(cls, api):
-    assert api.addInstances.call_count == 4
+    assert api.addInstances.call_count == 20
     last_addinst = api.addInstances.call_args
     assert isinstance(last_addinst[0][0], AddInstancesConfig)
-    assert last_addinst[0][0].instanceIds == frozenset([15, 16, 17, 18, 19])
+    assert last_addinst[0][0].instanceIds == frozenset([19])
     assert last_addinst[0][0].key == JobKey(environment='test', role='mchucarroll', name='hello')
 
   @classmethod
   def assert_correct_killtask_calls(cls, api):
-    assert api.killTasks.call_count == 4
+    assert api.killTasks.call_count == 20
     # Check the last call's parameters.
     api.killTasks.assert_called_with(
         TaskQuery(taskIds=None, jobName='hello', environment='test',
-            instanceIds=frozenset([16, 17, 18, 19, 15]),
+            instanceIds=frozenset([19]),
             owner=Identity(role=u'mchucarroll', user=None),
            statuses=ACTIVE_STATES),
         'foo')
@@ -273,25 +282,26 @@ class TestUpdateCommand(AuroraClientCommandTest):
   def assert_correct_status_calls(cls, api):
     # getTasksWithoutConfigs gets called a lot of times. The exact number isn't fixed; it
loops
     # over the health checks until all of them pass for a configured period of time.
-    # The minumum number of calls is 4: once for each batch of restarts (Since the batch
size
-    # is set to 5, and the total number of jobs is 20, that's 4 batches.)
+    # The minumum number of calls is 20: once before the tasks are restarted, and then
+    # once for each batch of restarts (Since the batch size is set to 1, and the
+    # total number of tasks is 20, that's 20 batches.)
     assert api.getTasksWithoutConfigs.call_count >= 4
 
     status_calls = api.getTasksWithoutConfigs.call_args_list
     for status_call in status_calls:
       status_call[0][0] == TaskQuery(
-          taskIds=None,
-          jobName='hello',
-          environment='test',
-          owner=Identity(role='mchucarroll', user=None),
-          statuses=set([ScheduleStatus.RUNNING]))
+        taskIds=None,
+        jobName='hello',
+        environment='test',
+        owner=Identity(role='mchucarroll', user=None),
+        statuses=set([ScheduleStatus.RUNNING]))
 
     # getTasksStatus is called only once to build an generate update instructions
     assert api.getTasksStatus.call_count == 1
 
     api.getTasksStatus.assert_called_once_with(TaskQuery(
-        taskIds=None,
-        jobName='hello',
-        environment='test',
-        owner=Identity(role=u'mchucarroll', user=None),
-        statuses=ACTIVE_STATES))
+      taskIds=None,
+      jobName='hello',
+      environment='test',
+      owner=Identity(role=u'mchucarroll', user=None),
+      statuses=ACTIVE_STATES))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/commands/util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/util.py b/src/test/python/apache/aurora/client/commands/util.py
index e24f130..21b8830 100644
--- a/src/test/python/apache/aurora/client/commands/util.py
+++ b/src/test/python/apache/aurora/client/commands/util.py
@@ -84,7 +84,7 @@ HELLO_WORLD = Job(
   instances = 20,
   %(inner)s
   update_config = UpdateConfig(
-    batch_size = 5,
+    batch_size = 1,
     restart_threshold = 60,
     watch_secs = 45,
     max_per_shard_failures = 2,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/fake_scheduler_proxy.py b/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
index 2a4773c..12e70e9 100644
--- a/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
+++ b/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
@@ -12,6 +12,8 @@
 # limitations under the License.
 #
 
+from threading import Event, RLock
+
 from apache.aurora.client.api.scheduler_client import SchedulerProxy
 
 
@@ -20,9 +22,14 @@ class FakeSchedulerProxy(SchedulerProxy):
     self._cluster = cluster
     self._scheduler = scheduler
     self._session_key = session_key
+    self._lock = RLock()
+    self._terminating = Event()
 
   def client(self):
     return self._scheduler
 
   def session_key(self):
     return self._session_key
+
+  def terminate(self):
+    return self._terminating.set()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
index 664c3e3..4e98929 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
@@ -25,7 +25,7 @@ stage_server = Process(
 
 test_task = Task(
   name = 'http_example',
-  resources = Resources(cpu=1.0, ram=64*MB, disk=64*MB),
+  resources = Resources(cpu=0.5, ram=32*MB, disk=64*MB),
   processes = [stage_server, run_server],
   constraints = order(stage_server, run_server))
 
@@ -37,7 +37,7 @@ job = Job(
   role = getpass.getuser(),
   environment = 'test',
   contact = '{{role}}@localhost',
-  # Since there is only one slave in devcluster allow both instances to run there.
+  # Since there is only one slave in devcluster allow all instances to run there.
   constraints = {
     'host': 'limit:2',
   },

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
index dcf6103..9dfc651 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
@@ -25,21 +25,26 @@ stage_server = Process(
 
 test_task = Task(
   name = 'http_example',
-  resources = Resources(cpu=1.0, ram=64*MB, disk=96*MB),
+  resources = Resources(cpu=0.5, ram=34*MB, disk=64*MB),
   processes = [stage_server, run_server],
   constraints = order(stage_server, run_server))
 
+update_config = UpdateConfig(watch_secs=10, batch_size=2)
+health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=1)
+
 job = Job(
   name = 'http_example',
   cluster = 'devcluster',
-  instances = 2,
+  instances = 4,
+  update_config = update_config,
+  health_check_config = health_check_config,
   task = test_task,
   role = getpass.getuser(),
   environment = 'test',
   contact = '{{role}}@localhost',
-  # Since there is only one slave in devcluster allow both instances to run there.
+  # Since there is only one slave in devcluster allow all instances to run there.
   constraints = {
-    'host': 'limit:2',
+    'host': 'limit:4',
   },
 )
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
index 9c56528..3529c18 100755
--- a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
+++ b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
@@ -45,7 +45,7 @@ test_http_example() {
   # to allow automatic logins to the slaves. "aurora run" therefore tries to prompt the user
for
   # a password, finds that it's not running in a TTY, and aborts.
   runlen=$(vagrant ssh -c "aurora run $jobkey 'pwd'" | wc -l)
-  test $runlen -eq 2
+  test $runlen -eq 4
 
   vagrant ssh -c "aurora get_quota --cluster=$_cluster $_role"
   vagrant ssh -c "aurora killall  $jobkey"

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e1c0ade2/src/test/sh/org/apache/aurora/e2e/test_end_to_end_v2.sh
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/test_end_to_end_v2.sh b/src/test/sh/org/apache/aurora/e2e/test_end_to_end_v2.sh
index 2af256d..a3f530f 100755
--- a/src/test/sh/org/apache/aurora/e2e/test_end_to_end_v2.sh
+++ b/src/test/sh/org/apache/aurora/e2e/test_end_to_end_v2.sh
@@ -49,7 +49,7 @@ test_http_example() {
   # to allow automatic logins to the slaves. "aurora run" therefore tries to prompt the user
for
   # a password, finds that it's not running in a TTY, and aborts.
   runlen=$(vagrant ssh -c "aurora2 task run $jobkey 'pwd'" | wc -l)
-  test $runlen -eq 2
+  test $runlen -eq 4
 
   vagrant ssh -c "aurora2 quota get $_cluster/$_role"
   vagrant ssh -c "aurora2 job killall  $jobkey"


Mime
View raw message