Beispiel #1
0
 def test_bounce_chronos_job_doesnt_log_when_nothing_to_do(self):
     fake_jobs_to_disable = []
     fake_jobs_to_delete = []
     fake_job_to_create = []
     with contextlib.nested(
         mock.patch("setup_chronos_job._log", autospec=True),
         mock.patch("paasta_tools.chronos_tools.disable_job", autospec=True),
         mock.patch("paasta_tools.chronos_tools.delete_job", autospec=True),
         mock.patch("paasta_tools.chronos_tools.create_job", autospec=True),
     ) as (
         mock_log,
         mock_disable_job,
         mock_delete_job,
         mock_create_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             jobs_to_disable=fake_jobs_to_disable,
             jobs_to_delete=fake_jobs_to_delete,
             job_to_create=fake_job_to_create,
             client=self.fake_client,
         )
         assert not mock_log.called
         assert not mock_disable_job.called
         assert not mock_delete_job.called
         assert not mock_create_job.called
 def test_bounce_chronos_job_doesnt_log_when_nothing_to_do(self):
     fake_jobs_to_disable = []
     fake_jobs_to_delete = []
     fake_job_to_create = []
     with contextlib.nested(
             mock.patch("setup_chronos_job._log", autospec=True),
             mock.patch("paasta_tools.chronos_tools.disable_job",
                        autospec=True),
             mock.patch("paasta_tools.chronos_tools.delete_job",
                        autospec=True),
             mock.patch("paasta_tools.chronos_tools.create_job",
                        autospec=True),
     ) as (
             mock_log,
             mock_disable_job,
             mock_delete_job,
             mock_create_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             jobs_to_disable=fake_jobs_to_disable,
             jobs_to_delete=fake_jobs_to_delete,
             job_to_create=fake_job_to_create,
             client=self.fake_client,
         )
         assert not mock_log.called
         assert not mock_disable_job.called
         assert not mock_delete_job.called
         assert not mock_create_job.called
 def test_bounce_chronos_job_takes_actions(self):
     fake_jobs_to_disable = [{'name': 'job_to_disable'}]
     fake_jobs_to_delete = [{'name': 'job_to_delete'}]
     fake_job_to_create = {'name': 'job_to_create'}
     with contextlib.nested(
             mock.patch("setup_chronos_job._log", autospec=True),
             mock.patch("paasta_tools.chronos_tools.disable_job",
                        autospec=True),
             mock.patch("paasta_tools.chronos_tools.delete_job",
                        autospec=True),
             mock.patch("paasta_tools.chronos_tools.create_job",
                        autospec=True),
     ) as (
             mock_log,
             mock_disable_job,
             mock_delete_job,
             mock_create_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             jobs_to_disable=fake_jobs_to_disable,
             jobs_to_delete=fake_jobs_to_delete,
             job_to_create=fake_job_to_create,
             client=self.fake_client,
         )
         mock_log.assert_any_call(
             line=mock.ANY,
             level='debug',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_log.assert_any_call(
             line="Created new Chronos job: job_to_create",
             level='event',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_disable_job.assert_called_once_with(
             job=fake_jobs_to_disable[0], client=self.fake_client)
         mock_delete_job.assert_called_once_with(job=fake_jobs_to_delete[0],
                                                 client=self.fake_client)
         mock_create_job.assert_called_once_with(job=fake_job_to_create,
                                                 client=self.fake_client)
Beispiel #4
0
 def test_bounce_chronos_job_takes_actions(self):
     fake_jobs_to_disable = [{'name': 'job_to_disable'}]
     fake_jobs_to_delete = [{'name': 'job_to_delete'}]
     fake_job_to_create = {'name': 'job_to_create'}
     with contextlib.nested(
         mock.patch("setup_chronos_job._log", autospec=True),
         mock.patch("paasta_tools.chronos_tools.disable_job", autospec=True),
         mock.patch("paasta_tools.chronos_tools.delete_job", autospec=True),
         mock.patch("paasta_tools.chronos_tools.create_job", autospec=True),
     ) as (
         mock_log,
         mock_disable_job,
         mock_delete_job,
         mock_create_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             jobs_to_disable=fake_jobs_to_disable,
             jobs_to_delete=fake_jobs_to_delete,
             job_to_create=fake_job_to_create,
             client=self.fake_client,
         )
         mock_log.assert_any_call(
             line=mock.ANY,
             level='debug',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_log.assert_any_call(
             line="Created new Chronos job: job_to_create",
             level='event',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_disable_job.assert_called_once_with(job=fake_jobs_to_disable[0], client=self.fake_client)
         mock_delete_job.assert_called_once_with(job=fake_jobs_to_delete[0], client=self.fake_client)
         mock_create_job.assert_called_once_with(job=fake_job_to_create, client=self.fake_client)