Merge "Make get_partitions() work for partitioned disks"
This commit is contained in:
commit
d187de9574
@ -300,7 +300,7 @@ class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.validation_resources['keypair']['private_key'],
|
||||
server=server_no_eph_disk,
|
||||
servers_client=self.client)
|
||||
partition_num = len(linux_client.get_partitions().split('\n'))
|
||||
disks_num = len(linux_client.get_disks().split('\n'))
|
||||
|
||||
# Explicit server deletion necessary for Juno compatibility
|
||||
self.client.delete_server(server_no_eph_disk['id'])
|
||||
@ -320,8 +320,8 @@ class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.validation_resources['keypair']['private_key'],
|
||||
server=server_with_eph_disk,
|
||||
servers_client=self.client)
|
||||
partition_num_emph = len(linux_client.get_partitions().split('\n'))
|
||||
self.assertEqual(partition_num + 1, partition_num_emph)
|
||||
disks_num_eph = len(linux_client.get_disks().split('\n'))
|
||||
self.assertEqual(disks_num + 1, disks_num_eph)
|
||||
|
||||
|
||||
class ServersTestManualDisk(ServersTestJSON):
|
||||
|
@ -111,9 +111,9 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
|
||||
server=server,
|
||||
servers_client=self.servers_client)
|
||||
|
||||
partitions = linux_client.get_partitions()
|
||||
device_name_to_match = ' ' + self.device + '\n'
|
||||
self.assertIn(device_name_to_match, partitions)
|
||||
disks = linux_client.get_disks()
|
||||
device_name_to_match = '\n' + self.device + ' '
|
||||
self.assertIn(device_name_to_match, disks)
|
||||
|
||||
self._detach_volume(server['id'], attachment['volumeId'])
|
||||
self.servers_client.stop_server(server['id'])
|
||||
@ -133,8 +133,8 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
|
||||
server=server,
|
||||
servers_client=self.servers_client)
|
||||
|
||||
partitions = linux_client.get_partitions()
|
||||
self.assertNotIn(device_name_to_match, partitions)
|
||||
disks = linux_client.get_disks()
|
||||
self.assertNotIn(device_name_to_match, disks)
|
||||
|
||||
@test.idempotent_id('7fa563fe-f0f7-43eb-9e22-a1ece036b513')
|
||||
def test_list_get_volume_attachments(self):
|
||||
|
@ -112,11 +112,22 @@ class RemoteClient(object):
|
||||
output = self.exec_command('grep -c ^processor /proc/cpuinfo')
|
||||
return int(output)
|
||||
|
||||
def get_partitions(self):
|
||||
# Return the contents of /proc/partitions
|
||||
command = 'cat /proc/partitions'
|
||||
def get_disks(self):
|
||||
# Select root disk devices as shown by lsblk
|
||||
command = 'lsblk -lb --nodeps'
|
||||
output = self.exec_command(command)
|
||||
return output
|
||||
selected = []
|
||||
pos = None
|
||||
for l in output.splitlines():
|
||||
if pos is None and l.find("TYPE") > 0:
|
||||
pos = l.find("TYPE")
|
||||
# Show header line too
|
||||
selected.append(l)
|
||||
# lsblk lists disk type in a column right-aligned with TYPE
|
||||
elif pos > 0 and l[pos:pos + 4] == "disk":
|
||||
selected.append(l)
|
||||
|
||||
return "\n".join(selected)
|
||||
|
||||
def get_boot_time(self):
|
||||
cmd = 'cut -f1 -d. /proc/uptime'
|
||||
|
@ -66,10 +66,10 @@ class TestMinimumBasicScenario(manager.ScenarioTest):
|
||||
waiters.wait_for_server_status(self.servers_client,
|
||||
server['id'], 'ACTIVE')
|
||||
|
||||
def check_partitions(self):
|
||||
def check_disks(self):
|
||||
# NOTE(andreaf) The device name may be different on different guest OS
|
||||
partitions = self.linux_client.get_partitions()
|
||||
self.assertEqual(1, partitions.count(CONF.compute.volume_device_name))
|
||||
disks = self.linux_client.get_disks()
|
||||
self.assertEqual(1, disks.count(CONF.compute.volume_device_name))
|
||||
|
||||
def create_and_add_security_group_to_server(self, server):
|
||||
secgroup = self._create_security_group()
|
||||
@ -145,7 +145,7 @@ class TestMinimumBasicScenario(manager.ScenarioTest):
|
||||
self.linux_client = self.get_remote_client(
|
||||
floating_ip['ip'], private_key=keypair['private_key'])
|
||||
|
||||
self.check_partitions()
|
||||
self.check_disks()
|
||||
|
||||
# delete the floating IP, this should refresh the server addresses
|
||||
self.compute_floating_ips_client.delete_floating_ip(floating_ip['id'])
|
||||
|
@ -85,9 +85,9 @@ class TestStampPattern(manager.ScenarioTest):
|
||||
ssh = self.get_remote_client(ip_address, private_key=private_key)
|
||||
|
||||
def _func():
|
||||
part = ssh.get_partitions()
|
||||
LOG.debug("Partitions:%s" % part)
|
||||
return CONF.compute.volume_device_name in part
|
||||
disks = ssh.get_disks()
|
||||
LOG.debug("Disks: %s" % disks)
|
||||
return CONF.compute.volume_device_name in disks
|
||||
|
||||
if not test_utils.call_until_true(_func,
|
||||
CONF.compute.build_timeout,
|
||||
|
@ -107,13 +107,20 @@ class TestRemoteClient(base.TestCase):
|
||||
self.assertEqual(self.conn.get_number_of_vcpus(), 16)
|
||||
self._assert_exec_called_with('grep -c ^processor /proc/cpuinfo')
|
||||
|
||||
def test_get_partitions(self):
|
||||
proc_partitions = """major minor #blocks name
|
||||
def test_get_disks(self):
|
||||
output_lsblk = """\
|
||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
||||
sda 8:0 0 128035676160 0 disk
|
||||
sdb 8:16 0 1000204886016 0 disk
|
||||
sr0 11:0 1 1073741312 0 rom"""
|
||||
result = """\
|
||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
||||
sda 8:0 0 128035676160 0 disk
|
||||
sdb 8:16 0 1000204886016 0 disk"""
|
||||
|
||||
8 0 1048576 vda"""
|
||||
self.ssh_mock.mock.exec_command.return_value = proc_partitions
|
||||
self.assertEqual(self.conn.get_partitions(), proc_partitions)
|
||||
self._assert_exec_called_with('cat /proc/partitions')
|
||||
self.ssh_mock.mock.exec_command.return_value = output_lsblk
|
||||
self.assertEqual(self.conn.get_disks(), result)
|
||||
self._assert_exec_called_with('lsblk -lb --nodeps')
|
||||
|
||||
def test_get_boot_time(self):
|
||||
booted_at = 10000
|
||||
|
Loading…
Reference in New Issue
Block a user