Skip to content

Commit

Permalink
Merge pull request #55002 from aplanas/backport_52182
Browse files Browse the repository at this point in the history
(Backport 52182) mdadm_raid: convert metadata to text
  • Loading branch information
dwoz authored Dec 20, 2019
2 parents 576bd85 + 6cc6de2 commit b47787b
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions tests/unit/modules/test_mdadm_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,44 @@ def test_create(self):
'-C', '/dev/md0',
'-R',
'-v',
'-l', '5',
])
'-l', '5'])
self.assertEqual(args[0][10:], [
'-e', 'default',
'-n', '3',
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'])
self.assertEqual(sorted(args[0][7:10]), sorted(['--chunk', '256', '--force']))
self.assertIn('--chunk 256', ' '.join(args[0][7:10]))
'-e', 'default',
'-n', '3',
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'])
self.assertEqual(sorted(args[0][7:10]),
sorted(['--chunk', '256', '--force']))
self.assertEqual(kwargs, {'python_shell': False})

def test_create_metadata(self):
mock = MagicMock(return_value='salt')
with patch.dict(mdadm.__salt__, {'cmd.run': mock}), \
patch('salt.utils.path.which', lambda exe: exe):
ret = mdadm.create(
'/dev/md0', 5,
devices=['/dev/sdb1', '/dev/sdc1', '/dev/sdd1'],
metadata=0.9,
test_mode=False,
force=True,
chunk=256
)
self.assertEqual('salt', ret)

self.assert_called_once(mock)

args, kwargs = mock.call_args
self.assertEqual(args[0][:7], [
'mdadm',
'-C', '/dev/md0',
'-R',
'-v',
'-l', '5'])
self.assertEqual(args[0][10:], [
'-e', '0.9',
'-n', '3',
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'])
self.assertEqual(sorted(args[0][7:10]),
sorted(['--chunk', '256', '--force']))
self.assertEqual(kwargs, {'python_shell': False})

def test_create_test_mode(self):
Expand Down

0 comments on commit b47787b

Please sign in to comment.