yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #69161
[Bug 1706399] Re: unit test 'test_get_volume_config' doesn't test anything useful
Reviewed: https://review.openstack.org/489467
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=71d1cd1d2820af040889ca308c0560ccf927e549
Submitter: Zuul
Branch: master
commit 71d1cd1d2820af040889ca308c0560ccf927e549
Author: Takashi NATSUME <natsume.takashi@xxxxxxxxxxxxx>
Date: Tue Aug 1 13:22:30 2017 +0900
Fix test_get_volume_config method
The current test does not check instance variables of
LibvirtConfigGuestDisk object.
So fix the test to check attributes of LibvirtConfigGuestDisk
object.
Change-Id: I14fb44eebf9d6f7623225dea46d143f7cb84d7fc
Closes-Bug: #1706399
** Changed in: nova
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1706399
Title:
unit test 'test_get_volume_config' doesn't test anything useful
Status in OpenStack Compute (nova):
Fix Released
Bug description:
Description
===========
The unit test `test_get_volume_config` [1] asserts that a mock is equal
to itself:
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver,
'connect_volume')
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver, 'get_config')
def test_get_volume_config(self, get_config, connect_volume):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
connection_info = {'driver_volume_type': 'fake',
'data': {'device_path': '/fake',
'access_mode': 'rw'}}
bdm = {'device_name': 'vdb',
'disk_bus': 'fake-bus',
'device_type': 'fake-type'}
disk_info = {'bus': bdm['disk_bus'], 'type': bdm['device_type'],
'dev': 'vdb'}
mock_config = mock.MagicMock()
get_config.return_value = mock_config
config = drvr._get_volume_config(connection_info, disk_info)
get_config.assert_called_once_with(connection_info, disk_info)
self.assertEqual(mock_config, config)
self.assertEqual(mock_config, config)
Steps to reproduce
==================
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Add these two lines to see that the objects are the same:
print("mock config: %s" % mock_config)
print("config: %s" % config)
Expected result
===============
The `mock_config` has some kind of recording how it should look like and
the created `config` object is tested against that.
Actual result
=============
`mock_config` and `config` are the very same python object.
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Tests running...
mock config: <MagicMock id='147674384'>
config: <MagicMock id='147674384'>
Environment
===========
$ git log --oneline -1
87a0143 Merge "[placement] Flush RC_CACHE after each gabbit sequence"
References:
===========
[1] https://github.com/openstack/nova/blob/bbe0f313bdfd30cc1c740709543b679567b42f0f/nova/tests/unit/virt/libvirt/test_driver.py#L6355-L6373
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1706399/+subscriptions
References