diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2013-05-14 09:09:36 +0100 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2013-05-14 09:09:36 +0100 |
| commit | 28f0b01717f17ecc545a25f6deb0aa240e5aaf0d (patch) | |
| tree | c82c1fbbf134ae59ab7f79bcc59940c40ee5468a | |
| parent | 25141fd36c4885fb2fa0590d15db9b8d563f1afb (diff) | |
| download | nova-28f0b01717f17ecc545a25f6deb0aa240e5aaf0d.tar.gz nova-28f0b01717f17ecc545a25f6deb0aa240e5aaf0d.tar.xz nova-28f0b01717f17ecc545a25f6deb0aa240e5aaf0d.zip | |
Fix response from snapshot create stub
A change from Oleg highlighted that the current snapshot create
stub is broken because it passes a full volume for the volume_id
paramter.
Fix the stub and the api_samples output, but also add unit test
checks which would have caught this.
Change-Id: Id006e3995c7696aa8f061a2b96123ea27e4b6d3f
Co-authored-by: Oleg Bondarev <obondarev@mirantis.com>
6 files changed, 10 insertions, 48 deletions
diff --git a/doc/api_samples/os-volumes/snapshot-create-resp.json b/doc/api_samples/os-volumes/snapshot-create-resp.json index 1a14bea01..a8dd57d84 100644 --- a/doc/api_samples/os-volumes/snapshot-create-resp.json +++ b/doc/api_samples/os-volumes/snapshot-create-resp.json @@ -6,27 +6,6 @@ "id": 100, "size": 100, "status": "available", - "volumeId": { - "attach_status": "attached", - "availability_zone": "fakeaz", - "created_at": "1999-01-01T01:01:01.000000", - "display_description": "displaydesc", - "display_name": "displayname", - "host": "fakehost", - "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c", - "instance_uuid": "fakeuuid", - "mountpoint": "/", - "name": "vol name", - "project_id": "fakeproject", - "size": 1, - "snapshot_id": null, - "status": "fakestatus", - "user_id": "fakeuser", - "volume_metadata": [], - "volume_type": { - "name": "vol_type_name" - }, - "volume_type_id": "fakevoltype" - } + "volumeId": "521752a6-acf6-4b2d-bc7a-119f9148cd8c" } }
\ No newline at end of file diff --git a/doc/api_samples/os-volumes/snapshot-create-resp.xml b/doc/api_samples/os-volumes/snapshot-create-resp.xml index ad815f723..654bf3d34 100644 --- a/doc/api_samples/os-volumes/snapshot-create-resp.xml +++ b/doc/api_samples/os-volumes/snapshot-create-resp.xml @@ -1,2 +1,2 @@ <?xml version='1.0' encoding='UTF-8'?> -<snapshot status="available" displayDescription="Daily backup" displayName="snap-001" volumeId="{'instance_uuid': 'fakeuuid', 'status': 'fakestatus', 'user_id': 'fakeuser', 'name': 'vol name', 'display_name': 'displayname', 'availability_zone': 'fakeaz', 'created_at': datetime.datetime(1999, 1, 1, 1, 1, 1), 'attach_status': 'attached', 'display_description': 'displaydesc', 'host': 'fakehost', 'volume_type_id': 'fakevoltype', 'volume_metadata': [], 'volume_type': {'name': 'vol_type_name'}, 'snapshot_id': None, 'mountpoint': '/', 'project_id': 'fakeproject', 'id': u'521752a6-acf6-4b2d-bc7a-119f9148cd8c', 'size': 1}" id="100" createdAt="2013-02-25 16:27:36.840121" size="100"/>
\ No newline at end of file +<snapshot status="available" displayDescription="Daily backup" displayName="snap-001" volumeId="521752a6-acf6-4b2d-bc7a-119f9148cd8c" id="100" createdAt="2013-02-25 16:27:36.840121" size="100"/>
\ No newline at end of file diff --git a/nova/tests/api/openstack/compute/contrib/test_snapshots.py b/nova/tests/api/openstack/compute/contrib/test_snapshots.py index a890abe6f..8e042adf8 100644 --- a/nova/tests/api/openstack/compute/contrib/test_snapshots.py +++ b/nova/tests/api/openstack/compute/contrib/test_snapshots.py @@ -67,6 +67,8 @@ class SnapshotApiTest(test.TestCase): snapshot['display_name']) self.assertEqual(resp_dict['snapshot']['displayDescription'], snapshot['display_description']) + self.assertEqual(resp_dict['snapshot']['volumeId'], + snapshot['volume_id']) def test_snapshot_create_force(self): snapshot = {"volume_id": 12, @@ -88,6 +90,8 @@ class SnapshotApiTest(test.TestCase): snapshot['display_name']) self.assertEqual(resp_dict['snapshot']['displayDescription'], snapshot['display_description']) + self.assertEqual(resp_dict['snapshot']['volumeId'], + snapshot['volume_id']) # Test invalid force paramter snapshot = {"volume_id": 12, diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index bf7c4d0d4..0b1ba5a6c 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -601,8 +601,8 @@ def stub_snapshot(id, **kwargs): return snapshot -def stub_snapshot_create(self, context, volume_id, name, description): - return stub_snapshot(100, volume_id=volume_id, display_name=name, +def stub_snapshot_create(self, context, volume, name, description): + return stub_snapshot(100, volume_id=volume['id'], display_name=name, display_description=description) diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl index 73cd02d9d..ddffd97a3 100644 --- a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl @@ -6,27 +6,6 @@ "id": 100, "size": 100, "status": "available", - "volumeId": { - "attach_status": "attached", - "availability_zone": "fakeaz", - "created_at": "%(timestamp)s", - "display_description": "displaydesc", - "display_name": "displayname", - "host": "fakehost", - "id": "%(uuid)s", - "instance_uuid": "fakeuuid", - "mountpoint": "/", - "name": "vol name", - "project_id": "fakeproject", - "size": 1, - "snapshot_id": null, - "status": "fakestatus", - "user_id": "fakeuser", - "volume_metadata": [], - "volume_type": { - "name": "vol_type_name" - }, - "volume_type_id": "fakevoltype" - } + "volumeId": "%(uuid)s" } } diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl index aa713311f..d75ae7ddd 100644 --- a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl @@ -1,2 +1,2 @@ <?xml version='1.0' encoding='UTF-8'?> -<snapshot status="available" displayDescription="%(description)s" displayName="%(snapshot_name)s" volumeId="{'instance_uuid': 'fakeuuid', 'status': 'fakestatus', 'user_id': 'fakeuser', 'name': 'vol name', 'display_name': 'displayname', 'availability_zone': 'fakeaz', 'created_at': datetime.datetime(1999, 1, 1, 1, 1, 1), 'attach_status': 'attached', 'display_description': 'displaydesc', 'host': 'fakehost', 'volume_type_id': 'fakevoltype', 'volume_metadata': [], 'volume_type': {'name': 'vol_type_name'}, 'snapshot_id': None, 'mountpoint': '/', 'project_id': 'fakeproject', 'id': u'521752a6-acf6-4b2d-bc7a-119f9148cd8c', 'size': 1}" id="100" createdAt="%(timestamp)s" size="100"/> +<snapshot status="available" displayDescription="%(description)s" displayName="%(snapshot_name)s" volumeId="521752a6-acf6-4b2d-bc7a-119f9148cd8c" id="100" createdAt="%(timestamp)s" size="100"/> |
