You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by mc...@apache.org on 2014/03/11 17:58:31 UTC
git commit: Fix errors in jobs.py.
Repository: incubator-aurora
Updated Branches:
refs/heads/master d96d4bbf3 -> 6fd220423
Fix errors in jobs.py.
Reviewed at https://reviews.apache.org/r/18996/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/6fd22042
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/6fd22042
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/6fd22042
Branch: refs/heads/master
Commit: 6fd220423f4b8565419c874736dbe9784e280f86
Parents: d96d4bb
Author: Mark Chu-Carroll <mc...@twopensource.com>
Authored: Tue Mar 11 09:56:56 2014 -0700
Committer: Mark Chu-Carroll <mc...@twitter.com>
Committed: Tue Mar 11 09:56:56 2014 -0700
----------------------------------------------------------------------
.../python/apache/aurora/client/cli/jobs.py | 13 +++----
.../apache/aurora/client/cli/test_status.py | 37 ++++++++++++++++++++
2 files changed, 44 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6fd22042/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 3b327df..b9d4e83 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -222,7 +222,7 @@ the parsed configuration."""
def execute(self, context):
config = context.get_job_config(context.options.jobspec, context.options.config_file)
if context.options.raw:
- context.print(config.job())
+ context.print_out(config.job())
return EXIT_OK
job = config.raw()
@@ -243,7 +243,7 @@ the parsed configuration."""
context.print_out('%s: %s' % (constraint, value), indent=4)
context.print_out('service: %s' % job_thrift.taskConfig.isService, indent=2)
context.print_out('production: %s' % bool(job.production().get()), indent=2)
- context.print()
+ context.print_out()
task = job.task()
context.print_out('Task level information')
@@ -313,7 +313,7 @@ class ListJobsCommand(Verb):
def execute(self, context):
jobs = context.get_jobs_matching_key(context.options.jobspec)
for j in jobs:
- context.print('%s/%s/%s/%s' % (j.cluster, j.role, j.env, j.name))
+ context.print_out('%s/%s/%s/%s' % (j.cluster, j.role, j.env, j.name))
result = self.get_status_for_jobs(jobs, context)
context.print_out(result)
@@ -409,9 +409,10 @@ The jobspec parameter can omit parts of the jobkey, or use shell-style globs."""
task_strings.append('\t %s %s: %s' % (datetime.fromtimestamp(event.timestamp / 1000),
ScheduleStatus._VALUES_TO_NAMES[event.status], event.message))
task_strings.append('packages:')
- for pkg in assigned_task.task.packages:
- task_strings.append('\trole: %s, package: %s, version: %s' %
- (pkg.role, pkg.name, pkg.version))
+ if assigned_task.task.packages is not None:
+ for pkg in assigned_task.task.packages:
+ task_strings.append('\trole: %s, package: %s, version: %s' %
+ (pkg.role, pkg.name, pkg.version))
return '\n\t'.join(task_strings)
result = ["Active tasks (%s):\n" % len(active_tasks)]
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6fd22042/src/test/python/apache/aurora/client/cli/test_status.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_status.py b/src/test/python/apache/aurora/client/cli/test_status.py
index c543f3d..1d8d9b3 100644
--- a/src/test/python/apache/aurora/client/cli/test_status.py
+++ b/src/test/python/apache/aurora/client/cli/test_status.py
@@ -69,6 +69,13 @@ class TestJobStatus(AuroraClientCommandTest):
return jobs
@classmethod
+ def create_mock_scheduled_task_no_packages(cls):
+ result = cls.create_mock_scheduled_tasks()
+ for job in result:
+ job.assignedTask.task.packages = None
+ return result
+
+ @classmethod
def create_getjobs_response(cls):
result = Mock()
result.responseCode = ResponseCode.OK
@@ -95,6 +102,13 @@ class TestJobStatus(AuroraClientCommandTest):
return resp
@classmethod
+ def create_status_response_null_package(cls):
+ resp = cls.create_simple_success_response()
+ resp.result.scheduleStatusResult = Mock(spec=ScheduleStatusResult)
+ resp.result.scheduleStatusResult.tasks = set(cls.create_mock_scheduled_task_no_packages())
+ return resp
+
+ @classmethod
def create_failed_status_response(cls):
return cls.create_blank_response(ResponseCode.INVALID_REQUEST, 'No tasks found for query')
@@ -110,6 +124,18 @@ class TestJobStatus(AuroraClientCommandTest):
cmd.execute(['job', 'status', 'west/bozo/test/hello'])
mock_api.check_status.assert_called_with(AuroraJobKey('west', 'bozo', 'test', 'hello'))
+ def test_successful_status_shallow_nopackages(self):
+ """Regression test: there was a crasher bug when packages was None."""
+
+ mock_context = FakeAuroraCommandContext()
+ mock_api = mock_context.get_api('west')
+ mock_api.check_status.return_value = self.create_status_response_null_package()
+ with contextlib.nested(
+ patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context)):
+ cmd = AuroraCommandLine()
+ cmd.execute(['job', 'status', 'west/bozo/test/hello'])
+ mock_api.check_status.assert_called_with(AuroraJobKey('west', 'bozo', 'test', 'hello'))
+
def test_successful_status_deep(self):
"""Test the status command more deeply: in a request with a fully specified
job, it should end up doing a query using getTasksStatus."""
@@ -123,6 +149,17 @@ class TestJobStatus(AuroraClientCommandTest):
mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
environment='test', owner=Identity(role='bozo')))
+ def test_successful_status_deep_null_packages(self):
+ (mock_api, mock_scheduler_proxy) = self.create_mock_api()
+ mock_scheduler_proxy.query.return_value = self.create_status_response_null_package()
+ with contextlib.nested(
+ patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
+ patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+ cmd = AuroraCommandLine()
+ cmd.execute(['job', 'status', 'west/bozo/test/hello'])
+ mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
+ environment='test', owner=Identity(role='bozo')))
+
def test_status_wildcard(self):
"""Test status using a wildcard. It should first call api.get_jobs, and then do a
getTasksStatus on each job."""