Beispiel #1
0
 def setup_timers(self, service_instance):
     bounce_timers = service_instance.bounce_timers
     if bounce_timers:
         bounce_timers.processed_by_worker.stop()
         bounce_length_timer = bounce_timers.bounce_length
     else:
         bounce_length_timer = self.metrics.create_timer(
             'bounce_length_timer',
             service=service_instance.service,
             instance=service_instance.instance,
             paasta_cluster=self.cluster,
         )
         bounce_length_timer.start()
     processed_by_worker_timer = self.metrics.create_timer(
         'processed_by_worker',
         service=service_instance.service,
         instance=service_instance.instance,
         paasta_cluster=self.cluster,
     )
     setup_marathon_timer = self.metrics.create_timer(
         'setup_marathon_timer',
         service=service_instance.service,
         instance=service_instance.instance,
         paasta_cluster=self.cluster,
     )
     return BounceTimers(
         processed_by_worker=processed_by_worker_timer,
         setup_marathon=setup_marathon_timer,
         bounce_length=bounce_length_timer,
     )
Beispiel #2
0
 def test_setup_timers(self):
     mock_si = mock.Mock(bounce_timers=None, service="universe", instance="c137")
     ret = self.worker.setup_timers(mock_si)
     calls = [
         mock.call(
             "bounce_length_timer",
             service="universe",
             paasta_cluster="westeros-prod",
             instance="c137",
         ),
         mock.call().start(),
         mock.call(
             "processed_by_worker",
             service="universe",
             paasta_cluster="westeros-prod",
             instance="c137",
         ),
         mock.call(
             "setup_marathon_timer",
             service="universe",
             paasta_cluster="westeros-prod",
             instance="c137",
         ),
     ]
     self.mock_metrics.create_timer.assert_has_calls(calls)
     assert ret == BounceTimers(
         processed_by_worker=self.mock_metrics.create_timer.return_value,
         setup_marathon=self.mock_metrics.create_timer.return_value,
         bounce_length=self.mock_metrics.create_timer.return_value,
     )
Beispiel #3
0
    def setup_timers(self, service_instance: ServiceInstance) -> BounceTimers:
        bounce_length_timer = self.metrics.create_timer(
            "bounce_length_timer",
            service=service_instance.service,
            instance=service_instance.instance,
            paasta_cluster=self.cluster,
        )

        processed_by_worker_timer = self.metrics.create_timer(
            "processed_by_worker",
            service=service_instance.service,
            instance=service_instance.instance,
            paasta_cluster=self.cluster,
        )
        setup_marathon_timer = self.metrics.create_timer(
            "setup_marathon_timer",
            service=service_instance.service,
            instance=service_instance.instance,
            paasta_cluster=self.cluster,
        )
        return BounceTimers(
            processed_by_worker=processed_by_worker_timer,
            setup_marathon=setup_marathon_timer,
            bounce_length=bounce_length_timer,
        )
Beispiel #4
0
 def test_setup_timers(self):
     mock_si = mock.Mock(bounce_timers=None,
                         service='universe',
                         instance='c137')
     ret = self.worker.setup_timers(mock_si)
     calls = [mock.call('bounce_length_timer',
                        service='universe',
                        paasta_cluster='westeros-prod',
                        instance='c137'),
              mock.call().start(),
              mock.call('processed_by_worker',
                        service='universe',
                        paasta_cluster='westeros-prod',
                        instance='c137'),
              mock.call('setup_marathon_timer',
                        service='universe',
                        paasta_cluster='westeros-prod',
                        instance='c137')]
     self.mock_metrics.create_timer.assert_has_calls(calls)
     assert ret == BounceTimers(processed_by_worker=self.mock_metrics.create_timer.return_value,
                                setup_marathon=self.mock_metrics.create_timer.return_value,
                                bounce_length=self.mock_metrics.create_timer.return_value)