trunk tests issue fixing

Change-Id: Id0395db4b9e9d307acc736326fca84ba35d2e711
This commit is contained in:
dkumbhar 2020-03-23 23:31:03 +00:00
parent dc923060ef
commit 226664ee4b
3 changed files with 67 additions and 63 deletions

View File

@ -283,6 +283,6 @@ TrunkGroup = [
default='ubuntu',
help="image for trunk"),
cfg.StrOpt('flavor_id',
default='m3.small',
default='m1.small',
help="flavor for trunk"),
]

View File

@ -47,6 +47,7 @@ class BaseTrunkClient(base.BaseNetworkClient):
class TrunkClient(BaseTrunkClient):
create_trunk_path = '/trunks'
add_sub_port = '/trunks/%s/add_subports'
remove_sub_port = '/trunks/%s/remove_subports'
def create_trunk(self, **kwargs):
"""Create a trunk parent port.
@ -61,6 +62,12 @@ class TrunkClient(BaseTrunkClient):
response_data = self.update_resource(self.url, post_data)
return response_data
def remove_subport(self, trunkportid, **kwargs):
post_data = kwargs
self.url = self.remove_sub_port % trunkportid
response_data = self.update_resource(self.url, post_data)
return response_data
def get_client(client_mgr,
set_property=False, with_name="trunk_client"):

View File

@ -81,6 +81,10 @@ class TestTrunkService(feature_manager.FeatureManager):
def add_subports(cls, trunkportid, **kwargs):
return cls.trunk_client.add_subport(trunkportid, **kwargs)
@classmethod
def remove_subport(cls, trunkportid, **kwargs):
return cls.trunk_client.remove_subport(trunkportid, **kwargs)
def create_trunk_parent_port(self, provider, project_id,
parent_port, trunkportname):
kwargs = {}
@ -113,14 +117,14 @@ class TestTrunkService(feature_manager.FeatureManager):
delete_child_port = self.remove_subport(trunkportid, **kwargs)
return delete_child_port
def _assign_ip_address(self, ssh_source, interface_name, ip_address):
def _assign_ip_address(self, ssh_src1, interface_name, ip_address):
int_face = interface_name.split('.')[0]
vlan_id = interface_name.split('.')[1]
ssh_source.exec_command("sudo ip link add link %s name %s type vlan\
id %s" % (int_face, interface_name, vlan_id))
ssh_src1.exec_command("sudo ip link add link %s name %s type vlan\
id %s" % (int_face, interface_name, vlan_id))
ssh_source.exec_command("sudo ifconfig %s %s/24 \
up" % (interface_name, ip_address))
ssh_src1.exec_command("sudo ifconfig %s %s/24 \
up" % (interface_name, ip_address))
def create_trunk_network_topo(self,
create_instance=True,
@ -275,32 +279,30 @@ class TestTrunkService(feature_manager.FeatureManager):
keypair=keypair,
flavor=flavor_name)
ip_address = server1['floating_ips'][0]['floating_ip_address']
ssh_source = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
ip_address = server2['floating_ips'][0]['floating_ip_address']
ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
# Verify connectivity between vms
self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2)
self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_source, remote_ip,
self._assign_ip_address(ssh_src2, 'eth0.101', child1_ip_vm2)
self._assign_ip_address(ssh_src2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=True)
self.check_remote_connectivity(ssh_source, child2_ip_vm2,
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
# Remove subport & check connectivity should fail #
child2_trunk_p2 = self.remove_subport(provider=True,
project_id=project_id,
child_port=child2_id,
trunkportid=trunk_parent2)
self.check_remote_connectivity(ssh_source, child2_ip_vm2,
child2_trunk_p2 = self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_id,
trunkportid=trunk_parent2)
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=False)
child2_trunk_p2 = self.add_subport_to_parent(provider=True,
vlan_id=102,
@ -309,14 +311,11 @@ class TestTrunkService(feature_manager.FeatureManager):
childportname='ch22_p2',
trunkportid=trunk_parent2)
ip_address = server2['floating_ips'][0]['floating_ip_address']
ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
# Verify connectivity between vms
self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2)
self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_source, child2_ip_vm2,
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
def _test_trunk_instance_destroy_deploy(self, topology):
@ -398,25 +397,23 @@ class TestTrunkService(feature_manager.FeatureManager):
keypair=keypair,
flavor=flavor_name)
ip_address = server1['floating_ips'][0]['floating_ip_address']
ssh_source = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
ip_address = server2['floating_ips'][0]['floating_ip_address']
ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2)
self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_source, remote_ip,
ssh_src2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
self._assign_ip_address(ssh_src2, 'eth0.101', child1_ip_vm2)
self._assign_ip_address(ssh_src2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=True)
self.os_admin.servers_client.delete_server(server2['id'])
self.check_remote_connectivity(ssh_source, remote_ip,
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=False)
time.sleep(constants.NSX_BACKEND_SMALL_TIME_INTERVAL)
server2 = self.create_topology_instance(server_name2_default,
@ -424,8 +421,10 @@ class TestTrunkService(feature_manager.FeatureManager):
image_id=image_id,
port=parent2_port['port'],
security_groups=[sg_name_dict],
clients=self.cmgr_adm)
self.check_remote_connectivity(ssh_source, remote_ip,
clients=self.cmgr_adm,
keypair=keypair,
flavor=flavor_name)
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=True)
def _test_trunk_between_two_vms(self, topology):
@ -505,29 +504,27 @@ class TestTrunkService(feature_manager.FeatureManager):
keypair=keypair,
flavor=flavor_name)
ip_address = server1['floating_ips'][0]['floating_ip_address']
ssh_source = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
ip_address = server2['floating_ips'][0]['floating_ip_address']
ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key']
)
ssh_src2 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
# Verify connectivity between vms
child1_ip_vm2 = child1_p2['port']['fixed_ips'][0]['ip_address']
child2_ip_vm2 = child2_p2['port']['fixed_ips'][0]['ip_address']
self._assign_ip_address(ssh_sourc2, 'eth0.101', child1_ip_vm2)
self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_source, remote_ip,
self._assign_ip_address(ssh_src2, 'eth0.101', child1_ip_vm2)
self._assign_ip_address(ssh_src2, 'eth0.102', child2_ip_vm2)
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=True)
self.check_remote_connectivity(ssh_source, child1_ip_vm2,
self.check_remote_connectivity(ssh_src1, child1_ip_vm2,
should_succeed=True)
self.check_remote_connectivity(ssh_source, child2_ip_vm2,
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
@decorators.idempotent_id('9d4192e9-b1b7-48c9-af04-67a82637c359')