summaryrefslogtreecommitdiff
path: root/scheduler
diff options
context:
space:
mode:
authorlmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4>2010-10-28 23:00:23 +0000
committerlmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4>2010-10-28 23:00:23 +0000
commit0fef0e80f63a42951398e871cbdf26d002b991dd (patch)
tree5f54b2d819c12e5f525d00dba6761e14290bfdd8 /scheduler
parent22a77c55920f0e020146881b9615cfcbfb2daeef (diff)
Bugfix for my previous change r4897
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 <gps@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@4898 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/monitor_db_cleanup.py7
-rwxr-xr-xscheduler/monitor_db_cleanup_test.py8
2 files changed, 9 insertions, 6 deletions
diff --git a/scheduler/monitor_db_cleanup.py b/scheduler/monitor_db_cleanup.py
index 5d148ec1..d8bab116 100644
--- a/scheduler/monitor_db_cleanup.py
+++ b/scheduler/monitor_db_cleanup.py
@@ -164,10 +164,9 @@ class UserCleanup(PeriodicCleanup):
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)
diff --git a/scheduler/monitor_db_cleanup_test.py b/scheduler/monitor_db_cleanup_test.py
index f8500a07..6bf35c46 100755
--- a/scheduler/monitor_db_cleanup_test.py
+++ b/scheduler/monitor_db_cleanup_test.py
@@ -24,7 +24,8 @@ class UserCleanupTest(unittest.TestCase, frontend_test_utils.FrontendTestMixin):
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 @@ class UserCleanupTest(unittest.TestCase, frontend_test_utils.FrontendTestMixin):
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()