def test_load_based_fallback(self): config = bots_pb2.MachineType(schedule=bots_pb2.Schedule( daily=[ bots_pb2.DailySchedule( start='1:00', end='2:00', days_of_the_week=xrange(5), target_size=3, ) ], load_based=[bots_pb2.LoadBased( maximum_size=6, minimum_size=2, )], )) lease_management.MachineTypeUtilization( id='mt', busy=4, idle=0, ).put() now = datetime.datetime(2012, 1, 1, 1, 2) self.assertEqual( lease_management.get_target_size(config.schedule, 'mt', 1, 3, now), 6)
def test_no_utilization(self): config = bots_pb2.MachineType(schedule=bots_pb2.Schedule( load_based=[bots_pb2.LoadBased( maximum_size=5, minimum_size=3, )], )) self.assertEqual( lease_management.get_target_size(config.schedule, 'mt', 1, 4), 4)
def test_utilization(self): config = bots_pb2.MachineType(schedule=bots_pb2.Schedule( load_based=[bots_pb2.LoadBased( maximum_size=6, minimum_size=2, )], )) lease_management.MachineTypeUtilization( id='mt', busy=4, idle=0, ).put() self.assertEqual( lease_management.get_target_size(config.schedule, 'mt', 1, 3), 6)
def test_drop_dampening(self): config = bots_pb2.MachineType(schedule=bots_pb2.Schedule(load_based=[ bots_pb2.LoadBased( maximum_size=100, minimum_size=1, ) ], )) lease_management.MachineTypeUtilization( id='mt', busy=60, idle=20, ).put() self.assertEqual( lease_management.get_target_size(config.schedule, 'mt', 100, 50), 99)