-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16919/
-----------------------------------------------------------

Review request for Aurora and Mark Chu-Carroll.


Repository: aurora


Description
-------

I noticed that there was some code in src/test/python/twitter that shouldn't've 
been there.  This also uncovered a malformed BUILD and some broken tests.


Diffs
-----

  src/main/python/apache/aurora/client/cli/jobs.py 
1d0f37ea447d4915479749d3a0e24445984153cd 
  src/test/python/apache/aurora/client/BUILD 
27ebaf5cbda9e80b8beb47c85ad17a85eb234b1b 
  src/test/python/apache/aurora/client/cli/BUILD 
bf21590c35f105c0efb85a232fad9d3cd36329c6 
  src/test/python/apache/aurora/client/cli/test_status.py 
38f301836fa6f95c763e8ffb3e5ce7ac1d139096 
  src/test/python/twitter/aurora/client/cli/BUILD 
e4ea5da77649f9b663eaf999d4602e7e5177f7ad 
  src/test/python/twitter/aurora/client/cli/test_diff.py 
363352f9d607e90f103234aeb086e306ccbdb4ac 

Diff: https://reviews.apache.org/r/16919/diff/


Testing
-------

mba=aurora=; PANTS_PYTHON_TEST_FAILSOFT=1 ./pants 
src/test/python/apache/aurora/client/cli:all -v
Build operating on targets: 
OrderedSet([PythonTestSuite(src/test/python/apache/aurora/client/cli/BUILD:all)])
========================================================== test session starts 
===========================================================
platform darwin -- Python 2.7.6 -- pytest-2.5.1 -- 
/Users/wickman/Python/CPython-2.7.6/bin/python2.7
collected 17 items 

src/test/python/apache/aurora/client/cli/test_create.py:132: 
TestClientCreateCommand.test_create_job_delayed PASSED
src/test/python/apache/aurora/client/cli/test_create.py:157: 
TestClientCreateCommand.test_create_job_failed PASSED
src/test/python/apache/aurora/client/cli/test_create.py:183: 
TestClientCreateCommand.test_create_job_failed_invalid_config PASSED
src/test/python/apache/aurora/client/cli/test_create.py:99: 
TestClientCreateCommand.test_simple_successful_create_job PASSED
src/test/python/apache/aurora/client/cli/test_kill.py:20: 
TestInstancesParser.test_parse_instances PASSED
src/test/python/apache/aurora/client/cli/test_kill.py:25: 
TestInstancesParser.test_parse_none PASSED
src/test/python/apache/aurora/client/cli/test_kill.py:39: 
TestClientKillCommand.test_kill_job PASSED
src/test/python/apache/aurora/client/cli/test_kill.py:60: 
TestClientKillCommand.test_kill_job_with_instances PASSED
src/test/python/apache/aurora/client/cli/test_kill.py:80: 
TestClientKillCommand.test_kill_job_with_instances_deep_api PASSED
src/test/python/apache/aurora/client/cli/test_status.py:110: 
TestJobStatus.test_status_wildcard FAILED
src/test/python/apache/aurora/client/cli/test_status.py:130: 
TestJobStatus.test_status_wildcard_two PASSED
src/test/python/apache/aurora/client/cli/test_status.py:97: 
TestJobStatus.test_successful_status_deep PASSED
src/test/python/apache/aurora/client/cli/test_status.py:85: 
TestJobStatus.test_successful_status_shallow PASSED
src/test/python/apache/aurora/client/cli/test_status.py:148: 
TestJobStatus.test_unsuccessful_status_shallow PASSED
src/test/python/apache/aurora/client/cli/test_diff.py:124: 
TestDiffCommand.test_diff_invalid_config PASSED
src/test/python/apache/aurora/client/cli/test_diff.py:151: 
TestDiffCommand.test_diff_server_error FAILED
src/test/python/apache/aurora/client/cli/test_diff.py:93: 
TestDiffCommand.test_successful_diff FAILED

================================================================ FAILURES 
================================================================
___________________________________________________ 
TestJobStatus.test_status_wildcard 
___________________________________________________

