def test_decrease_worker_count(self): autoscaling = RuleBasedStrategy(70, 80) worker_pool = self.prepare_service(worker_count=5, utilisation=50.) actual = autoscaling.adjust(worker_pool) self.assertEqual(4, actual)
def test_increase_when_utilisation_too_high(self): autoscaling = RuleBasedStrategy(70, 80) worker_pool = self.prepare_service(worker_count=4, utilisation=100.) actual = autoscaling.adjust(worker_pool) self.assertEqual(5, actual)
def test_does_not_change_a_value_within_the_range(self): worker_count = 4 autoscaling = RuleBasedStrategy(70, 80) service = self.prepare_service(worker_count, utilisation=75.) actual = autoscaling.adjust(service) self.assertEqual(worker_count, actual)
def create_autoscaler(self, environment, autoscaling): strategy = RuleBasedStrategy(70, 80) return AutoScaler(environment, autoscaling.period, autoscaling.limits, strategy)