aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mchucarr...@apache.org
Subject git commit: Make config-file an optional parameter for "job restart."
Date Wed, 03 Sep 2014 18:27:35 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 417cb169c -> f6eeb0a0a


Make config-file an optional parameter for "job restart."

Bugs closed: aurora-673

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


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

Branch: refs/heads/master
Commit: f6eeb0a0aecf9ede21ea94adc3e26afa0f052c3a
Parents: 417cb16
Author: Mark Chu-Carroll <mchucarroll@twopensource.com>
Authored: Wed Sep 3 14:24:22 2014 -0400
Committer: Mark Chu-Carroll <mchucarroll@twitter.com>
Committed: Wed Sep 3 14:24:22 2014 -0400

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/jobs.py     |  8 ++--
 .../apache/aurora/client/cli/test_restart.py    | 40 ++++++++++++++++----
 .../org/apache/aurora/e2e/test_end_to_end_v2.sh |  4 +-
 3 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f6eeb0a0/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 ebc22aa..1134e13 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -45,6 +45,7 @@ from apache.aurora.client.cli.options import (
     BROWSER_OPTION,
     CommandOption,
     CONFIG_ARGUMENT,
+    CONFIG_OPTION,
     FORCE_OPTION,
     HEALTHCHECK_OPTION,
     INSTANCES_SPEC_ARGUMENT,
@@ -449,11 +450,12 @@ class RestartCommand(Verb):
         CommandOption('--restart-threshold', type=int, default=60,
              help='Maximum number of seconds before a shard must move into the RUNNING state
'
                   'before considered a failure.'),
+        CONFIG_OPTION,
         MAX_TOTAL_FAILURES_OPTION,
         STRICT_OPTION,
         CommandOption("--rollback-on-failure", default=True, action="store_false",
             help="If false, prevent update from performing a rollback."),
-        INSTANCES_SPEC_ARGUMENT, CONFIG_ARGUMENT]
+        INSTANCES_SPEC_ARGUMENT]
 
   @property
   def help(self):
@@ -476,8 +478,8 @@ Restarts are fully controlled client-side, so aborting halts the restart."""
     if instances is not None and context.options.strict:
       context.verify_shards_option_validity(job, instances)
     api = context.get_api(job.cluster)
-    config = (context.get_job_config(job, context.options.config_file)
-        if context.options.config_file else None)
+    config = (context.get_job_config(job, context.options.config)
+        if context.options.config else None)
     updater_config = UpdaterConfig(
         context.options.batch_size,
         context.options.restart_threshold,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f6eeb0a0/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 a1e7a5a..92aefe6 100644
--- a/src/test/python/apache/aurora/client/cli/test_restart.py
+++ b/src/test/python/apache/aurora/client/cli/test_restart.py
@@ -67,7 +67,8 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello', fp.name])
+        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
+            '--config', fp.name])
 
         # Like the update test, the exact number of calls here doesn't matter.
         # what matters is that it must have been called once before batching, plus
@@ -79,6 +80,27 @@ class TestRestartCommand(AuroraClientCommandTest):
         mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
             role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19], None)
 
+  def test_restart_simple_no_config(self):
+    # Test the client-side restart logic in its simplest case: everything succeeds
+    (mock_api, mock_scheduler_proxy) = self.create_mock_api()
+    mock_health_check = self.setup_health_checks(mock_api)
+    self.setup_mock_scheduler_for_simple_restart(mock_api)
+    with contextlib.nested(
+        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
+        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('threading._Event.wait')
+    ):
+      cmd = AuroraCommandLine()
+      cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello'])
+
+      assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count >= 4
+      assert mock_scheduler_proxy.restartShards.call_count == 4
+      mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
+          role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19], None)
+
   def test_restart_invalid_shards(self):
     # Test the client-side restart when a shard argument is too large, and it's
     # using strict mode.
@@ -98,7 +120,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         result = cmd.execute(['job', 'restart', '--batch-size=5', '--max-total-failures=-1',
-            'west/bozo/test/hello', fp.name])
+            'west/bozo/test/hello', '--config', fp.name])
         assert result == EXIT_INVALID_PARAMETER
         assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count == 0
         assert mock_scheduler_proxy.restartShards.call_count == 0
@@ -119,7 +141,8 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        result = cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
fp.name])
+        result = cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
+            '--config', fp.name])
         assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count == 1
         assert mock_scheduler_proxy.restartShards.call_count == 0
         assert result == EXIT_API_ERROR
@@ -143,7 +166,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         result = cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello/1-3',
-            fp.name])
+            '--config', fp.name])
         # We need to check tat getTasksWithoutConfigs was called, but that restartShards
wasn't.
         # In older versions of the client, if shards were specified, but the job didn't
         # exist, the error wouldn't be detected unti0 restartShards was called, which generated
@@ -171,7 +194,8 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        result = cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
fp.name])
+        result = cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
+            '--config', fp.name])
         assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count == 1
         assert mock_scheduler_proxy.restartShards.call_count == 1
         mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
@@ -218,7 +242,8 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello', fp.name])
+        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
+            '--config', fp.name])
         print(self.MOCK_OUT)
         assert self.MOCK_OUT == ['Job west/bozo/test/hello restarted successfully']
         assert self.MOCK_ERR == []
@@ -244,6 +269,7 @@ class TestRestartCommand(AuroraClientCommandTest):
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello', fp.name])
+        cmd.execute(['job', 'restart', '--batch-size=5', 'west/bozo/test/hello',
+            '--config', fp.name])
       assert self.MOCK_OUT == []
       assert self.MOCK_ERR == ['Error restarting job west/bozo/test/hello; see log for details']

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f6eeb0a0/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 14a0b62..6dff70e 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
@@ -53,8 +53,8 @@ test_http_example() {
 
   echo "== Restarting test job"
 
-  vagrant ssh -c "aurora2 job restart $jobkey $_updated_config"
-
+  vagrant ssh -c "aurora2 job restart $jobkey"
+  
   echo '== Updating test job'
   vagrant ssh -c "aurora2 job update $jobkey $_updated_config"
 


Mime
View raw message