When a one-time host is added as a normal host while it's running a job, the status would get reset, messing up the scheduler. Fix that.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3778 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/models_test.py b/frontend/afe/models_test.py
index 9f4d99d..47932e0 100755
--- a/frontend/afe/models_test.py
+++ b/frontend/afe/models_test.py
@@ -39,6 +39,32 @@
self._check_acls(host2, ['my_acl'])
+class HostTest(unittest.TestCase,
+ frontend_test_utils.FrontendTestMixin):
+ def setUp(self):
+ self._frontend_common_setup()
+
+
+ def tearDown(self):
+ self._frontend_common_teardown()
+
+
+ def test_add_host_previous_one_time_host(self):
+ # ensure that when adding a host which was previously used as a one-time
+ # host, the status isn't reset, since this can interfere with the
+ # scheduler.
+ host = models.Host.create_one_time_host('othost')
+ self.assertEquals(host.invalid, True)
+ self.assertEquals(host.status, models.Host.Status.READY)
+
+ host.status = models.Host.Status.RUNNING
+ host.save()
+
+ host2 = models.Host.add_object(hostname='othost')
+ self.assertEquals(host2.id, host.id)
+ self.assertEquals(host2.status, models.Host.Status.RUNNING)
+
+
class SpecialTaskUnittest(unittest.TestCase,
frontend_test_utils.FrontendTestMixin):
def setUp(self):