self = <test_status.TestJobStatus testMethod=test_status_wildcard>

    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."""
      mock_context = FakeAuroraCommandContext()
      mock_api = mock_context.get_api('west')
      mock_api.check_status.return_value = self.create_status_response()
      mock_api.get_jobs.return_value = self.create_getjobs_response()
      with contextlib.nested(
          patch('apache.aurora.client.cli.jobs.Job.create_context', 
return_value=mock_context)):
        cmd = AuroraCommandLine()
        cmd.execute(['job', 'status', '*'])
    
      # Wildcard should have expanded to two jobs, so there should be two calls
      # to check_status.
      assert mock_api.check_status.call_count == 2
>     assert (call(AuroraJobKey('example', 'RoleA', 'test', 'hithere')) in
          mock_api.check_status.call_args_list)
E     AssertionError: assert call(<class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>('example', 'RoleA', 'test', 
'hithere')) in [call(<class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>(u'wickman-loc...mmon.aurora_job_key.AuroraJobKey'>(u'wickman-local',
 'bozo', 'test', 'hello'))]
E      +  where call(<class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>('example', 'RoleA', 'test', 
'hithere')) = call(<class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>('example', 'RoleA', 'test', 
'hithere'))
E      +    where <class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>('example', 'RoleA', 'test', 
'hithere') = AuroraJobKey('example', 'RoleA', 'test', 'hithere')
E      +  and   [call(<class 
'apache.aurora.common.aurora_job_key.AuroraJobKey'>(u'wickman-loc...mmon.aurora_job_key.AuroraJobKey'>(u'wickman-local',
 'bozo', 'test', 'hello'))] = <Mock name='mock.check_status' 
id='4327783248'>.call_args_list
E      +    where <Mock name='mock.check_status' id='4327783248'> = <Mock 
spec='HookedAuroraClientAPI' id='4327784528'>.check_status

src/test/python/apache/aurora/client/cli/test_status.py:125: AssertionError
------------------------------------------------------------ Captured stdout 
-------------------------------------------------------------
Active tasks (3):
        cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:       cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:       cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:Inactive tasks (0):
Active tasks (3):
        cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:       cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:       cpus: 2, ram: 2 MB, disk: 2 MB
                 1970-11-23 10:58:46 RUNNING: Hi there
        packages:Inactive tasks (0):

_________________________________________________ 
TestDiffCommand.test_diff_server_error 
_________________________________________________

self = <test_diff.TestDiffCommand testMethod=test_diff_server_error>

    def test_diff_server_error(self):
      """Test the diff command if the user passes a config with an error in 
