Skip to content

Commit

Permalink
tests: Add test for multiple blocks devices
Browse files Browse the repository at this point in the history
The 'server create' command should support multiple '--block-device'
parameters. Prove it.

Change-Id: I1bd83287efdbbe11774053b694bae99b6a4ebdf5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
  • Loading branch information
stephenfin committed Dec 1, 2022
1 parent 6cd72f6 commit e7bc687
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions openstackclient/tests/unit/compute/v2/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ def setUp(self):
self.flavors_mock.get.return_value = self.flavor

self.volume = volume_fakes.create_one_volume()
self.volume_alt = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = self.volume

self.snapshot = volume_fakes.create_one_snapshot()
Expand Down Expand Up @@ -2563,11 +2564,13 @@ def test_server_create_with_block_device(self):
'key_name': None,
'availability_zone': None,
'admin_pass': None,
'block_device_mapping_v2': [{
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
}],
'block_device_mapping_v2': [
{
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
},
],
'nics': [],
'scheduler_hints': {},
'config_drive': None,
Expand All @@ -2594,11 +2597,13 @@ def test_server_create_with_block_device_full(self):
f'volume_type=foo,boot_index=1,delete_on_termination=true,'
f'tag=foo'
)
block_device_alt = f'uuid={self.volume_alt.id},source_type=volume'

arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
'--block-device', block_device,
'--block-device', block_device_alt,
self.new_server.name,
]
verifylist = [
Expand All @@ -2619,6 +2624,10 @@ def test_server_create_with_block_device_full(self):
'delete_on_termination': 'true',
'tag': 'foo',
},
{
'uuid': self.volume_alt.id,
'source_type': 'volume',
},
]),
('server_name', self.new_server.name),
]
Expand All @@ -2639,20 +2648,27 @@ def test_server_create_with_block_device_full(self):
'key_name': None,
'availability_zone': None,
'admin_pass': None,
'block_device_mapping_v2': [{
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
'disk_bus': 'ide',
'device_name': 'sdb',
'volume_size': '64',
'guest_format': 'ext4',
'boot_index': 1,
'device_type': 'disk',
'delete_on_termination': True,
'tag': 'foo',
'volume_type': 'foo',
}],
'block_device_mapping_v2': [
{
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
'disk_bus': 'ide',
'device_name': 'sdb',
'volume_size': '64',
'guest_format': 'ext4',
'boot_index': 1,
'device_type': 'disk',
'delete_on_termination': True,
'tag': 'foo',
'volume_type': 'foo',
},
{
'uuid': self.volume_alt.id,
'source_type': 'volume',
'destination_type': 'volume',
},
],
'nics': 'auto',
'scheduler_hints': {},
'config_drive': None,
Expand Down

0 comments on commit e7bc687

Please sign in to comment.