Skip to content

Commit 9cddbf8

Browse files
committed
Fix test errors
1 parent 3198d3c commit 9cddbf8

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

otcextensions/sdk/rds/v3/_base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,19 @@ def find(cls, session, name_or_id, ignore_missing=True, **params):
151151
"No %s found for %s" % (cls.__name__, name_or_id)
152152
)
153153

154-
def delete(self, session, error_message=None):
154+
def delete(self, session, error_message=None, **params):
155+
"""Delete the remote resource based on this instance.
155156
156-
response = self._raw_delete(session)
157+
:param session: The session to use for making this request.
158+
:type session: :class:`~keystoneauth1.adapter.Adapter`
159+
:param dict params: Additional arguments (e.g. ``params``,
160+
``microversion``, ``base_path``) as passed down by the calling
161+
:class:`~openstack.proxy.Proxy`. Their exact set differs between
162+
openstacksdk releases, so they are accepted generically and
163+
forwarded as-is to ``_raw_delete``.
164+
"""
165+
166+
response = self._raw_delete(session, **params)
157167
kwargs = {}
158168
if error_message:
159169
kwargs["error_message"] = error_message

otcextensions/tests/functional/privatenat.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,33 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
import time
1314
import uuid
1415

1516
from openstack import exceptions as sdk_exceptions
1617
from openstack import resource
1718

1819

1920
class PrivateNatEnvironmentMixin(object):
21+
def _wait_for_subnet_active(self, subnet, timeout=60, retries=3):
22+
"""Wait for a VPC subnet to become ACTIVE.
23+
24+
The OTC VPC subnet API is occasionally read-after-write
25+
inconsistent: a GET right after creation can 404 even though a
26+
previous GET already returned the resource. Retry the wait a
27+
few times before giving up so such transient 404s don't fail
28+
the test.
29+
"""
30+
for attempt in range(retries):
31+
try:
32+
return resource.wait_for_status(
33+
self.conn.vpc, subnet, "ACTIVE", None, 2, timeout
34+
)
35+
except sdk_exceptions.ResourceNotFound:
36+
if attempt == retries - 1:
37+
raise
38+
time.sleep(2)
39+
2040
def _delete_private_transit_ip(self, transit_ip_id):
2141
self.conn.natv3.delete_private_transit_ip(transit_ip_id, ignore_missing=True)
2242

@@ -43,7 +63,7 @@ def _create_private_nat_subnet(self, vpc, prefix, suffix):
4363
gateway_ip=gw[:-2] + ".1",
4464
dns_list=["100.125.4.25", "100.125.129.199"],
4565
)
46-
resource.wait_for_status(self.conn.vpc, subnet, "ACTIVE", None, 2, 60)
66+
self._wait_for_subnet_active(subnet)
4767
return subnet
4868

4969
def _delete_private_nat_subnet(self, subnet):
@@ -52,7 +72,7 @@ def _delete_private_nat_subnet(self, subnet):
5272
except sdk_exceptions.ResourceNotFound:
5373
return
5474

55-
resource.wait_for_status(self.conn.vpc, subnet, "ACTIVE", None, 2, 60)
75+
self._wait_for_subnet_active(subnet)
5676
self.conn.vpc.delete_subnet(subnet, ignore_missing=True)
5777
resource.wait_for_delete(self.conn.vpc, subnet, 2, 120)
5878

0 commit comments

Comments
 (0)