Fix unit tests for LVM migration with os-brick 1.7.0

Commit a9f50dd3823ea2e9c568a1fdd970e268955dca9f in os-brick 1.7.0
introduced the usage of safe_decode() of the results of CLI commands.
This revealed that two unit tests in Cinder use a mocked "execute"
method of os-brick *without* specifying the return value. This lead
to an exception in the safe_decode() method as it isn't able to
decode MagicMocks:
    TypeError: <class 'mock.mock.MagicMock'> can't be decoded

This change adds return values to the mocked "execute" method which
can be decoded safely.

This change can not be cherry picked from the newton and ocata fixes
(dc84c1de76) due to refactoring of the
test_volume unit test files.

Co-Authored-By: Markus Zoeller <mzoeller@de.ibm.com>

Change-Id: I9b0a6c5be41c471d1a7782f77927ffe3b9652043
Closes-Bug: 1638861
This commit is contained in:
Sean McGinnis 2016-11-07 10:44:21 -06:00
parent f90114b449
commit 753a147768
1 changed files with 2 additions and 0 deletions

View File

@ -7204,6 +7204,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
False,
None,
'default')
mock_execute.return_value = ("mock_outs", "mock_errs")
moved, model_update = \
self.volume.driver.migrate_volume(self.context, vol, host)
self.assertTrue(moved)
@ -7251,6 +7252,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
False,
None,
'default')
mock_execute.return_value = ("mock_outs", "mock_errs")
lvm_driver._sparse_copy_volume = True
moved, model_update = \
lvm_driver.migrate_volume(self.context, vol, host)