it."""
      mock_options = self.setup_mock_options()
      (mock_api, mock_scheduler) = self.create_mock_api()
      mock_scheduler.getTasksStatus.return_value = 
self.create_failed_status_response()
      self.setup_populate_job_config(mock_scheduler)
      with contextlib.nested(
          patch('apache.aurora.client.api.SchedulerProxy', 
return_value=mock_scheduler),
          patch('apache.aurora.client.factory.CLUSTERS', 
new=self.TEST_CLUSTERS),
          patch('twitter.common.app.get_options', return_value=mock_options),
          patch('subprocess.call', return_value=0),
          patch('json.loads', return_value=Mock())) as (
              mock_scheduler_proxy_class,
              mock_clusters,
              options,
              subprocess_patch,
              json_patch):
        with temporary_file() as fp:
          fp.write(self.get_valid_config())
          fp.flush()
          cmd = AuroraCommandLine()
          result = cmd.execute(['job', 'diff', 'west/bozo/test/hello', fp.name])
          assert result == EXIT_INVALID_PARAMETER
          # In this error case, we should have called the server getTasksStatus;
          # but since it fails, we shouldn't call populateJobConfig or 
subprocess.
          mock_scheduler.getTasksStatus.assert_called_with(
              TaskQuery(jobName='hello', environment='test', 
owner=Identity(role='bozo'),
                  statuses=set([ScheduleStatus.PENDING, ScheduleStatus.STARTING,
                      ScheduleStatus.RUNNING, ScheduleStatus.KILLING, 
ScheduleStatus.ASSIGNED,
>                     ScheduleStatus.RESTARTING, ScheduleStatus.PREEMPTING])))

src/test/python/apache/aurora/client/cli/test_diff.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

_mock_self = <Mock name='mock.scheduler.getTasksStatus' id='4327983888'>
args = (TaskQuery(taskIds=None, jobName='hello', environment='test', 
instanceIds=None,... owner=Identity(role='bozo', user=None), statuses=set([0, 
1, 2, 6, 9, 12, 13])),)
kwargs = {}, self = <Mock name='mock.scheduler.getTasksStatus' id='4327983888'>
msg = "Expected call: getTasksStatus(TaskQuery(taskIds=None, jobName='hello', 
environment='test', instanceIds=None, slaveHos...instanceIds=None, 
slaveHost=None, owner=Identity(role=u'bozo', user=None), statuses=set([0, 1, 2, 
6, 9, 12, 13, 16])))"

>   ???
E   AssertionError: Expected call: getTasksStatus(TaskQuery(taskIds=None, 
jobName='hello', environment='test', instanceIds=None, slaveHost=None, 
owner=Identity(role='bozo', user=None), statuses=set([0, 1, 2, 6, 9, 12, 13])))
E   Actual call: getTasksStatus(TaskQuery(taskIds=None, jobName=u'hello', 
environment=u'test', instanceIds=None, slaveHost=None, 
owner=Identity(role=u'bozo', user=None), statuses=set([0, 1, 2, 6, 9, 12, 13, 
16])))

/lib/python2.7/site-packages/mock.py:835: AssertionError
------------------------------------------------------------ Captured stderr 
-------------------------------------------------------------
Error executing command: Could not find job to diff against
__________________________________________________ 
TestDiffCommand.test_successful_diff 
__________________________________________________

self = <test_diff.TestDiffCommand testMethod=test_successful_diff>

    def test_successful_diff(self):
      """Test the diff command."""
      (mock_api, mock_scheduler) = self.setup_mock_api()
      with contextlib.nested(
          patch('apache.aurora.client.api.SchedulerProxy', 
return_value=mock_scheduler),
          patch('apache.aurora.client.factory.CLUSTERS', 
new=self.TEST_CLUSTERS),
          patch('subprocess.call', return_value=0),
          patch('json.loads', return_value=Mock())) as (_, _, subprocess_patch, 
_):
        mock_scheduler.getTasksStatus.return_value = 
self.create_status_response()
        self.setup_populate_job_config(mock_scheduler)
        with temporary_file() as fp:
          fp.write(self.get_valid_config())
          fp.flush()
          cmd = AuroraCommandLine()
          cmd.execute(['job', 'diff', 'west/bozo/test/hello', fp.name])
    
          # Diff should get the task status, populate a config, and run diff.
          mock_scheduler.getTasksStatus.assert_called_with(
              TaskQuery(jobName='hello', environment='test', 
owner=Identity(role='bozo'),
                  statuses=set([ScheduleStatus.PENDING, ScheduleStatus.STARTING,
                      ScheduleStatus.RUNNING, ScheduleStatus.KILLING, 
ScheduleStatus.ASSIGNED,
>                     ScheduleStatus.RESTARTING, ScheduleStatus.PREEMPTING])))

src/test/python/apache/aurora/client/cli/test_diff.py:114: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

_mock_self = <Mock name='mock.scheduler.getTasksStatus' id='4329723472'>
args = (TaskQuery(taskIds=None, jobName='hello', environment='test', 
instanceIds=None,... owner=Identity(role='bozo', user=None), statuses=set([0, 
1, 2, 6, 9, 12, 13])),)
kwargs = {}, self = <Mock name='mock.scheduler.getTasksStatus' id='4329723472'>
msg = "Expected call: getTasksStatus(TaskQuery(taskIds=None, jobName='hello', 
environment='test', instanceIds=None, slaveHos...instanceIds=None, 
slaveHost=None, owner=Identity(role=u'bozo', user=None), statuses=set([0, 1, 2, 
6, 9, 12, 13, 16])))"

>   ???
E   AssertionError: Expected call: getTasksStatus(TaskQuery(taskIds=None, 
jobName='hello', environment='test', instanceIds=None, slaveHost=None, 
owner=Identity(role='bozo', user=None), statuses=set([0, 1, 2, 6, 9, 12, 13])))
E   Actual call: getTasksStatus(TaskQuery(taskIds=None, jobName=u'hello', 
environment=u'test', instanceIds=None, slaveHost=None, 
owner=Identity(role=u'bozo', user=None), statuses=set([0, 1, 2, 6, 9, 12, 13, 
16])))

/lib/python2.7/site-packages/mock.py:835: AssertionError
================================================== 3 failed, 14 passed in 0.73 
seconds ===================================================
src.test.python.apache.aurora.client.cli.job                                    
.....   FAILURE
mba=aurora=; 


Thanks,

Brian Wickman

Reply via email to