]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Fix more circular imports
authorZack Cerza <zack@redhat.com>
Wed, 15 Mar 2023 21:54:28 +0000 (15:54 -0600)
committerZack Cerza <zack@redhat.com>
Mon, 20 Mar 2023 19:33:49 +0000 (13:33 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/dispatcher/__init__.py
teuthology/nuke/__init__.py
teuthology/task/ansible.py
teuthology/test/task/test_ansible.py
teuthology/test/test_worker.py
teuthology/worker.py

index 3d31a1f2a59c072f54e7512b3426c3f2a0ce38bd..b6b03dd5a9318343ca49dd1613bb9da2acd339ba 100644 (file)
@@ -16,13 +16,13 @@ from teuthology import (
     beanstalk,
     nuke,
     report,
+    repo_utils,
     worker,
 )
 from teuthology.config import config as teuth_config
 from teuthology.dispatcher import supervisor
 from teuthology.exceptions import SkipJob
 from teuthology.lock import ops as lock_ops
-from teuthology.repo_utils import fetch_qa_suite, fetch_teuthology
 from teuthology import safepath
 
 log = logging.getLogger(__name__)
@@ -100,8 +100,8 @@ def main(args):
     result_proc = None
 
     if teuth_config.teuthology_path is None:
-        fetch_teuthology('main')
-    fetch_qa_suite('main')
+        repo_utils.fetch_teuthology('main')
+    repo_utils.fetch_qa_suite('main')
 
     keep_running = True
     job_procs = set()
index 77d48ccc00a6aaf60ed62be91c5ded6ca202a5ec..25f145c65d16b67d8ca3654c60d5f941235d3ce6 100644 (file)
@@ -30,7 +30,7 @@ from teuthology.misc import (
 from teuthology.openstack import OpenStack, OpenStackInstance, enforce_json_dictionary
 from teuthology.orchestra.remote import Remote
 from teuthology.parallel import parallel
-from teuthology.task.internal import check_lock, add_remotes, connect
+from teuthology.task import internal
 
 log = logging.getLogger(__name__)
 
@@ -314,7 +314,7 @@ def nuke_helper(ctx, should_unlock, keep_logs, should_reboot):
     if ctx.check_locks:
         # does not check to ensure if the node is 'up'
         # we want to be able to nuke a downed node
-        check_lock.check_lock(ctx, None, check_up=False)
+        internal.check_lock.check_lock(ctx, None, check_up=False)
     status = get_status(host)
     if status['machine_type'] in provision.fog.get_types():
         remote.console.power_off()
@@ -337,8 +337,8 @@ def nuke_helper(ctx, should_unlock, keep_logs, should_reboot):
             log.info("Will attempt to connect via SSH")
             remote = Remote(host)
             remote.connect()
-    add_remotes(ctx, None)
-    connect(ctx, None)
+    internal.add_remotes(ctx, None)
+    internal.connect(ctx, None)
     clear_firewall(ctx)
     shutdown_daemons(ctx)
     kill_valgrind(ctx)
index 8dd20c320360e601d58920fb188c420f5466e67b..23453c1238033f6a2343ab9a478f2ac398031d50 100644 (file)
@@ -8,15 +8,16 @@ import shutil
 
 from tempfile import mkdtemp, NamedTemporaryFile
 
+from teuthology import repo_utils
 from teuthology.config import config as teuth_config
 from teuthology.exceptions import CommandFailedError, AnsibleFailedError
 from teuthology.job_status import set_status
-from teuthology.repo_utils import fetch_repo
 
 from teuthology.task import Task
 
 log = logging.getLogger(__name__)
 
+
 class LoggerFile(object):
     """
     A thin wrapper around a logging.Logger instance that provides a file-like
@@ -141,7 +142,7 @@ class Ansible(Task):
         """
         repo = self.config.get('repo', '.')
         if repo.startswith(('http://', 'https://', 'git@', 'git://')):
-            repo_path = fetch_repo(
+            repo_path = repo_utils.fetch_repo(
                 repo,
                 self.config.get('branch', 'main'),
             )
index 745b2723bd03ae7bc7f085b02bd0ca1fd74da08d..eb98fc378db072e985a8c216573fab4f1d518a2d 100644 (file)
@@ -121,7 +121,7 @@ class TestAnsibleTask(TestTask):
         task.find_repo()
         assert task.repo_path == os.path.expanduser(self.task_config['repo'])
 
-    @patch('teuthology.task.ansible.fetch_repo')
+    @patch('teuthology.repo_utils.fetch_repo')
     def test_find_repo_path_remote(self, m_fetch_repo):
         self.task_config.update(dict(
             repo='git://fake_host/repo.git',
@@ -131,7 +131,7 @@ class TestAnsibleTask(TestTask):
         task.find_repo()
         assert task.repo_path == os.path.expanduser('/tmp/repo')
 
-    @patch('teuthology.task.ansible.fetch_repo')
+    @patch('teuthology.repo_utils.fetch_repo')
     def test_find_repo_http(self, m_fetch_repo):
         self.task_config.update(dict(
             repo='http://example.com/my/repo',
@@ -141,7 +141,7 @@ class TestAnsibleTask(TestTask):
         m_fetch_repo.assert_called_once_with(self.task_config['repo'],
                                              'main')
 
-    @patch('teuthology.task.ansible.fetch_repo')
+    @patch('teuthology.repo_utils.fetch_repo')
     def test_find_repo_git(self, m_fetch_repo):
         self.task_config.update(dict(
             repo='git@example.com/my/repo',
@@ -521,7 +521,7 @@ class TestCephLabTask(TestAnsibleTask):
     def start_patchers(self):
         super(TestCephLabTask, self).start_patchers()
         self.patchers['fetch_repo'] = patch(
-            'teuthology.task.ansible.fetch_repo',
+            'teuthology.repo_utils.fetch_repo',
         )
         self.patchers['fetch_repo'].return_value = 'PATH'
 
@@ -536,7 +536,7 @@ class TestCephLabTask(TestAnsibleTask):
         for name in self.patchers.keys():
             self.start_patcher(name)
 
-    @patch('teuthology.task.ansible.fetch_repo')
+    @patch('teuthology.repo_utils.fetch_repo')
     def test_find_repo_http(self, m_fetch_repo):
         repo = os.path.join(config.ceph_git_base_url,
                             'ceph-cm-ansible.git')
index 97a4d738d892cbfa80602a61ba18cb8ed7aae707..1fe9d57b00bd040cc4aff7f1fe10b63f09a902bc 100644 (file)
@@ -177,11 +177,11 @@ 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("teuthology.repo_utils.ls_remote")
     @patch("os.path.isdir")
-    @patch("teuthology.worker.fetch_teuthology")
+    @patch("teuthology.repo_utils.fetch_teuthology")
     @patch("teuthology.worker.teuth_config")
-    @patch("teuthology.worker.fetch_qa_suite")
+    @patch("teuthology.repo_utils.fetch_qa_suite")
     def test_prep_job(self, m_fetch_qa_suite, m_teuth_config,
             m_fetch_teuthology, m_isdir, m_ls_remote):
         config = dict(
@@ -234,8 +234,8 @@ class TestWorker(object):
     @patch("teuthology.worker.run_job")
     @patch("teuthology.worker.prep_job")
     @patch("beanstalkc.Job", autospec=True)
-    @patch("teuthology.worker.fetch_qa_suite")
-    @patch("teuthology.worker.fetch_teuthology")
+    @patch("teuthology.repo_utils.fetch_qa_suite")
+    @patch("teuthology.repo_utils.fetch_teuthology")
     @patch("teuthology.worker.beanstalk.watch_tube")
     @patch("teuthology.worker.beanstalk.connect")
     @patch("os.path.isdir", return_value=True)
@@ -269,12 +269,12 @@ class TestWorker(object):
             job.bury.assert_called_once_with()
             job.delete.assert_called_once_with()
 
-    @patch("teuthology.worker.ls_remote")
+    @patch("teuthology.repo_utils.ls_remote")
     @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.repo_utils.fetch_qa_suite")
+    @patch("teuthology.repo_utils.fetch_teuthology")
     @patch("teuthology.worker.beanstalk.watch_tube")
     @patch("teuthology.worker.beanstalk.connect")
     @patch("os.path.isdir", return_value=True)
index cb3030da1129f33ee4d86034c5689f03b70d01ba..b23b6120a5b2de58306150c764ddfa9869e26873 100644 (file)
@@ -8,14 +8,20 @@ import yaml
 
 from datetime import datetime
 
-from teuthology import setup_log_file, install_except_hook, kill
-from teuthology import beanstalk
-from teuthology import report
-from teuthology import safepath
+from teuthology import (
+    # non-modules
+    setup_log_file,
+    install_except_hook,
+    # modules
+    beanstalk,
+    kill,
+    report,
+    repo_utils,
+    safepath,
+)
 from teuthology.config import config as teuth_config
 from teuthology.config import set_config_attr
 from teuthology.exceptions import BranchNotFoundError, CommitNotFoundError, SkipJob, MaxWhileTries
-from teuthology.repo_utils import fetch_qa_suite, fetch_teuthology, ls_remote, build_git_url
 
 log = logging.getLogger(__name__)
 start_time = datetime.utcnow()
@@ -78,8 +84,8 @@ def main(ctx):
     result_proc = None
 
     if teuth_config.teuthology_path is None:
-        fetch_teuthology('main')
-    fetch_qa_suite('main')
+        repo_utils.fetch_teuthology('main')
+    repo_utils.fetch_qa_suite('main')
 
     keep_running = True
     while keep_running:
@@ -149,8 +155,8 @@ def prep_job(job_config, log_file_path, archive_dir):
     job_config['teuthology_branch'] = teuthology_branch
     teuthology_sha1 = job_config.get('teuthology_sha1')
     if not teuthology_sha1:
-        repo_url = build_git_url('teuthology', 'ceph')
-        teuthology_sha1 = ls_remote(repo_url, teuthology_branch)
+        repo_url = repo_utils.build_git_url('teuthology', 'ceph')
+        teuthology_sha1 = repo_utils.ls_remote(repo_url, teuthology_branch)
         if not teuthology_sha1:
             reason = "Teuthology branch {} not found; marking job as dead".format(teuthology_branch)
             log.error(reason)
@@ -166,7 +172,7 @@ def prep_job(job_config, log_file_path, archive_dir):
         if teuth_config.teuthology_path is not None:
             teuth_path = teuth_config.teuthology_path
         else:
-            teuth_path = fetch_teuthology(branch=teuthology_branch,
+            teuth_path = repo_utils.fetch_teuthology(branch=teuthology_branch,
                                           commit=teuthology_sha1)
         # For the teuthology tasks, we look for suite_branch, and if we
         # don't get that, we look for branch, and fall back to 'main'.
@@ -178,7 +184,7 @@ def prep_job(job_config, log_file_path, archive_dir):
         if suite_repo:
             teuth_config.ceph_qa_suite_git_url = suite_repo
         job_config['suite_path'] = os.path.normpath(os.path.join(
-            fetch_qa_suite(suite_branch, suite_sha1),
+            repo_utils.fetch_qa_suite(suite_branch, suite_sha1),
             job_config.get('suite_relpath', ''),
         ))
     except (BranchNotFoundError, CommitNotFoundError) as exc: