]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add a test for issue 13925
authorZack Cerza <zack@redhat.com>
Tue, 24 May 2016 22:51:05 +0000 (16:51 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 25 May 2016 15:55:19 +0000 (09:55 -0600)
It will fail - the next commit fixes it.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/test/test_worker.py

index a68bec9ff90f5580f4ca45b4c5ae5a938b32c914..3fcf1e57ccf318ec7b3e84dc8a64330604f7b173 100644 (file)
@@ -7,6 +7,8 @@ from datetime import datetime, timedelta
 
 from .. import worker
 
+from ..contextutil import MaxWhileTries
+
 
 class TestWorker(object):
     def setup(self):
@@ -270,3 +272,40 @@ class TestWorker(object):
         for job in jobs:
             job.bury.assert_called_once_with()
             job.delete.assert_called_once_with()
+
+    @patch("teuthology.worker.report.try_push_job_info")
+    @patch("teuthology.worker.run_job")
+    @patch("beanstalkc.Job", autospec=True)
+    @patch("teuthology.worker.fetch_qa_suite")
+    @patch("teuthology.worker.fetch_teuthology")
+    @patch("teuthology.worker.beanstalk.watch_tube")
+    @patch("teuthology.worker.beanstalk.connect")
+    @patch("os.path.isdir", return_value=True)
+    @patch("teuthology.worker.setup_log_file")
+    def test_main_loop_13925(
+        self, m_setup_log_file, m_isdir, m_connect, m_watch_tube,
+        m_fetch_teuthology, m_fetch_qa_suite, m_job, m_run_job,
+        m_try_push_job_info,
+                       ):
+        m_connection = Mock()
+        jobs = self.build_fake_jobs(
+            m_connection,
+            m_job,
+            [
+                'name: name',
+                'name: name\nstop_worker: true',
+            ],
+        )
+        m_connection.reserve.side_effect = jobs
+        m_connect.return_value = m_connection
+        m_fetch_qa_suite.side_effect = [
+            '/suite/path',
+            MaxWhileTries(),
+            MaxWhileTries(),
+        ]
+        worker.main(self.ctx)
+        assert len(m_run_job.call_args_list) == 0
+        assert len(m_try_push_job_info.call_args_list) == len(jobs)
+        for i in range(len(jobs)):
+            push_call = m_try_push_job_info.call_args_list[i]
+            assert push_call[0][1]['status'] == 'dead'