Merge "Added fix to 'test_delete_saving_image' testcase"

This commit is contained in:
Zuul 2020-02-28 08:01:38 +00:00 committed by Gerrit Code Review
commit 7dae461504
1 changed files with 20 additions and 7 deletions

View File

@ -12,12 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import testtools
from tempest.api.compute import base
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
import testtools
from tempest.lib import exceptions as lib_exceptions
CONF = config.CONF
@ -51,12 +53,23 @@ class ImagesTestJSON(base.BaseV2ComputeTest):
# in task_state image_snapshot
self.addCleanup(waiters.wait_for_server_status, self.servers_client,
server['id'], 'ACTIVE')
image = self.create_image_from_server(server['id'],
wait_until='SAVING')
self.client.delete_image(image['id'])
msg = ('The image with ID {image_id} failed to be deleted'
.format(image_id=image['id']))
self.assertTrue(self.client.is_resource_deleted(image['id']), msg)
snapshot_name = data_utils.rand_name('test-snap')
try:
image = self.create_image_from_server(server['id'],
name=snapshot_name,
wait_until='SAVING')
self.client.delete_image(image['id'])
msg = ('The image with ID {image_id} failed to be deleted'
.format(image_id=image['id']))
self.assertTrue(self.client.is_resource_deleted(image['id']),
msg)
self.assertEqual(snapshot_name, image['name'])
except lib_exceptions.TimeoutException as ex:
# If timeout is reached, we don't need to check state,
# since, it wouldn't be a 'SAVING' state atleast and apart from
# it, this testcase doesn't have scope for other state transition
# Hence, skip the test.
raise self.skipException("This test is skipped because " + str(ex))
@decorators.idempotent_id('aaacd1d0-55a2-4ce8-818a-b5439df8adc9')
def test_create_image_from_stopped_server(self):