Skip to content

Commit 0960980

Browse files
authored
[Release-3.14][E2E Test] Prevent the bad IndexError when build image fails (#7171)
When build image fails, the image_list is empty but the code directly accesses image_list[0], causing IndexError that masks the real error. Add safety check to only access list elements when list is not empty.
1 parent 4bea369 commit 0960980

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/integration-tests/tests/createami/test_createami.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,11 @@ def _test_image_tag_and_volume(image):
421421
logging.info(f"Image List: {image_list}, length {len(image_list)}")
422422
assert_that(len(image_list)).is_equal_to(1)
423423

424-
created_image = image_list[0]
425-
volume_size = created_image.get("BlockDeviceMappings")[0].get("Ebs").get("VolumeSize")
426-
assert_that(volume_size).is_equal_to(200)
427-
assert_that(created_image["Tags"]).contains({"Key": "dummyImageTag", "Value": "dummyImageTag"})
424+
if len(image_list) > 0:
425+
created_image = image_list[0]
426+
volume_size = created_image.get("BlockDeviceMappings")[0].get("Ebs").get("VolumeSize")
427+
assert_that(volume_size).is_equal_to(200)
428+
assert_that(created_image["Tags"]).contains({"Key": "dummyImageTag", "Value": "dummyImageTag"})
428429

429430

430431
@pytest.fixture()

0 commit comments

Comments
 (0)