Fix DroneManager._drop_old_pidfiles() -- use items() instead of iteritems() to avoid concurrent modification exception. Added unit test.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@4010 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/drone_manager_unittest.py b/scheduler/drone_manager_unittest.py
index 4364bfb..161b5c5 100755
--- a/scheduler/drone_manager_unittest.py
+++ b/scheduler/drone_manager_unittest.py
@@ -238,5 +238,15 @@
os.path.join(self._DRONE_RESULTS_DIR, file_path), written_data))
+ def test_pidfile_expiration(self):
+ self.god.stub_with(self.manager, '_get_max_pidfile_refreshes',
+ lambda: 0)
+ pidfile_id = self.manager.get_pidfile_id_from('tag', 'name')
+ self.manager.register_pidfile(pidfile_id)
+ self.manager._drop_old_pidfiles()
+ self.manager._drop_old_pidfiles()
+ self.assertFalse(self.manager._registered_pidfile_info)
+
+
if __name__ == '__main__':
unittest.main()