]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume tests update to use error.value instead of str(error)
authorAlfredo Deza <adeza@redhat.com>
Wed, 3 Jul 2019 18:58:31 +0000 (14:58 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 3 Jul 2019 18:59:53 +0000 (14:59 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/api/test_lvm.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_validate.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py
src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py
src/ceph-volume/ceph_volume/tests/util/test_prepare.py

index 272b3636e4c6d3e5e50f6342db3ca75d4487a146..ddf99f6ae1f80e453bd306dc065858cddc57baca 100644 (file)
@@ -384,7 +384,7 @@ class TestVolumeGroupFree(object):
         vg = api.VolumeGroup(vg_name='nosize', vg_free='F')
         with pytest.raises(RuntimeError) as error:
             vg.free
-        assert "Unable to convert vg size to integer: 'F'" in str(error)
+        assert "Unable to convert vg size to integer: 'F'" in str(error.value)
 
     def test_invalid_float(self):
         vg = api.VolumeGroup(vg_name='nosize', vg_free=' g')
@@ -464,7 +464,7 @@ class TestVolumeGroupSizing(object):
     def test_parts_and_size_errors(self):
         with pytest.raises(ValueError) as error:
             self.vg.sizing(parts=4, size=10)
-        assert "Cannot process sizing" in str(error)
+        assert "Cannot process sizing" in str(error.value)
 
     def test_zero_parts_produces_100_percent(self):
         result = self.vg.sizing(parts=0)
index 28c9f773af63eaf599cc16c3d8391390914ca386..8df5840b6527b9b83c49b2c9ed876a77cff54c33 100644 (file)
@@ -36,7 +36,7 @@ class TestSingleType(object):
         ]
         with pytest.raises(RuntimeError) as error:
             bluestore.SingleType.with_auto_devices(args, devices)
-        assert 'Unable to use device 5.66 GB /dev/sda' in str(error)
+        assert 'Unable to use device 5.66 GB /dev/sda' in str(error.value)
 
     def test_device_is_lvm_member_fails(self, fakedevice, factory):
         args = factory(filtered_devices=[], osds_per_device=1,
@@ -46,7 +46,7 @@ class TestSingleType(object):
         ]
         with pytest.raises(RuntimeError) as error:
             bluestore.SingleType.with_auto_devices(args, devices)
-        assert 'Unable to use device, already a member of LVM' in str(error)
+        assert 'Unable to use device, already a member of LVM' in str(error.value)
 
 
 class TestMixedType(object):
@@ -97,7 +97,7 @@ class TestMixedTypeConfiguredSize(object):
         with pytest.raises(RuntimeError) as error:
             bluestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         expected = 'Not enough space in fast devices (5.66 GB) to create 1 x 7.22 GB block.db LV'
-        assert expected in str(error)
+        assert expected in str(error.value)
 
     def test_multi_hdd_device_is_not_large_enough(self, stub_vgs, fakedevice, factory, conf_ceph):
         # 3GB block.db in ceph.conf
@@ -112,7 +112,7 @@ class TestMixedTypeConfiguredSize(object):
         with pytest.raises(RuntimeError) as error:
             bluestore.MixedType.with_auto_devices(args, devices)
         expected = 'Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB'
-        assert expected in str(error)
+        assert expected in str(error.value)
 
 
 class TestMixedTypeLargeAsPossible(object):
@@ -165,7 +165,7 @@ class TestMixedTypeLargeAsPossible(object):
         with pytest.raises(RuntimeError) as error:
             bluestore.MixedType.with_auto_devices(args, devices)
         expected = 'Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB'
-        assert expected in str(error)
+        assert expected in str(error.value)
 
 
 class TestMixedTypeWithExplicitDevices(object):
@@ -198,4 +198,4 @@ class TestMixedTypeWithExplicitDevices(object):
         with pytest.raises(RuntimeError) as error:
             bluestore.MixedType(args, [hdd], [], [ssd]).computed['osds'][0]
         expected = 'Unable to use device 1.50 GB /dev/sda, LVs would be smaller than 1GB'
-        assert expected in str(error), str(error)
+        assert expected in str(error.value), str(error)
index bffba4b47820d409f0148503e1ca41ae90bfe84d..9fb814950960392ea58ca31d48cfb2de629027fc 100644 (file)
@@ -28,7 +28,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_ssd_device_is_large_enough(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '5120')
@@ -53,7 +53,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_ssd_device_multi_osd(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '5120')
@@ -65,7 +65,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_hdd_device_multi_osd(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '5120')
@@ -77,7 +77,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_device_is_lvm_member_fails(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '5120')
@@ -88,7 +88,7 @@ class TestSingleType(object):
         ]
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
-        assert 'Unable to use device, already a member of LVM' in str(error)
+        assert 'Unable to use device, already a member of LVM' in str(error.value)
 
     def test_hdd_device_with_small_configured_journal(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '120')
