Esempio n. 1
0
 def fetch_machine_types():
     return {
         'machine-type-a':
         bots_pb2.MachineType(
             early_release_secs=0,
             lease_duration_secs=1,
             mp_dimensions=['disk_gb:100'],
             name='machine-type-a',
             target_size=2,
         ),
         'machine-type-b':
         bots_pb2.MachineType(
             early_release_secs=0,
             lease_duration_secs=1,
             mp_dimensions=['disk_gb:100'],
             name='machine-type-b',
             target_size=2,
         ),
         'machine-type-c':
         bots_pb2.MachineType(
             early_release_secs=0,
             lease_duration_secs=1,
             mp_dimensions=['disk_gb:100'],
             name='machine-type-c',
             target_size=1,
         ),
     }
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
0
 def fetch_machine_types():
     return {
         'machine-type':
         bots_pb2.MachineType(
             early_release_secs=0,
             lease_duration_secs=1,
             mp_dimensions=['disk_gb:100'],
             name='machine-type',
             target_size=1,
             schedule=bots_pb2.Schedule(daily=[
                 bots_pb2.DailySchedule(
                     start='0:00',
                     end='1:00',
                     days_of_the_week=xrange(7),
                     target_size=0,
                 )
             ], ),
         ),
     }
Esempio n. 8
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)