Merge "Move get_server_or_ip method to common class"
This commit is contained in:
commit
cca55181f9
@ -600,6 +600,13 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
||||
ssh_client.umount(mount_path)
|
||||
return timestamp
|
||||
|
||||
def get_server_or_ip(self, server):
|
||||
if CONF.validation.connect_method == 'floating':
|
||||
ip = self.create_floating_ip(server)['ip']
|
||||
else:
|
||||
ip = server
|
||||
return ip
|
||||
|
||||
|
||||
class NetworkScenarioTest(ScenarioTest):
|
||||
"""Base class for network scenario tests.
|
||||
|
@ -78,24 +78,17 @@ class TestShelveInstance(manager.ScenarioTest):
|
||||
server = self.create_server(image=CONF.compute.image_ref,
|
||||
create_kwargs=create_kwargs)
|
||||
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
floating_ip = self.create_floating_ip(server)['ip']
|
||||
timestamp = self.create_timestamp(
|
||||
floating_ip, private_key=keypair['private_key'])
|
||||
else:
|
||||
timestamp = self.create_timestamp(
|
||||
server, private_key=keypair['private_key'])
|
||||
instance_ip = self.get_server_or_ip(server)
|
||||
timestamp = self.create_timestamp(instance_ip,
|
||||
private_key=keypair['private_key'])
|
||||
|
||||
# Prevent bug #1257594 from coming back
|
||||
# Unshelve used to boot the instance with the original image, not
|
||||
# with the instance snapshot
|
||||
self._shelve_then_unshelve_server(server)
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
timestamp2 = self.get_timestamp(floating_ip,
|
||||
private_key=keypair['private_key'])
|
||||
else:
|
||||
timestamp2 = self.get_timestamp(server,
|
||||
private_key=keypair['private_key'])
|
||||
|
||||
timestamp2 = self.get_timestamp(instance_ip,
|
||||
private_key=keypair['private_key'])
|
||||
self.assertEqual(timestamp, timestamp2)
|
||||
|
||||
@test.idempotent_id('1164e700-0af0-4a4c-8792-35909a88743c')
|
||||
|
@ -56,13 +56,9 @@ class TestSnapshotPattern(manager.ScenarioTest):
|
||||
# boot an instance and create a timestamp file in it
|
||||
server = self._boot_image(CONF.compute.image_ref, keypair,
|
||||
security_group)
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
fip_for_server = self.create_floating_ip(server)
|
||||
timestamp = self.create_timestamp(
|
||||
fip_for_server['ip'], private_key=keypair['private_key'])
|
||||
else:
|
||||
timestamp = self.create_timestamp(
|
||||
server, private_key=keypair['private_key'])
|
||||
instance_ip = self.get_server_or_ip(server)
|
||||
timestamp = self.create_timestamp(instance_ip,
|
||||
private_key=keypair['private_key'])
|
||||
|
||||
# snapshot the instance
|
||||
snapshot_image = self.create_server_snapshot(server=server)
|
||||
@ -72,11 +68,7 @@ class TestSnapshotPattern(manager.ScenarioTest):
|
||||
keypair, security_group)
|
||||
|
||||
# check the existence of the timestamp file in the second instance
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
fip_for_snapshot = self.create_floating_ip(server_from_snapshot)
|
||||
timestamp2 = self.get_timestamp(fip_for_snapshot['ip'],
|
||||
private_key=keypair['private_key'])
|
||||
else:
|
||||
timestamp2 = self.get_timestamp(server_from_snapshot,
|
||||
private_key=keypair['private_key'])
|
||||
server_from_snapshot_ip = self.get_server_or_ip(server_from_snapshot)
|
||||
timestamp2 = self.get_timestamp(server_from_snapshot_ip,
|
||||
private_key=keypair['private_key'])
|
||||
self.assertEqual(timestamp, timestamp2)
|
||||
|
@ -139,11 +139,7 @@ class TestStampPattern(manager.ScenarioTest):
|
||||
security_group)
|
||||
|
||||
# create and add floating IP to server1
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
floating_ip_for_server = self.create_floating_ip(server)
|
||||
ip_for_server = floating_ip_for_server['ip']
|
||||
else:
|
||||
ip_for_server = server
|
||||
ip_for_server = self.get_server_or_ip(server)
|
||||
|
||||
self._attach_volume(server, volume)
|
||||
self._wait_for_volume_available_on_the_system(ip_for_server,
|
||||
@ -168,12 +164,7 @@ class TestStampPattern(manager.ScenarioTest):
|
||||
keypair, security_group)
|
||||
|
||||
# create and add floating IP to server_from_snapshot
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
floating_ip_for_snapshot = self.create_floating_ip(
|
||||
server_from_snapshot)
|
||||
ip_for_snapshot = floating_ip_for_snapshot['ip']
|
||||
else:
|
||||
ip_for_snapshot = server_from_snapshot
|
||||
ip_for_snapshot = self.get_server_or_ip(server_from_snapshot)
|
||||
|
||||
# attach volume2 to instance2
|
||||
self._attach_volume(server_from_snapshot, volume_from_snapshot)
|
||||
|
@ -94,13 +94,6 @@ class TestVolumeBootPattern(manager.ScenarioTest):
|
||||
vol_name = data_utils.rand_name('volume')
|
||||
return self.create_volume(name=vol_name, snapshot_id=snap_id)
|
||||
|
||||
def _get_server_ip(self, server):
|
||||
if CONF.compute.use_floatingip_for_ssh:
|
||||
ip = self.create_floating_ip(server)['ip']
|
||||
else:
|
||||
ip = server
|
||||
return ip
|
||||
|
||||
def _delete_server(self, server):
|
||||
self.servers_client.delete_server(server['id'])
|
||||
waiters.wait_for_server_termination(self.servers_client, server['id'])
|
||||
@ -118,7 +111,7 @@ class TestVolumeBootPattern(manager.ScenarioTest):
|
||||
keypair, security_group)
|
||||
|
||||
# write content to volume on instance
|
||||
ip_instance_1st = self._get_server_ip(instance_1st)
|
||||
ip_instance_1st = self.get_server_or_ip(instance_1st)
|
||||
timestamp = self.create_timestamp(ip_instance_1st,
|
||||
private_key=keypair['private_key'])
|
||||
|
||||
@ -130,7 +123,7 @@ class TestVolumeBootPattern(manager.ScenarioTest):
|
||||
keypair, security_group)
|
||||
|
||||
# check the content of written file
|
||||
ip_instance_2nd = self._get_server_ip(instance_2nd)
|
||||
ip_instance_2nd = self.get_server_or_ip(instance_2nd)
|
||||
timestamp2 = self.get_timestamp(ip_instance_2nd,
|
||||
private_key=keypair['private_key'])
|
||||
self.assertEqual(timestamp, timestamp2)
|
||||
@ -140,13 +133,13 @@ class TestVolumeBootPattern(manager.ScenarioTest):
|
||||
|
||||
# create a 3rd instance from snapshot
|
||||
volume = self._create_volume_from_snapshot(snapshot['id'])
|
||||
instance_from_snapshot = (
|
||||
server_from_snapshot = (
|
||||
self._boot_instance_from_volume(volume['id'],
|
||||
keypair, security_group))
|
||||
|
||||
# check the content of written file
|
||||
ip_instance_from_snapshot = self._get_server_ip(instance_from_snapshot)
|
||||
timestamp3 = self.get_timestamp(ip_instance_from_snapshot,
|
||||
server_from_snapshot_ip = self.get_server_or_ip(server_from_snapshot)
|
||||
timestamp3 = self.get_timestamp(server_from_snapshot_ip,
|
||||
private_key=keypair['private_key'])
|
||||
self.assertEqual(timestamp, timestamp3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user