]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: replace deprecated assertEquals with assertEqual
authorEmmanuel Ferdman <emmanuelferdman@gmail.com>
Fri, 16 May 2025 11:28:30 +0000 (04:28 -0700)
committerEmmanuel Ferdman <emmanuelferdman@gmail.com>
Sun, 18 May 2025 17:05:51 +0000 (10:05 -0700)
The unittest.TestCase.assertEquals() method is deprecated in Python 2.7
and emits a DeprecationWarning. This commit replaces all instances of
assertEquals() with the recommended assertEqual() in the cephfs test files
to resolve these warnings and ensure future compatibility.

This change addresses warnings such as:
DeprecationWarning: Please use assertEqual instead.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
qa/tasks/cephfs/test_mirroring.py
qa/tasks/mgr/test_cache.py

index 4d17a9a902f0c46c36173d001554e426c6d3711f..d136e35b7d909208a031ee31820032bf341ca690 100644 (file)
@@ -615,7 +615,7 @@ class TestMirroring(CephFSTestCase):
         self.assertGreater(second["counters"]["last_synced_start"], first["counters"]["last_synced_start"])
         self.assertGreater(second["counters"]["last_synced_end"], second["counters"]["last_synced_start"])
         self.assertGreater(second["counters"]["last_synced_duration"], 0)
-        self.assertEquals(second["counters"]["last_synced_bytes"], 10737418240) # last_synced_bytes = 10 files of 1024MB size each
+        self.assertEqual(second["counters"]["last_synced_bytes"], 10737418240) # last_synced_bytes = 10 files of 1024MB size each
 
         # some more IO
         for i in range(10):
@@ -638,7 +638,7 @@ class TestMirroring(CephFSTestCase):
         self.assertGreater(third["counters"]["last_synced_start"], second["counters"]["last_synced_end"])
         self.assertGreater(third["counters"]["last_synced_end"], third["counters"]["last_synced_start"])
         self.assertGreater(third["counters"]["last_synced_duration"], 0)
-        self.assertEquals(third["counters"]["last_synced_bytes"], 10737418240) # last_synced_bytes = 10 files of 1024MB size each
+        self.assertEqual(third["counters"]["last_synced_bytes"], 10737418240) # last_synced_bytes = 10 files of 1024MB size each
 
         # delete a snapshot
         self.mount_a.run_shell(["rmdir", "d0/.snap/snap0"])
@@ -822,9 +822,9 @@ class TestMirroring(CephFSTestCase):
 
         # we have not added any directories
         peer = status['filesystems'][0]['peers'][0]
-        self.assertEquals(status['filesystems'][0]['directory_count'], 0)
-        self.assertEquals(peer['stats']['failure_count'], 0)
-        self.assertEquals(peer['stats']['recovery_count'], 0)
+        self.assertEqual(status['filesystems'][0]['directory_count'], 0)
+        self.assertEqual(peer['stats']['failure_count'], 0)
+        self.assertEqual(peer['stats']['recovery_count'], 0)
 
         # add a non-existent directory for synchronization -- check if its reported
         # in daemon stats
@@ -834,10 +834,10 @@ class TestMirroring(CephFSTestCase):
         status = self.get_mirror_daemon_status()
         # we added one
         peer = status['filesystems'][0]['peers'][0]
-        self.assertEquals(status['filesystems'][0]['directory_count'], 1)
+        self.assertEqual(status['filesystems'][0]['directory_count'], 1)
         # failure count should be reflected
-        self.assertEquals(peer['stats']['failure_count'], 1)
-        self.assertEquals(peer['stats']['recovery_count'], 0)
+        self.assertEqual(peer['stats']['failure_count'], 1)
+        self.assertEqual(peer['stats']['recovery_count'], 0)
 
         # create the directory, mirror daemon would recover
         self.mount_a.run_shell(["mkdir", "d0"])
@@ -845,10 +845,10 @@ class TestMirroring(CephFSTestCase):
         time.sleep(120)
         status = self.get_mirror_daemon_status()
         peer = status['filesystems'][0]['peers'][0]
-        self.assertEquals(status['filesystems'][0]['directory_count'], 1)
+        self.assertEqual(status['filesystems'][0]['directory_count'], 1)
         # failure and recovery count should be reflected
