From 9390592c343cd55dfb7943cdc8d7970f6ce024cb Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 17 Jun 2024 14:02:11 +0200 Subject: [PATCH] ceph-volume: fix TestMigrate tests ae5ef432845 broke some unit tests. This commit fixes that. Signed-off-by: Guillaume Abrioux --- .../tests/devices/lvm/test_migrate.py | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_migrate.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_migrate.py index 072d4f1ef35e9..99aba1285c3c5 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_migrate.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_migrate.py @@ -6,6 +6,8 @@ from ceph_volume.devices.lvm import migrate from ceph_volume.util.device import Device from ceph_volume.util import system from ceph_volume.util import encryption as encryption_utils +from ceph_volume.devices.lvm.zap import Zap + class TestGetClusterName(object): @@ -1214,7 +1216,8 @@ Example calls for supported scenarios: assert not stderr - def test_migrate_data_db_to_new_db(self, is_root, monkeypatch): + @patch.object(Zap, 'main') + def test_migrate_data_db_to_new_db(self, m_zap, is_root, monkeypatch): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev' @@ -1312,9 +1315,11 @@ Example calls for supported scenarios: '--command', 'bluefs-bdev-migrate', '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db'] + m_zap.assert_called_once() + @patch.object(Zap, 'main') @patch('os.getuid') - def test_migrate_data_db_to_new_db_encrypted(self, m_getuid, monkeypatch): + def test_migrate_data_db_to_new_db_encrypted(self, m_getuid, m_zap, monkeypatch): m_getuid.return_value = 0 source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ @@ -1427,6 +1432,8 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db'] + m_zap.assert_called_once() + def test_migrate_data_db_to_new_db_active_systemd(self, is_root, monkeypatch, capsys): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev' @@ -1490,7 +1497,8 @@ Example calls for supported scenarios: assert '--> OSD is running, stop it with: systemctl stop ceph-osd@2' == stderr.rstrip() assert not stdout - def test_migrate_data_db_to_new_db_no_systemd(self, is_root, monkeypatch): + @patch.object(Zap, 'main') + def test_migrate_data_db_to_new_db_no_systemd(self, m_zap, is_root, monkeypatch): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev' source_db_tags = 'ceph.osd_id=2,ceph.type=db,ceph.osd_fsid=1234,' \ @@ -1586,7 +1594,10 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db'] - def test_migrate_data_db_to_new_db_skip_wal(self, is_root, monkeypatch): + m_zap.assert_called_once() + + @patch.object(Zap, 'main') + def test_migrate_data_db_to_new_db_skip_wal(self, m_zap, is_root, monkeypatch): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev' source_db_tags = 'ceph.osd_id=2,ceph.type=db,ceph.osd_fsid=1234,' \ @@ -1705,7 +1716,10 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db'] - def test_migrate_data_db_wal_to_new_db(self, is_root, monkeypatch): + m_zap.assert_called_once() + + @patch.object(Zap, 'main') + def test_migrate_data_db_wal_to_new_db(self, m_zap, is_root, monkeypatch): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev,' \ 'ceph.wal_uuid=waluuid,ceph.wal_device=wal_dev' @@ -1829,8 +1843,11 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + assert len(m_zap.mock_calls) == 2 + + @patch.object(Zap, 'main') @patch('os.getuid') - def test_migrate_data_db_wal_to_new_db_encrypted(self, m_getuid, monkeypatch): + def test_migrate_data_db_wal_to_new_db_encrypted(self, m_getuid, m_zap, monkeypatch): m_getuid.return_value = 0 source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ @@ -1970,6 +1987,8 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block.db', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + assert len(m_zap.mock_calls) == 2 + @patch('os.getuid') def test_dont_migrate_data_db_wal_to_new_data(self, m_getuid, @@ -2334,7 +2353,9 @@ Example calls for supported scenarios: '--command', 'bluefs-bdev-migrate', '--devs-source', '/var/lib/ceph/osd/ceph-2/block'] + @patch.object(Zap, 'main') def test_migrate_data_wal_to_db(self, + m_zap, is_root, monkeypatch, capsys): @@ -2436,11 +2457,15 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + m_zap.assert_called_once() + + @patch.object(Zap, 'main') @patch('os.getuid') def test_migrate_wal_to_db(self, - m_getuid, - monkeypatch, - capsys): + m_getuid, + m_zap, + monkeypatch, + capsys): m_getuid.return_value = 0 source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ @@ -2523,9 +2548,13 @@ Example calls for supported scenarios: '--command', 'bluefs-bdev-migrate', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + m_zap.assert_called_once() + + @patch.object(Zap, 'main') @patch('os.getuid') def test_migrate_data_wal_to_db_encrypted(self, m_getuid, + m_zap, monkeypatch, capsys): m_getuid.return_value = 0 @@ -2637,6 +2666,8 @@ Example calls for supported scenarios: '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + m_zap.assert_called_once() + def test_migrate_data_wal_to_db_active_systemd(self, is_root, monkeypatch, capsys): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev,' \ @@ -2709,7 +2740,8 @@ Example calls for supported scenarios: assert '--> OSD is running, stop it with: systemctl stop ceph-osd@2' == stderr.rstrip() assert not stdout - def test_migrate_data_wal_to_db_no_systemd(self, is_root, monkeypatch): + @patch.object(Zap, 'main') + def test_migrate_data_wal_to_db_no_systemd(self, m_zap, is_root, monkeypatch): source_tags = 'ceph.osd_id=2,ceph.type=data,ceph.osd_fsid=1234,' \ 'ceph.cluster_name=ceph,ceph.db_uuid=dbuuid,ceph.db_device=db_dev,' \ 'ceph.wal_uuid=waluuid,ceph.wal_device=wal_dev' @@ -2805,3 +2837,5 @@ Example calls for supported scenarios: '--command', 'bluefs-bdev-migrate', '--devs-source', '/var/lib/ceph/osd/ceph-2/block', '--devs-source', '/var/lib/ceph/osd/ceph-2/block.wal'] + + m_zap.assert_called_once() \ No newline at end of file -- 2.39.5