Merge "update tests for bug 2112187" into mcp/epoxy
diff --git a/requirements.txt b/requirements.txt
index a1eff53..a9046fb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -21,3 +21,4 @@
defusedxml>=0.7.1 # PSFL
fasteners>=0.16.0 # Apache-2.0
testscenarios>=0.5.0
+tenacity>=4.4.0 # Apache-2.0
diff --git a/tempest/api/compute/servers/test_novnc.py b/tempest/api/compute/servers/test_novnc.py
index 1308b19..c90aea8 100644
--- a/tempest/api/compute/servers/test_novnc.py
+++ b/tempest/api/compute/servers/test_novnc.py
@@ -64,7 +64,15 @@
def _validate_novnc_html(self, vnc_url):
"""Verify we can connect to novnc and get back the javascript."""
- resp = urllib3.PoolManager().request('GET', vnc_url)
+ cert_params = {}
+
+ if CONF.identity.disable_ssl_certificate_validation:
+ cert_params['cert_reqs'] = "CERT_NONE"
+ else:
+ cert_params["cert_reqs"] = "CERT_REQUIRED"
+ cert_params["ca_certs"] = CONF.identity.ca_certificates_file
+
+ resp = urllib3.PoolManager(**cert_params).request('GET', vnc_url)
# Make sure that the GET request was accepted by the novncproxy
self.assertEqual(resp.status, 200, 'Got a Bad HTTP Response on the '
'initial call: ' + str(resp.status))
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 5bbd50e..79c29d7 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -21,6 +21,7 @@
from tempest import exceptions
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
+from tempest.lib.common import waiters as lib_waiters
from tempest.lib import exceptions as lib_exc
import tempest.test
@@ -226,6 +227,9 @@
test_utils.call_and_ignore_notfound_exc(
cls.routers_client.remove_router_interface, router['id'],
subnet_id=i['fixed_ips'][0]['subnet_id'])
+ lib_waiters.wait_router_interface_removed(
+ cls.ports_client, router['id'],
+ subnet_id=i['fixed_ips'][0]['subnet_id'])
cls.routers_client.delete_router(router['id'])
def remove_router_interface(self, router_id, port_id, subnet_id=None):
diff --git a/tempest/api/volume/test_volumes_filters.py b/tempest/api/volume/test_volumes_filters.py
index 6d45aa5..8ac3d90 100644
--- a/tempest/api/volume/test_volumes_filters.py
+++ b/tempest/api/volume/test_volumes_filters.py
@@ -28,6 +28,10 @@
CONF.volume_feature_enabled.instance_locality_enabled,
"InstanceLocalityFilter test is disabled",
)
+ @testtools.skipUnless(
+ CONF.volume_feature_enabled.instance_locality_enabled,
+ "InstanceLocalityFilter test is disabled",
+ )
@decorators.idempotent_id("5c13f4f7-5add-4fad-8ef7-dccca0f76295")
def test_instancelocalityfilter(self):
# 1. Create instance
diff --git a/tempest/lib/common/constants.py b/tempest/lib/common/constants.py
new file mode 100644
index 0000000..57fdd93
--- /dev/null
+++ b/tempest/lib/common/constants.py
@@ -0,0 +1,5 @@
+# Retry constants
+RETRY_ATTEMPTS = 30
+RETRY_INITIAL_DELAY = 1
+RETRY_BACKOFF = 3
+RETRY_MAX = 10
diff --git a/tempest/lib/common/dynamic_creds.py b/tempest/lib/common/dynamic_creds.py
index 5890b55..d4bd302 100644
--- a/tempest/lib/common/dynamic_creds.py
+++ b/tempest/lib/common/dynamic_creds.py
@@ -16,11 +16,15 @@
import netaddr
from oslo_log import log as logging
+import tenacity
+import tempest.lib.common.constants as const
from tempest.lib.common import cred_client
from tempest.lib.common import cred_provider
from tempest.lib.common.utils import data_utils
+from tempest.lib.common import waiters as lib_waiters
from tempest.lib import exceptions as lib_exc
+
from tempest.lib.services import clients
LOG = logging.getLogger(__name__)
@@ -539,6 +543,11 @@
del self._creds[creds_name]
return self.get_credentials(roles, scope=scope, by_role=True)
+ @tenacity.retry(
+ retry=tenacity.retry_if_exception_type(lib_exc.Conflict),
+ wait=tenacity.wait_incrementing(
+ const.RETRY_INITIAL_DELAY, const.RETRY_BACKOFF, const.RETRY_MAX),
+ stop=tenacity.stop_after_attempt(const.RETRY_ATTEMPTS))
def _clear_isolated_router(self, router_id, router_name):
client = self.routers_admin_client
try:
@@ -580,6 +589,9 @@
client.remove_router_interface(
creds.router['id'],
subnet_id=creds.subnet['id'])
+ lib_waiters.wait_router_interface_removed(
+ self.ports_admin_client, creds.router['id'],
+ subnet_id=creds.subnet['id'])
except lib_exc.NotFound:
LOG.warning('router with name: %s not found for delete',
creds.router['name'])
diff --git a/tempest/lib/common/waiters.py b/tempest/lib/common/waiters.py
new file mode 100644
index 0000000..1f0bdc9
--- /dev/null
+++ b/tempest/lib/common/waiters.py
@@ -0,0 +1,32 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import time
+
+from tempest.lib import exceptions as lib_exc
+
+
+def wait_router_interface_removed(
+ ports_client, router_id, subnet_id, timeout=30, interval=3):
+ """Waits for router inface is removed"""
+ start_time = int(time.time())
+ while int(time.time()) - start_time < timeout:
+ try:
+ ports = ports_client.list_ports(
+ device_id=router_id,
+ fixed_ips=f"subnet_id={subnet_id}")['ports']
+ if len(ports) == 0:
+ return
+ time.sleep(interval)
+ except Exception:
+ pass
+ raise lib_exc.TimeoutException()
diff --git a/tempest/tests/lib/common/test_dynamic_creds.py b/tempest/tests/lib/common/test_dynamic_creds.py
index 4c2ea30..61cead2 100644
--- a/tempest/tests/lib/common/test_dynamic_creds.py
+++ b/tempest/tests/lib/common/test_dynamic_creds.py
@@ -750,6 +750,7 @@
router_interface_mock = self.patch(
'tempest.lib.services.network.routers_client.RoutersClient.'
'add_router_interface')
+ self.patch('tempest.lib.common.waiters.wait_router_interface_removed')
creds.get_primary_creds()
creds.get_project_admin_creds()
router_interface_mock.assert_called_once_with('1234', subnet_id='1234')