-        self.assertEquals(peer['stats']['failure_count'], 1)
-        self.assertEquals(peer['stats']['recovery_count'], 1)
+        self.assertEqual(peer['stats']['failure_count'], 1)
+        self.assertEqual(peer['stats']['recovery_count'], 1)
 
         self.disable_mirroring(self.primary_fs_name, self.primary_fs_id)
 
@@ -856,7 +856,7 @@ class TestMirroring(CephFSTestCase):
         """Test mirror daemon init failure"""
 
         # disable mgr mirroring plugin as it would try to load dir map on
-        # on mirroring enabled for a filesystem (an throw up erorrs in
+        # on mirroring enabled for a filesystem (an throw up errors in
         # the logs)
         self.disable_mirroring_module()
 
@@ -892,7 +892,7 @@ class TestMirroring(CephFSTestCase):
         """Test if the mirror daemon can recover from a init failure"""
 
         # disable mgr mirroring plugin as it would try to load dir map on
-        # on mirroring enabled for a filesystem (an throw up erorrs in
+        # on mirroring enabled for a filesystem (an throw up errors in
         # the logs)
         self.disable_mirroring_module()
 
@@ -1253,11 +1253,11 @@ class TestMirroring(CephFSTestCase):
             for fname in fnames:
                 t = self.mount_b.run_shell_payload(f"stat -c %F {dirname}/.snap/{snap_name}/{fname}").stdout.getvalue().strip()
                 if typs[tidx] == 'reg':
-                    self.assertEquals('regular file', t)
+                    self.assertEqual('regular file', t)
                 elif typs[tidx] == 'dir':
-                    self.assertEquals('directory', t)
+                    self.assertEqual('directory', t)
                 elif typs[tidx] == 'sym':
-                    self.assertEquals('symbolic link', t)
+                    self.assertEqual('symbolic link', t)
                 tidx += 1
 
         self.enable_mirroring(self.primary_fs_name, self.primary_fs_id)
@@ -1293,7 +1293,7 @@ class TestMirroring(CephFSTestCase):
         """Test snapshot synchronization in midst of snapshot deletes.
 
         Deleted the previous snapshot when the mirror daemon is figuring out
-        incremental differences between current and previous snaphot. The
+        incremental differences between current and previous snapshot. The
         mirror daemon should identify the purge and switch to using remote
         comparison to sync the snapshot (in the next iteration of course).
         """
index 71131cbc6afa6e6d57dcca780f9c366491ad3b6e..7a05de47c17cde943d0640d6d11a9cf73441fc25 100644 (file)
@@ -34,7 +34,7 @@ class TestCache(MgrTestCase):
     def test_init_cache(self):
         get_ttl = "config get mgr mgr_ttl_cache_expire_seconds"
         res = self.cluster_cmd(get_ttl)
-        self.assertEquals(int(res), 10)
+        self.assertEqual(int(res), 10)
 
     def test_health_not_cached(self):
         get_health = "mgr api get health"
@@ -43,8 +43,8 @@ class TestCache(MgrTestCase):
         self.cluster_cmd(get_health)
         h, m = self.get_hit_miss_ratio()
 
-        self.assertEquals(h, h_start)
-        self.assertEquals(m, m_start)
+        self.assertEqual(h, h_start)
+        self.assertEqual(m, m_start)
 
     def test_osdmap(self):
         get_osdmap = "mgr api get osd_map"
@@ -73,11 +73,11 @@ class TestCache(MgrTestCase):
         # Miss, add osd_map to cache
         self.wait_until_true(wait_miss, self.ttl + 5)
         h, m = self.get_hit_miss_ratio()
-        self.assertEquals(h, hit_start)
-        self.assertEquals(m, miss_start+1)
+        self.assertEqual(h, hit_start)
+        self.assertEqual(m, miss_start+1)
 
         # Hit, get osd_map from cache
         self.cluster_cmd(get_osdmap)
         h, m = self.get_hit_miss_ratio()
-        self.assertEquals(h, hit_start+1)
-        self.assertEquals(m, miss_start+1)
+        self.assertEqual(h, hit_start+1)
+        self.assertEqual(m, miss_start+1)