示例#1
0
  def test_cron_status_multiple_jobs(self):
    _, mock_scheduler_proxy = self.create_mock_api()
    with contextlib.nested(
        patch('time.sleep'),
        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.cli.context.AuroraCommandContext.print_out')) as (
            _, _, _, mock_print):
      response = self.create_simple_success_response()
      response.result = Result(getJobsResult=GetJobsResult(configs=[
          JobConfiguration(
              key=JobKey(role='bozo', environment='test', name='hello'),
              cronSchedule='* * * * *'),
          JobConfiguration(
              key=JobKey(role='bozo', environment='test', name='hello2'),
              cronSchedule='* * * * *')
      ]))
      mock_scheduler_proxy.getJobs.return_value = response

      cmd = AuroraCommandLine()
      result = cmd.execute(['cron', 'show', 'west/bozo/test/hello'])

      assert result == EXIT_OK
      mock_scheduler_proxy.getJobs.assert_called_once_with("bozo")
      mock_print.assert_called_with("west/bozo/test/hello\t * * * * *")
示例#2
0
 def _create_getjobs_response(cls):
     response = cls.create_simple_success_response()
     response.result = Result(getJobsResult=GetJobsResult(configs=[
         JobConfiguration(
             cronSchedule='* * * * *',
             key=JobKey(role='bozo', environment='test', name='hello'))
     ]))
     return response
示例#3
0
 def _expect_get_jobs(self, *envs):
     self._api.get_jobs(self.ROLE).AndReturn(
         Response(responseCode=ResponseCode.OK,
                  messageDEPRECATED='Mock OK',
                  result=Result(getJobsResult=GetJobsResult(configs=set(
                      JobConfiguration(key=JobKey(
                          role=self.ROLE, environment=env, name=self.NAME))
                      for env in envs)))))
示例#4
0
 def create_getjobs_response(cls):
     mock_job_one = JobConfiguration(
         key=JobKey(role='RoleA', environment='test', name='hithere'))
     mock_job_two = JobConfiguration(
         key=JobKey(role='bozo', environment='test', name='hello'))
     result = cls.create_simple_success_response()
     result.result = Result(getJobsResult=GetJobsResult(
         configs=[mock_job_one, mock_job_two]))
     return result
示例#5
0
    def test_cron_status_multiple_jobs(self):
        mock_context = FakeAuroraCommandContext()
        with patch('apache.aurora.client.cli.cron.CronNoun.create_context',
                   return_value=mock_context):
            api = mock_context.get_api("west")
            response = self.create_simple_success_response()
            response.result = Result(getJobsResult=GetJobsResult(configs=[
                JobConfiguration(key=JobKey(
                    role='bozo', environment='test', name='hello'),
                                 cronSchedule='* * * * *'),
                JobConfiguration(key=JobKey(
                    role='bozo', environment='test', name='hello2'),
                                 cronSchedule='* * * * *')
            ]))
            api.get_jobs.return_value = response

            cmd = AuroraCommandLine()
            result = cmd.execute(['cron', 'show', 'west/bozo/test/hello'])

            assert result == EXIT_OK
            api.get_jobs.assert_called_once_with("bozo")
            assert mock_context.get_out_str(
            ) == "west/bozo/test/hello\t * * * * *"