Bugfix for my previous change. The unittest unfortunately hid the problem because our self.god.stub_with() stubs non-existant things out with a new value without checking to see if the thing being stubbed out existed in the first place.
Signed-off-by: Gregory Smith <[email protected]> --- autotest/scheduler/monitor_db_cleanup.py 2010-10-21 13:16:19.000000000 -0700 +++ autotest/scheduler/monitor_db_cleanup.py 2010-10-22 10:03:20.000000000 -0700 @@ -164,10 +164,9 @@ def _choose_subset_of_hosts_to_reverify(self, hosts): """Given hosts needing verification, return a subset to reverify.""" - if (scheduler_config.reverify_max_hosts_at_once > 0 and - len(hosts) > scheduler_config.reverify_max_hosts_at_once): - return random.sample(hosts, - scheduler_config.reverify_max_hosts_at_once) + max_at_once = scheduler_config.config.reverify_max_hosts_at_once + if (max_at_once > 0 and len(hosts) > max_at_once): + return random.sample(hosts, max_at_once) return sorted(hosts) --- autotest/scheduler/monitor_db_cleanup_test.py 2010-10-21 13:16:19.000000000 -0700 +++ autotest/scheduler/monitor_db_cleanup_test.py 2010-10-22 10:03:20.000000000 -0700 @@ -24,7 +24,8 @@ def test_reverify_dead_hosts(self): # unlimited reverifies - self.god.stub_with(scheduler_config, 'reverify_max_hosts_at_once', 0) + self.god.stub_with(scheduler_config.config, + 'reverify_max_hosts_at_once', 0) for i in (0, 1, 2): self.hosts[i].status = models.Host.Status.REPAIR_FAILED self.hosts[i].save() @@ -47,7 +48,10 @@ def test_reverify_dead_hosts_limits(self): # limit the number of reverifies - self.god.stub_with(scheduler_config, 'reverify_max_hosts_at_once', 2) + self.assertTrue(hasattr(scheduler_config.config, + 'reverify_max_hosts_at_once')) + self.god.stub_with(scheduler_config.config, + 'reverify_max_hosts_at_once', 2) for i in (0, 1, 2, 3, 4, 5): self.hosts[i].status = models.Host.Status.REPAIR_FAILED self.hosts[i].save() _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
