]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
tests: Make sure to patch repo_utils ops
authorZack Cerza <zack@redhat.com>
Fri, 20 Jan 2023 20:54:17 +0000 (13:54 -0700)
committerZack Cerza <zack@redhat.com>
Tue, 24 Jan 2023 00:28:58 +0000 (17:28 -0700)
These tests were hitting the network.

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

index a580c3603c333c71382157edede6ec45aae3aff6..eefa721f8e790aba9eedc39fde821f70bc551744 100644 (file)
@@ -121,11 +121,13 @@ class TestRun(object):
         assert run.base_config.sha1 == 'ceph_sha1'
         assert run.base_config.branch == 'ceph_branch'
 
+    @patch('teuthology.suite.run.util.git_ls_remote')
     @patch('requests.head')
     @patch('teuthology.suite.util.git_branch_exists')
     @patch('teuthology.suite.util.package_version_for_hash')
     def test_sha1_nonexistent(
         self,
+        m_git_ls_remote,
         m_package_version_for_hash,
         m_git_branch_exists,
         m_requests_head,
index 2c4e8f4bd5676c9982a7fcabd81995d8d92a9cfa..92ce8c5f622a24f7297fd261f9e58d2ed3411b37 100644 (file)
@@ -8,7 +8,7 @@ from mock import Mock, patch
 from teuthology.config import config
 from teuthology.orchestra.opsys import OS
 from teuthology.suite import util
-from teuthology.exceptions import ScheduleFailError
+from teuthology.exceptions import BranchNotFoundError, ScheduleFailError
 
 
 REPO_PROJECTS_AND_URLS = [
@@ -67,8 +67,11 @@ class TestUtil(object):
         assert str(exc.value) == "Scheduling failed: error msg"
         m_smtp.assert_not_called()
 
+    @patch('teuthology.suite.util.fetch_qa_suite')
     @patch('teuthology.suite.util.smtplib.SMTP')
-    def test_fetch_repo_no_branch(self, m_smtp):
+    def test_fetch_repo_no_branch(self, m_smtp, m_fetch_qa_suite):
+        m_fetch_qa_suite.side_effect = BranchNotFoundError(
+            "no-branch", "https://github.com/ceph/ceph-ci.git")
         config.results_email = "example@example.com"
         with pytest.raises(ScheduleFailError) as exc:
             util.fetch_repos("no-branch", "test1", dry_run=False)
@@ -76,8 +79,11 @@ class TestUtil(object):
 Branch 'no-branch' not found in repo: https://github.com/ceph/ceph-ci.git!"
         m_smtp.assert_called()
 
+    @patch('teuthology.suite.util.fetch_qa_suite')
     @patch('teuthology.suite.util.smtplib.SMTP')
-    def test_fetch_repo_no_branch_dryrun(self, m_smtp):
+    def test_fetch_repo_no_branch_dryrun(self, m_smtp, m_fetch_qa_suite):
+        m_fetch_qa_suite.side_effect = BranchNotFoundError(
+            "no-branch", "https://github.com/ceph/ceph-ci.git")
         config.results_email = "example@example.com"
         with pytest.raises(ScheduleFailError) as exc:
             util.fetch_repos("no-branch", "test1", dry_run=True)
index 877d9903d795d44e48b47267e4e9923357a81c1e..05342b8dc1df28f5352f13c388d30ac4da8eb20b 100644 (file)
@@ -178,13 +178,13 @@ class TestWorker(object):
         worker.run_with_watchdog(process, config)
         m_symlink_log.assert_called_with(config["worker_log"], config["archive_path"])
 
+    @patch("teuthology.worker.ls_remote")
     @patch("os.path.isdir")
     @patch("teuthology.worker.fetch_teuthology")
     @patch("teuthology.worker.teuth_config")
     @patch("teuthology.worker.fetch_qa_suite")
-    def test_prep_job(self, m_fetch_qa_suite,
-                      m_teuth_config,
-                      m_fetch_teuthology, m_isdir):
+    def test_prep_job(self, m_fetch_qa_suite, m_teuth_config,
+            m_fetch_teuthology, m_isdir, m_ls_remote):
         config = dict(
             name="the_name",
             job_id="1",
@@ -269,6 +269,7 @@ class TestWorker(object):
             job.bury.assert_called_once_with()
             job.delete.assert_called_once_with()
 
+    @patch("teuthology.worker.ls_remote")
     @patch("teuthology.worker.report.try_push_job_info")
     @patch("teuthology.worker.run_job")
     @patch("beanstalkc.Job", autospec=True)
@@ -281,7 +282,7 @@ class TestWorker(object):
     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_try_push_job_info, m_ls_remote,
                        ):
         m_connection = Mock()
         jobs = self.build_fake_jobs(