Namespace network resources cleanup
It adds checks for connectivity and namespace deletion, including checking for resource leftovers. Change-Id: Id08dfeb0d7423857cd471100410dabd71646b402
This commit is contained in:
parent
f12edd7100
commit
2640527765
|
@ -143,7 +143,7 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
pod_fip = self.os_admin.floating_ips_client.create_floatingip(
|
||||
floating_network_id=ext_net_id,
|
||||
tenant_id=self.get_project_id(),
|
||||
port_id=self.get_pod_port(pod_name)['id'])
|
||||
port_id=self.get_pod_port(pod_name, namespace)['id'])
|
||||
self.pod_fips.append(pod_fip)
|
||||
return pod_fip
|
||||
|
||||
|
|
|
@ -12,8 +12,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import kubernetes
|
||||
import shlex
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from oslo_log import log as logging
|
||||
from tempest import config
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
|
||||
from kuryr_tempest_plugin.tests.scenario import base
|
||||
|
||||
|
@ -35,8 +41,8 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||
super(TestNamespaceScenario, cls).setup_clients()
|
||||
|
||||
def test_namespace(self):
|
||||
# Check resources are created
|
||||
namespace_name, namespace = self.create_namespace()
|
||||
self.addCleanup(self.delete_namespace, namespace_name)
|
||||
|
||||
existing_namespaces = [ns.metadata.name
|
||||
for ns in self.list_namespaces().items]
|
||||
|
@ -61,3 +67,39 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
|
|||
self.assertIn(kuryr_net_crd_name, kuryr_net_crd['metadata']['name'])
|
||||
self.assertIn(kuryr_net_crd['spec']['subnetId'], subnet_id)
|
||||
self.assertIn(kuryr_net_crd['spec']['netId'], net_id)
|
||||
|
||||
# Check namespace pod connectivity
|
||||
pod_name, pod = self.create_pod(labels={"app": 'pod-label'},
|
||||
namespace=namespace_name)
|
||||
svc_name, _ = self.create_service(pod_label=pod.metadata.labels,
|
||||
namespace=namespace_name)
|
||||
svc_service_ip = self.get_service_ip(service_name=svc_name,
|
||||
namespace=namespace_name)
|
||||
self.wait_service_status(svc_service_ip,
|
||||
CONF.kuryr_kubernetes.lb_build_timeout)
|
||||
|
||||
cmd = "curl {dst_ip}".format(dst_ip=svc_service_ip)
|
||||
try:
|
||||
subprocess.check_output(shlex.split(cmd))
|
||||
except subprocess.CalledProcessError:
|
||||
LOG.error("Checking output of curl to the service IP %s "
|
||||
"failed" % svc_service_ip)
|
||||
raise lib_exc.UnexpectedResponseCode()
|
||||
|
||||
# Check resources are deleted
|
||||
self.delete_namespace(namespace_name)
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
try:
|
||||
self.get_kuryr_net_crds(kuryr_net_crd_name)
|
||||
except kubernetes.client.rest.ApiException:
|
||||
break
|
||||
|
||||
existing_namespaces = [ns.metadata.name
|
||||
for ns in self.list_namespaces().items]
|
||||
|
||||
seen_subnets = self.os_admin.subnets_client.list_subnets()
|
||||
seen_subnet_names = [n['name'] for n in seen_subnets['subnets']]
|
||||
|
||||
self.assertNotIn(subnet_name, seen_subnet_names)
|
||||
|
|
Loading…
Reference in New Issue