Merge "Fix retry_bad_request() context manager"
This commit is contained in:
commit
614b326bde
|
@ -14,7 +14,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
import io
|
import io
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
@ -29,19 +28,7 @@ from tempest.lib import exceptions as lib_exc
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
BAD_REQUEST_RETRIES = 3
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
|
|
||||||
class ImportImagesTest(base.BaseV2ImageTest):
|
class ImportImagesTest(base.BaseV2ImageTest):
|
||||||
|
@ -837,9 +824,16 @@ class ImageLocationsTest(base.BaseV2ImageTest):
|
||||||
# HTTP, it will return BadRequest. Because this can be transient in
|
# 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
|
# CI, we try this a few times before we agree that it has failed
|
||||||
# for a reason worthy of failing the test.
|
# for a reason worthy of failing the test.
|
||||||
with retry_bad_request():
|
for i in range(BAD_REQUEST_RETRIES):
|
||||||
self.client.update_image(image['id'], [
|
try:
|
||||||
dict(add='/locations/-', value=new_loc)])
|
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
|
# The image should now be active, with one location that looks
|
||||||
# like we expect
|
# like we expect
|
||||||
|
@ -874,9 +868,16 @@ class ImageLocationsTest(base.BaseV2ImageTest):
|
||||||
# HTTP, it will return BadRequest. Because this can be transient in
|
# 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
|
# CI, we try this a few times before we agree that it has failed
|
||||||
# for a reason worthy of failing the test.
|
# for a reason worthy of failing the test.
|
||||||
with retry_bad_request():
|
for i in range(BAD_REQUEST_RETRIES):
|
||||||
self.client.update_image(image['id'], [
|
try:
|
||||||
dict(add='/locations/-', value=new_loc)])
|
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
|
# The image should now have two locations and the last one
|
||||||
# (locations are ordered) should have the new URL.
|
# (locations are ordered) should have the new URL.
|
||||||
|
|
|
@ -149,6 +149,8 @@
|
||||||
experimental:
|
experimental:
|
||||||
jobs:
|
jobs:
|
||||||
- nova-multi-cell
|
- nova-multi-cell
|
||||||
|
- nova-ceph-multistore:
|
||||||
|
irrelevant-files: *tempest-irrelevant-files
|
||||||
- tempest-with-latest-microversion
|
- tempest-with-latest-microversion
|
||||||
- tempest-stestr-master
|
- tempest-stestr-master
|
||||||
- tempest-cinder-v2-api:
|
- tempest-cinder-v2-api:
|
||||||
|
|
Loading…
Reference in New Issue