]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
tests: add unit test test_update_key and test_sha1 wip-base-config-fix 2060/head
authorVallari Agrawal <val.agl002@gmail.com>
Tue, 1 Jul 2025 15:12:53 +0000 (20:42 +0530)
committerVallari Agrawal <val.agl002@gmail.com>
Tue, 1 Jul 2025 15:15:19 +0000 (20:45 +0530)
Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
teuthology/suite/test/test_run_.py
teuthology/test/test_misc.py

index a8a0aaaa93b6aac42e7fbdf9d487a119b2ab35e4..3459e79ad8475476946b4bbac8728b0bd68f34ae 100644 (file)
@@ -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
index f2a6ebfb81f1ec70b9533950c77bc4244192d845..ca7533643d0f58e1600de98946ccad8a24895bd8 100644 (file)
@@ -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()