From: Vallari Agrawal Date: Tue, 1 Jul 2025 15:12:53 +0000 (+0530) Subject: tests: add unit test test_update_key and test_sha1 X-Git-Tag: 1.2.2~18^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fheads%2Fwip-base-config-fix;p=teuthology.git tests: add unit test test_update_key and test_sha1 Signed-off-by: Vallari Agrawal --- diff --git a/teuthology/suite/test/test_run_.py b/teuthology/suite/test/test_run_.py index a8a0aaaa9..3459e79ad 100644 --- a/teuthology/suite/test/test_run_.py +++ b/teuthology/suite/test/test_run_.py @@ -205,12 +205,40 @@ class TestRun(object): del self.args['distro'] run_ = run.Run(self.args) run_.base_args = run_.build_base_args() + run_.base_config = run_.build_base_config() configs = [ ["desc", [], {"os_type": "debian", "os_version": "8.0"}], + ["desc", [], {"os_type": "ubuntu", "os_version": "24.0"}], ] missing, to_schedule = run_.collect_jobs('x86_64', configs, False, False) assert to_schedule[0]['yaml']['os_type'] == "debian" assert to_schedule[0]['yaml']['os_version'] == "8.0" + assert to_schedule[1]['yaml']['os_type'] == "ubuntu" + assert to_schedule[1]['yaml']['os_version'] == "24.0" + + @patch('teuthology.suite.run.util.fetch_repos') + @patch('teuthology.suite.util.git_ls_remote') + @patch('teuthology.suite.run.util.package_version_for_hash') + def test_sha1(self, m_pvfh, m_git_ls_remote, m_fetch_repos): + m_git_ls_remote.return_value = "sha1" + del self.args['distro'] + run_ = run.Run(self.args) + run_.base_args = run_.build_base_args() + for i in range(5): # mock backtracking + run_.config_input['ceph_hash'] = f"boo{i}" + run_.config_input['suite_hash'] = f"bar{i}" + run_.base_config = run_.build_base_config() + configs = [ + ["desc", [], {"os_type": "debian", "os_version": "8.0", + "sha1": "old_sha", "suite_sha1": "old_sha", + "overrides": { "workunit": {"sha1": "old_sha"}, "ceph": {"sha1": "old_sha"} } + }], + ] + missing, to_schedule = run_.collect_jobs('x86_64', configs, False, False) + assert to_schedule[0]['yaml']['sha1'] == "boo4" + assert to_schedule[0]['yaml']['suite_sha1'] == "bar4" + assert to_schedule[0]['yaml']['overrides']['workunit']["sha1"] == "bar4" + assert to_schedule[0]['yaml']['overrides']['ceph']["sha1"] == "boo4" class TestScheduleSuite(object): klass = run.Run diff --git a/teuthology/test/test_misc.py b/teuthology/test/test_misc.py index f2a6ebfb8..ca7533643 100644 --- a/teuthology/test/test_misc.py +++ b/teuthology/test/test_misc.py @@ -242,6 +242,13 @@ def test_split_role(): actual_split = misc.split_role(role) assert actual_split == expected_split +def test_update_key(): + a = { "sha": "foo", "workunit": { "sha": "foo" }, "tasks": [{"task1": "ceph"}], "overrides": [{"sha": "foo"}] } + b = { "sha": "blah", "workunit": { "sha": "bar" }, "tasks": [] } + + misc.update_key("sha", a, b) + assert a == { "sha": "blah", "workunit": { "sha": "bar" }, "tasks": [{"task1": "ceph"}], "overrides": [{"sha": "foo"}] } + class TestHostnames(object): def setup_method(self): config._conf = dict()