Change naming (again) for networks and subnets.
There is a need for changing names again, since namespace id is no longer stored in description and name for net/subnet is a compound of name and uid. Depends-On: https://review.opendev.org/c/openstack/kuryr-tempest-plugin/+/845745 Change-Id: Ib97a597f8afb47316e77154a9bf3ced41ce48468
This commit is contained in:
parent
962594cc7b
commit
0cc8ae0fae
@ -49,6 +49,7 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
# Check resources are created
|
# Check resources are created
|
||||||
namespace_name, namespace = self.create_namespace()
|
namespace_name, namespace = self.create_namespace()
|
||||||
self.namespaces.append(namespace)
|
self.namespaces.append(namespace)
|
||||||
|
ns_uid = namespace.metadata.uid
|
||||||
|
|
||||||
existing_namespaces = [ns.metadata.name
|
existing_namespaces = [ns.metadata.name
|
||||||
for ns in self.list_namespaces().items]
|
for ns in self.list_namespaces().items]
|
||||||
@ -63,9 +64,11 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
||||||
seen_subnet_names = [n['name'] for n in seen_subnets['subnets']]
|
seen_subnet_names = [n['name'] for n in seen_subnets['subnets']]
|
||||||
|
|
||||||
subnet_name = namespace_name
|
subnet_name = (f"{ns_uid}/{namespace_name}")
|
||||||
if subnet_name not in seen_subnet_names:
|
if subnet_name not in seen_subnet_names:
|
||||||
subnet_name = 'ns/' + namespace_name + '-subnet'
|
subnet_name = 'ns/' + namespace_name + '-subnet'
|
||||||
|
if subnet_name not in seen_subnet_names:
|
||||||
|
subnet_name = namespace_name
|
||||||
|
|
||||||
self.assertIn(subnet_name, seen_subnet_names)
|
self.assertIn(subnet_name, seen_subnet_names)
|
||||||
|
|
||||||
@ -112,9 +115,9 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
seen_sg_ids = [sg['id'] for sg in seen_sgs]
|
seen_sg_ids = [sg['id'] for sg in seen_sgs]
|
||||||
|
|
||||||
subnet_ns1_name, net_crd_ns1 = self._get_and_check_ns_resources(
|
subnet_ns1_name, net_crd_ns1 = self._get_and_check_ns_resources(
|
||||||
ns1_name, existing_namespaces, seen_sg_ids)
|
ns1, existing_namespaces, seen_sg_ids)
|
||||||
subnet_ns2_name, net_crd_ns2 = self._get_and_check_ns_resources(
|
subnet_ns2_name, net_crd_ns2 = self._get_and_check_ns_resources(
|
||||||
ns2_name, existing_namespaces, seen_sg_ids)
|
ns2, existing_namespaces, seen_sg_ids)
|
||||||
self.assertIn('default', existing_namespaces)
|
self.assertIn('default', existing_namespaces)
|
||||||
|
|
||||||
# Create pods in different namespaces
|
# Create pods in different namespaces
|
||||||
@ -153,17 +156,24 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
||||||
if subnet_ns1_name not in seen_subnets:
|
if subnet_ns1_name not in seen_subnets:
|
||||||
subnet_ns1_name = f'ns/{ns1_name}-subnet'
|
subnet_ns1_name = f'ns/{ns1_name}-subnet'
|
||||||
|
if subnet_ns1_name not in seen_subnets:
|
||||||
|
subnet_ns1_name = ns1_name
|
||||||
if subnet_ns2_name not in seen_subnets:
|
if subnet_ns2_name not in seen_subnets:
|
||||||
subnet_ns2_name = f'ns/{ns2_name}-subnet'
|
subnet_ns2_name = f'ns/{ns2_name}-subnet'
|
||||||
|
if subnet_ns2_name not in seen_subnets:
|
||||||
|
subnet_ns2_name = ns2_name
|
||||||
|
|
||||||
self._delete_namespace_resources(ns1_name, net_crd_ns1,
|
self._delete_namespace_resources(ns1_name, net_crd_ns1,
|
||||||
subnet_ns1_name)
|
subnet_ns1_name)
|
||||||
self._delete_namespace_resources(ns2_name, net_crd_ns2,
|
self._delete_namespace_resources(ns2_name, net_crd_ns2,
|
||||||
subnet_ns2_name)
|
subnet_ns2_name)
|
||||||
|
|
||||||
def _get_and_check_ns_resources(self, ns_name, existing_namespaces,
|
def _get_and_check_ns_resources(self, ns, existing_namespaces,
|
||||||
existing_sgs):
|
existing_sgs):
|
||||||
subnet_ns_name = ns_name
|
ns_name = ns.metadata.name
|
||||||
|
ns_uid = ns.metadata.name
|
||||||
|
subnet_ns_name = f'{ns_uid}/{ns_name}'
|
||||||
|
|
||||||
net_crd_ns_name = 'ns-' + ns_name
|
net_crd_ns_name = 'ns-' + ns_name
|
||||||
self.assertIn(ns_name, existing_namespaces)
|
self.assertIn(ns_name, existing_namespaces)
|
||||||
|
|
||||||
@ -209,9 +219,9 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
seen_sg_ids = [sg['id'] for sg in seen_sgs]
|
seen_sg_ids = [sg['id'] for sg in seen_sgs]
|
||||||
|
|
||||||
subnet_ns1_name, net_crd_ns1 = self._get_and_check_ns_resources(
|
subnet_ns1_name, net_crd_ns1 = self._get_and_check_ns_resources(
|
||||||
ns1_name, existing_namespaces, seen_sg_ids)
|
ns1, existing_namespaces, seen_sg_ids)
|
||||||
subnet_ns2_name, net_crd_ns2 = self._get_and_check_ns_resources(
|
subnet_ns2_name, net_crd_ns2 = self._get_and_check_ns_resources(
|
||||||
ns2_name, existing_namespaces, seen_sg_ids)
|
ns2, existing_namespaces, seen_sg_ids)
|
||||||
self.assertIn('default', existing_namespaces)
|
self.assertIn('default', existing_namespaces)
|
||||||
|
|
||||||
pod_nsdefault_name, pod_nsdefault = self.create_pod(
|
pod_nsdefault_name, pod_nsdefault = self.create_pod(
|
||||||
@ -255,8 +265,12 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||||||
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
||||||
if subnet_ns1_name not in seen_subnets:
|
if subnet_ns1_name not in seen_subnets:
|
||||||
subnet_ns1_name = f'ns/{ns1_name}-subnet'
|
subnet_ns1_name = f'ns/{ns1_name}-subnet'
|
||||||
|
if subnet_ns1_name not in seen_subnets:
|
||||||
|
subnet_ns1_name = ns1_name
|
||||||
if subnet_ns2_name not in seen_subnets:
|
if subnet_ns2_name not in seen_subnets:
|
||||||
subnet_ns2_name = f'ns/{ns2_name}-subnet'
|
subnet_ns2_name = f'ns/{ns2_name}-subnet'
|
||||||
|
if subnet_ns2_name not in seen_subnets:
|
||||||
|
subnet_ns2_name = ns2_name
|
||||||
|
|
||||||
self._delete_namespace_resources(ns1_name, net_crd_ns1,
|
self._delete_namespace_resources(ns1_name, net_crd_ns1,
|
||||||
subnet_ns1_name)
|
subnet_ns1_name)
|
||||||
|
@ -53,19 +53,20 @@ class TestPortPoolScenario(base.BaseKuryrScenarioTest):
|
|||||||
'ports_pool_batch', 'ports_pool_min', 'ports_pool_max',
|
'ports_pool_batch', 'ports_pool_min', 'ports_pool_max',
|
||||||
'ports_pool_update_frequency'])
|
'ports_pool_update_frequency'])
|
||||||
|
|
||||||
def get_subnet_id_for_ns(self, namespace_name):
|
def get_subnet_id_for_ns(self, namespace):
|
||||||
subnet_name = namespace_name
|
|
||||||
subnets_list = self.os_admin.subnets_client.list_subnets()
|
subnets_list = self.os_admin.subnets_client.list_subnets()
|
||||||
subnet_id = [n['id'] for n in subnets_list['subnets']
|
ns_name = namespace.metadata.name
|
||||||
if n['name'] == subnet_name]
|
ns_uid = namespace.metadata.uid
|
||||||
if subnet_id:
|
|
||||||
subnet_id = subnet_id[0]
|
|
||||||
else:
|
|
||||||
subnet_name = f'ns/{namespace_name}-subnet'
|
|
||||||
subnet_id = [n['id'] for n in subnets_list['subnets']
|
|
||||||
if n['name'] == subnet_name][0]
|
|
||||||
|
|
||||||
return subnet_id
|
for subnet_name in (f'{ns_name}/{ns_uid}',
|
||||||
|
f'ns/{ns_name}-subnet',
|
||||||
|
ns_name):
|
||||||
|
subnet_id = [n['id'] for n in subnets_list['subnets']
|
||||||
|
if n['name'] == subnet_name]
|
||||||
|
if subnet_id:
|
||||||
|
return subnet_id[0]
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def check_initial_ports_num(self, subnet_id, namespace_name, pool_batch):
|
def check_initial_ports_num(self, subnet_id, namespace_name, pool_batch):
|
||||||
# check the original length of list of ports for new ns
|
# check the original length of list of ports for new ns
|
||||||
@ -105,9 +106,9 @@ class TestPortPoolScenario(base.BaseKuryrScenarioTest):
|
|||||||
# create a pod to test the port pool increase
|
# create a pod to test the port pool increase
|
||||||
pod_name1, _ = self.create_pod(namespace=namespace_name,
|
pod_name1, _ = self.create_pod(namespace=namespace_name,
|
||||||
labels={'type': 'demo'})
|
labels={'type': 'demo'})
|
||||||
subnet_id = self.get_subnet_id_for_ns(namespace_name)
|
subnet_id = self.get_subnet_id_for_ns(namespace)
|
||||||
else:
|
else:
|
||||||
subnet_id = self.get_subnet_id_for_ns(namespace_name)
|
subnet_id = self.get_subnet_id_for_ns(namespace)
|
||||||
port_list_num = self.check_initial_ports_num(subnet_id,
|
port_list_num = self.check_initial_ports_num(subnet_id,
|
||||||
namespace_name,
|
namespace_name,
|
||||||
pool_batch)
|
pool_batch)
|
||||||
@ -190,7 +191,7 @@ class TestPortPoolScenario(base.BaseKuryrScenarioTest):
|
|||||||
# Check resources are created
|
# Check resources are created
|
||||||
namespace_name, namespace = self.create_namespace()
|
namespace_name, namespace = self.create_namespace()
|
||||||
self.addCleanup(self.delete_namespace, namespace_name)
|
self.addCleanup(self.delete_namespace, namespace_name)
|
||||||
subnet_id = self.get_subnet_id_for_ns(namespace_name)
|
subnet_id = self.get_subnet_id_for_ns(namespace)
|
||||||
self.update_config_map_ini_section_and_restart(
|
self.update_config_map_ini_section_and_restart(
|
||||||
name=self.CONFIG_MAP_NAME,
|
name=self.CONFIG_MAP_NAME,
|
||||||
conf_to_update=self.CONF_TO_UPDATE,
|
conf_to_update=self.CONF_TO_UPDATE,
|
||||||
@ -253,7 +254,7 @@ class TestPortPoolScenario(base.BaseKuryrScenarioTest):
|
|||||||
# Check resources are created
|
# Check resources are created
|
||||||
namespace_name, namespace = self.create_namespace()
|
namespace_name, namespace = self.create_namespace()
|
||||||
self.addCleanup(self.delete_namespace, namespace_name)
|
self.addCleanup(self.delete_namespace, namespace_name)
|
||||||
subnet_id = self.get_subnet_id_for_ns(namespace_name)
|
subnet_id = self.get_subnet_id_for_ns(namespace)
|
||||||
|
|
||||||
# Read the value of the drivers
|
# Read the value of the drivers
|
||||||
update_pools_vif_drivers = self.get_config_map_ini_value(
|
update_pools_vif_drivers = self.get_config_map_ini_value(
|
||||||
@ -348,7 +349,7 @@ class TestPortPoolScenario(base.BaseKuryrScenarioTest):
|
|||||||
# Check resources are created
|
# Check resources are created
|
||||||
namespace_name, namespace = self.create_namespace()
|
namespace_name, namespace = self.create_namespace()
|
||||||
self.addCleanup(self.delete_namespace, namespace_name)
|
self.addCleanup(self.delete_namespace, namespace_name)
|
||||||
subnet_id = self.get_subnet_id_for_ns(namespace_name)
|
subnet_id = self.get_subnet_id_for_ns(namespace)
|
||||||
|
|
||||||
self.update_config_map_ini_section_and_restart(
|
self.update_config_map_ini_section_and_restart(
|
||||||
name=self.CONFIG_MAP_NAME,
|
name=self.CONFIG_MAP_NAME,
|
||||||
|
Loading…
Reference in New Issue
Block a user