Fix retry_bad_request() context manager
When I converted this from a decorator to a context manager, I didn't remove the fn parameter, nor was it even doing the thing I expected on the second and later iterations because it doesn't fail in my local environment. Apparently we're not running this test in the tempest gate, so this adds to experimental so we can at least run it on command. Change-Id: Ia72b50f7f7bf64fe0ddd3f1a415b1807ff264b66
This commit is contained in:
parent
829c42b485
commit
1ae54e331e
|
@ -14,7 +14,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import random
|
||||
import time
|
||||
|
@ -29,19 +28,7 @@ from tempest.lib import exceptions as lib_exc
|
|||
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def retry_bad_request(fn):
|
||||
retries = 3
|
||||
for i in range(retries):
|
||||
try:
|
||||
yield
|
||||
except lib_exc.BadRequest:
|
||||
if i < retries:
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise
|
||||
BAD_REQUEST_RETRIES = 3
|
||||
|
||||
|
||||
class ImportImagesTest(base.BaseV2ImageTest):
|
||||
|
@ -837,9 +824,16 @@ class ImageLocationsTest(base.BaseV2ImageTest):
|
|||
# HTTP, it will return BadRequest. Because this can be transient in
|
||||
# CI, we try this a few times before we agree that it has failed
|
||||
# for a reason worthy of failing the test.
|
||||
with retry_bad_request():
|
||||
self.client.update_image(image['id'], [
|
||||
dict(add='/locations/-', value=new_loc)])
|
||||
for i in range(BAD_REQUEST_RETRIES):
|
||||
try:
|
||||
self.client.update_image(image['id'], [
|
||||
dict(add='/locations/-', value=new_loc)])
|
||||
break
|
||||
except lib_exc.BadRequest:
|
||||
if i + 1 == BAD_REQUEST_RETRIES:
|
||||
raise
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
# The image should now be active, with one location that looks
|
||||
# like we expect
|
||||
|
@ -874,9 +868,16 @@ class ImageLocationsTest(base.BaseV2ImageTest):
|
|||
# HTTP, it will return BadRequest. Because this can be transient in
|
||||
# CI, we try this a few times before we agree that it has failed
|
||||
# for a reason worthy of failing the test.
|
||||
with retry_bad_request():
|
||||
self.client.update_image(image['id'], [
|
||||
dict(add='/locations/-', value=new_loc)])
|
||||
for i in range(BAD_REQUEST_RETRIES):
|
||||
try:
|
||||
self.client.update_image(image['id'], [
|
||||
dict(add='/locations/-', value=new_loc)])
|
||||
break
|
||||
except lib_exc.BadRequest:
|
||||
if i + 1 == BAD_REQUEST_RETRIES:
|
||||
raise
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
# The image should now have two locations and the last one
|
||||
# (locations are ordered) should have the new URL.
|
||||
|
|
|
@ -159,6 +159,8 @@
|
|||
experimental:
|
||||
jobs:
|
||||
- nova-multi-cell
|
||||
- nova-ceph-multistore:
|
||||
irrelevant-files: *tempest-irrelevant-files
|
||||
- tempest-with-latest-microversion
|
||||
- tempest-stestr-master
|
||||
- tempest-cinder-v2-api:
|
||||
|
|
Loading…
Reference in New Issue