Check network_data info in config drive tests

There is an existing scenario test that verifies the meta_data.json
contents of config drives. Extend this to also do verification of the
network_data.json information on the config drive.

The network_data has been included in various ways by different cloud
deployments so we want to have a concrete test for this somewhere as the
first step towards consistency.

Change-Id: Ia148bca2cd932ccdf9735142e0082a330212ee04
This commit is contained in:
Clark Boylan 2016-07-06 09:55:28 -07:00
parent 617e65ac03
commit df73bdf0c0

View File

@ -81,22 +81,42 @@ class TestServerBasicOps(manager.ScenarioTest):
'verify metadata on server. '
'%s is empty.' % md_url)
def verify_metadata_on_config_drive(self):
if self.run_ssh and CONF.compute_feature_enabled.config_drive:
# Verify metadata on config_drive
def _mount_config_drive(self):
cmd_blkid = 'blkid | grep -i config-2'
result = self.ssh_client.exec_command(cmd_blkid)
dev_name = re.match('([^:]+)', result).group()
self.ssh_client.exec_command('sudo mount %s /mnt' % dev_name)
def _unmount_config_drive(self):
self.ssh_client.exec_command('sudo umount /mnt')
def verify_metadata_on_config_drive(self):
if self.run_ssh and CONF.compute_feature_enabled.config_drive:
# Verify metadata on config_drive
self._mount_config_drive()
cmd_md = 'sudo cat /mnt/openstack/latest/meta_data.json'
result = self.ssh_client.exec_command(cmd_md)
self.ssh_client.exec_command('sudo umount /mnt')
self._unmount_config_drive()
result = json.loads(result)
self.assertIn('meta', result)
msg = ('Failed while verifying metadata on config_drive on server.'
' Result of command "%s" is NOT "%s".' % (cmd_md, self.md))
self.assertEqual(self.md, result['meta'], msg)
def verify_networkdata_on_config_drive(self):
if self.run_ssh and CONF.compute_feature_enabled.config_drive:
# Verify network data on config_drive
self._mount_config_drive()
cmd_md = 'sudo cat /mnt/openstack/latest/network_data.json'
result = self.ssh_client.exec_command(cmd_md)
self._unmount_config_drive()
result = json.loads(result)
self.assertIn('services', result)
self.assertIn('links', result)
self.assertIn('networks', result)
# TODO(clarkb) construct network_data from known network
# instance info and do direct comparison.
@test.idempotent_id('7fff3fb3-91d8-4fd0-bd7d-0204f1f180ba')
@test.attr(type='smoke')
@test.services('compute', 'network')
@ -116,4 +136,5 @@ class TestServerBasicOps(manager.ScenarioTest):
self.verify_ssh(keypair)
self.verify_metadata()
self.verify_metadata_on_config_drive()
self.verify_networkdata_on_config_drive()
self.servers_client.delete_server(self.instance['id'])