Incorrect exception raised during create image , when invalid Image Metadata is passed

Bug #1005423 reported by Rohit Karajgi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Low
Prem Karat

Bug Description

Our tempest test that validates a return error code when an invalid key-value pair for metadata is passed during Create Image fails for the following scenarios.

1. Blank key-value metadata

Steps to reproduce:
1. Create a server
2. Create an image of the above server and pass invalid metadata key value pair, for ex:
meta = {'': ''}

Expected Return Code: 400 BadRequest
Actual Return Code: 404 Not Found

Besides, in this case the snapshot image is created but the operation stays in Queued state.

2. Metadata that exceeds length limit

Steps to reproduce:
1. Create a server
2. Create an image of the above server and pass invalid metadata key value pair, for ex:
meta = {'a' * 260: 'b' * 260}

Expected Return Code: 413 OverLimit
Actual Return Code: 404 Not Found

Return an error when creating image with invalid metadata ... FAIL
======================================================================
FAIL: Return an error when creating image with invalid metadata
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/stack/tempest/tests/test_images.py", line 276, in test_create_image_specify_invalid_metadata
    self.fail("Should raise 400 Bad Request if meta data is invalid")
AssertionError: Should raise 400 Bad Request if meta data is invalid
-------------------- >> begin captured logging << --------------------
tempest.config: INFO: Using tempest config file /opt/stack/tempest/etc/tempest.conf
tempest.common.rest_client: ERROR: Request URL: http://10.2.3.164:8774/v2/e5eb2e14ed8a409d9b36db3fddb5a757/images/9ea13f87-88ff-420c-8822-4d7ee7352d51
tempest.common.rest_client: ERROR: Request Body: None
tempest.common.rest_client: ERROR: Response Headers: {'date': 'Mon, 28 May 2012 07:21:44 GMT', 'status': '404', 'content-length': '62', 'content-type': 'application/json; charset=UTF-8', 'x-compute-request-id': 'req-921eda64-cfe2-43ff-a892-8fac1e9f9d67'}
tempest.common.rest_client: ERROR: Response Body: {"itemNotFound": {"message": "Image not found.", "code": 404}}
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------

Return an error when creating image with meta data over 256 chars ... FAIL

======================================================================
FAIL: Return an error when creating image with meta data over 256 chars
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/stack/tempest/tests/test_images.py", line 293, in test_create_image_specify_metadata_over_limits
    self.fail("Should raise 413 Over Limit if meta data was too long")
AssertionError: Should raise 413 Over Limit if meta data was too long
-------------------- >> begin captured logging << --------------------
tempest.config: INFO: Using tempest config file /opt/stack/tempest/etc/tempest.conf
tempest.common.rest_client: ERROR: Request URL: http://10.2.3.164:8774/v2/e5eb2e14ed8a409d9b36db3fddb5a757/images/9ea13f87-88ff-420c-8822-4d7ee7352d51
tempest.common.rest_client: ERROR: Request Body: None
tempest.common.rest_client: ERROR: Response Headers: {'date': 'Mon, 28 May 2012 13:11:13 GMT', 'status': '404', 'content-length': '62', 'content-type': 'application/json; charset=UTF-8', 'x-compute-request-id': 'req-4d383155-65f3-4eb3-8196-4adb91674853'}
tempest.common.rest_client: ERROR: Response Body: {"itemNotFound": {"message": "Image not found.", "code": 404}}
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------

Ran 2 test in 51.507s

FAILED (failures=2)

Tags: ntt tempest
Rohit Karajgi (rohitk)
description: updated
Revision history for this message
Brian Waldon (bcwaldon) wrote :

I would expect the first situation to pass with a 2XX code and the second to fail with a 400.

Changed in nova:
status: New → Triaged
importance: Undecided → Low
tags: added: tempest
Prem Karat (prem-karat)
Changed in nova:
assignee: nobody → Prem Karat (prem-karat)
Prem Karat (prem-karat)
Changed in nova:
status: Triaged → Fix Committed
Revision history for this message
Prem Karat (prem-karat) wrote :

This bug is fixed now and the tests pass.

Fix provided is in test_create_image_specify_metadata_over_limits(self):

         # Return an error when creating image with meta data over 256 chars
         snapshot_name = rand_name('test-snap-')
         meta = {'a' * 260: 'b' * 260}
- self.assertRaises(exceptions.OverLimit, self.client.create_image,
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
                           self.server['id'], snapshot_name, meta)

Expected Return Code: 413 OverLimit
Actual Return Code: 404 Not Found

Expected Return cod was OverLimit but it should be BadRequest.

All 3 test cases passes now. Fix submitted upstream

Change I87712288: Fix to enable negative test image_invalid_metadata

Change-Id: I877122880085d1fd69abe1d6d5b730701084c4a9
Owner Prem Karat
Project openstack/tempest
Branch master
Topic bug/1005423
Uploaded Apr 25, 2013 5:05 PM
Updated Apr 25, 2013 5:05 PM
Status Review in Progress

Fix to enable negative test image_invalid_metadata

Remove skips in test_images_oneserver

* Remove skip test_create_image_specify_invalid_metadata
* Fix assertRaises bug to match against exceptions.BadRequest instead
of exceptions.OverLimit which was causing this test case to fail.

Change-Id: I877122880085d1fd69abe1d6d5b730701084c4a9

Thierry Carrez (ttx)
affects: nova → tempest
Sean Dague (sdague)
Changed in tempest:
milestone: none → havana-1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.