@@ -100,7 +100,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_ssd_device_with_small_configured_journal(self, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '120')
@@ -112,7 +112,7 @@ class TestSingleType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.SingleType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
 
 class TestMixedType(object):
@@ -128,7 +128,7 @@ class TestMixedType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.MixedType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_ssd_device_is_not_large_enough(self, stub_vgs, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '7120')
@@ -141,7 +141,7 @@ class TestMixedType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.MixedType.with_auto_devices(args, devices)
         msg = "Not enough space in fast devices (5.66 GB) to create 1 x 6.95 GB journal LV"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_hdd_device_is_lvm_member_fails(self, stub_vgs, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '5120')
@@ -153,7 +153,7 @@ class TestMixedType(object):
         ]
         with pytest.raises(RuntimeError) as error:
             filestore.MixedType.with_auto_devices(args, devices)
-        assert 'Unable to use device, already a member of LVM' in str(error)
+        assert 'Unable to use device, already a member of LVM' in str(error.value)
 
     def test_ssd_is_lvm_member_doesnt_fail(self, volumes, stub_vgs, fakedevice, factory, conf_ceph):
         # fast PV, because ssd is an LVM member
@@ -209,7 +209,7 @@ class TestMixedType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.MixedType.with_auto_devices(args, devices)
 
-        assert 'Could not find a common VG between devices' in str(error)
+        assert 'Could not find a common VG between devices' in str(error.value)
 
     def test_ssd_device_fails_multiple_osds(self, stub_vgs, fakedevice, factory, conf_ceph):
         conf_ceph(get_safe=lambda *a: '15120')
@@ -222,7 +222,7 @@ class TestMixedType(object):
         with pytest.raises(RuntimeError) as error:
             filestore.MixedType.with_auto_devices(args, devices)
         msg = "Not enough space in fast devices (14.97 GB) to create 2 x 14.77 GB journal LV"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_filter_all_data_devs(self, fakedevice, factory):
         # in this scenario the user passed a already used device to be used for
index 315ec7c5b7447fc06a76a60888a21e0c1b06ef45..ebb93149b196e028aee8f5225a56eb3527c4363a 100644 (file)
@@ -14,7 +14,7 @@ class TestMinimumDeviceSize(object):
         with pytest.raises(RuntimeError) as error:
             validators.minimum_device_size(devices)
         msg = "LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_large_device_multiple_osds_fails(self, fakedevice):
         devices = [fakedevice(sys_api=dict(size=6073740000))]
@@ -23,7 +23,7 @@ class TestMinimumDeviceSize(object):
                 devices, osds_per_device=4
             )
         msg = "LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
 
 class TestMinimumCollocatedDeviceSize(object):
@@ -40,7 +40,7 @@ class TestMinimumCollocatedDeviceSize(object):
         with pytest.raises(RuntimeError) as error:
             validators.minimum_device_collocated_size(devices, self.journal_size)
         msg = "LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
 
     def test_large_device_multiple_osds_fails(self, fakedevice):
         devices = [fakedevice(sys_api=dict(size=16073740000))]
@@ -49,4 +49,4 @@ class TestMinimumCollocatedDeviceSize(object):
                 devices, self.journal_size, osds_per_device=3
             )
         msg = "LVs would be smaller than 5GB"
-        assert msg in str(error)
+        assert msg in str(error.value)
index c7963bb2ff199a354562abca3eec3fefbe896ba6..dbdb3f08f53b76a93ca3f98303e80a0545abc52c 100644 (file)
@@ -28,8 +28,8 @@ class TestPrepareDevice(object):
         with pytest.raises(RuntimeError) as error:
             lvm.prepare.Prepare([]).prepare_device(
                     '/dev/var/foo', 'data', 'asdf', '0')
-        assert 'Cannot use device (/dev/var/foo)' in str(error)
-        assert 'A vg/lv path or an existing device is needed' in str(error)
+        assert 'Cannot use device (/dev/var/foo)' in str(error.value)
+        assert 'A vg/lv path or an existing device is needed' in str(error.value)
 
 
 class TestGetClusterFsid(object):
@@ -98,7 +98,7 @@ class TestPrepare(object):
         with pytest.raises(SystemExit) as error:
             lvm.prepare.Prepare(argv=['--filestore', '--data', '/dev/sdfoo']).main()
         expected = '--journal is required when using --filestore'
-        assert expected in str(error)
+        assert expected in str(error.value)
 
 
 class TestGetJournalLV(object):
