示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    def test_right_day(self):
        config = bots_pb2.MachineType(schedule=bots_pb2.Schedule(daily=[
            bots_pb2.DailySchedule(
                start='1:00',
                end='2:00',
                days_of_the_week=xrange(7),
                target_size=3,
            )
        ], ))
        now = datetime.datetime(2012, 1, 1, 1, 2)

        self.assertEqual(
            lease_management.get_target_size(config.schedule, 'mt', 1, 2, now),
            3)
示例#5
0
    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)
示例#6
0
    def test_no_schedules(self):
        config = bots_pb2.MachineType(schedule=bots_pb2.Schedule())

        self.assertEqual(
            lease_management.get_target_size(config.schedule, 'mt', 1, 2), 2)