index 885a6ec25437f018806c56579a509b767072bafd..eea0b08675a705d4b48ae075736ada0580615814 100644 (file)
@@ -15,7 +15,7 @@ class TestActivate(object):
         os.environ['CEPH_VOLUME_SIMPLE_JSON_DIR'] = '/non/existing/path'
         with pytest.raises(RuntimeError) as error:
             activate.Activate(['1', 'asdf']).main()
-        assert 'RuntimeError: Expected JSON config path not found' in str(error)
+        assert 'Expected JSON config path not found' in str(error.value)
 
     def test_main_spits_help_with_no_arguments(self, capsys):
         activate.Activate([]).main()
@@ -132,13 +132,13 @@ class TestValidateDevices(object):
         activation = activate.Activate([])
         with pytest.raises(RuntimeError) as error:
             activation.validate_devices({'type': 'filestore', 'data': {}})
-        assert 'Unable to activate filestore OSD due to missing devices' in str(error)
+        assert 'Unable to activate filestore OSD due to missing devices' in str(error.value)
 
     def test_filestore_missing_data(self):
         activation = activate.Activate([])
         with pytest.raises(RuntimeError) as error:
             activation.validate_devices({'type': 'filestore', 'journal': {}})
-        assert 'Unable to activate filestore OSD due to missing devices' in str(error)
+        assert 'Unable to activate filestore OSD due to missing devices' in str(error.value)
 
     def test_filestore_journal_device_found(self, capsys):
         activation = activate.Activate([])
@@ -180,7 +180,7 @@ class TestValidateDevices(object):
         activation = activate.Activate([])
         with pytest.raises(RuntimeError) as error:
             activation.validate_devices({'type': 'bluestore', 'block': {}})
-        assert 'Unable to activate bluestore OSD due to missing devices' in str(error)
+        assert 'Unable to activate bluestore OSD due to missing devices' in str(error.value)
 
     def test_bluestore_block_device_found(self, capsys):
         activation = activate.Activate([])
index 2167aeac1469b53ff6e963402229b9f6c3357f70..c18bff45d78993525c1537a5737348b5784266ab 100644 (file)
@@ -25,7 +25,7 @@ class TestOSDPath(object):
         validator = arg_validators.OSDPath()
         with pytest.raises(argparse.ArgumentError) as error:
             validator(tmppath)
-        assert 'Required file (ceph_fsid) was not found in OSD' in str(error)
+        assert 'Required file (ceph_fsid) was not found in OSD' in str(error.value)
 
 
 class TestExcludeGroupOptions(object):
index c1d872f5fdd60d2057c8b19a7ef7e7e7ad4e7864..ced5d49e76c9cb155baf83409c17bf556db56c68 100644 (file)
@@ -319,7 +319,7 @@ class TestMkfsFilestore(object):
         stub_call(([], [], 1))
         with pytest.raises(RuntimeError) as error:
             prepare.osd_mkfs_filestore('1', 'asdf-1234', 'keyring')
-        assert "Command failed with exit code 1" in str(error)
+        assert "Command failed with exit code 1" in str(error.value)
 
     def test_non_zero_exit_formats_command_correctly(self, stub_call, monkeypatch):
         conf.cluster = 'ceph'
@@ -337,7 +337,7 @@ class TestMkfsFilestore(object):
             '--osd-journal', '/var/lib/ceph/osd/ceph-1/journal',
             '--osd-uuid', 'asdf-1234',
             '--setuser', 'ceph', '--setgroup', 'ceph'])
-        assert expected in str(error)
+        assert expected in str(error.value)
 
 
 class TestMkfsBluestore(object):
@@ -348,7 +348,7 @@ class TestMkfsBluestore(object):
         stub_call(([], [], 1))
         with pytest.raises(RuntimeError) as error:
             prepare.osd_mkfs_bluestore('1', 'asdf-1234', keyring='keyring')
-        assert "Command failed with exit code 1" in str(error)
+        assert "Command failed with exit code 1" in str(error.value)
 
     def test_non_zero_exit_formats_command_correctly(self, stub_call, monkeypatch):
         conf.cluster = 'ceph'
@@ -365,7 +365,7 @@ class TestMkfsBluestore(object):
             '--keyfile', '-', '--osd-data', '/var/lib/ceph/osd/ceph-1/',
             '--osd-uuid', 'asdf-1234',
             '--setuser', 'ceph', '--setgroup', 'ceph'])
-        assert expected in str(error)
+        assert expected in str(error.value)
 
 
 class TestGetJournalSize(object):
@@ -418,5 +418,5 @@ class TestGetJournalSize(object):
         """))
         with pytest.raises(RuntimeError) as error:
             prepare.get_journal_size()
-        assert 'journal sizes must be larger' in str(error)
-        assert 'detected: 1024.00 MB' in str(error)
+        assert 'journal sizes must be larger' in str(error.value)
+        assert 'detected: 1024.00 MB' in str(error.value)