summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorPhilip Knouff <philip.knouff@mailtrust.com>2012-02-08 17:32:13 -0500
committerPhilip Knouff <philip.knouff@mailtrust.com>2012-02-09 12:56:04 -0500
commit6a823d0e1670507a6f4674d5f70e8d9ce0b4c3df (patch)
treecafe9d094f9beb85d216afb05b8334fd4e117dae /nova/tests
parentb8944efb1e2c87a9136f941eddaf90fc02b7fffb (diff)
Ensures that hostId's are unique
fixes bug #928015 Change-Id: I26e1e036ee56e0ee4344f9254df4c7024e0ceddf
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py
index 14f49684f..3510932c9 100644
--- a/nova/tests/api/openstack/compute/test_servers.py
+++ b/nova/tests/api/openstack/compute/test_servers.py
@@ -19,6 +19,7 @@
import datetime
import json
import urlparse
+import uuid
from lxml import etree
import webob
@@ -217,6 +218,27 @@ class ServersControllerTest(test.TestCase):
res_dict = self.controller.show(req, FAKE_UUID)
self.assertEqual(res_dict['server']['id'], FAKE_UUID)
+ def test_unique_host_id(self):
+ """Create two servers with the same host and different
+ project_ids and check that the hostId's are unique"""
+ def return_instance_with_host(self, *args):
+ project_id = str(uuid.uuid4())
+ return fakes.stub_instance(id=1, uuid=FAKE_UUID,
+ project_id=project_id,
+ host='fake_host')
+
+ self.stubs.Set(nova.db, 'instance_get_by_uuid',
+ return_instance_with_host)
+ self.stubs.Set(nova.db, 'instance_get',
+ return_instance_with_host)
+
+ req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % FAKE_UUID)
+ server1 = self.controller.show(req, FAKE_UUID)
+ server2 = self.controller.show(req, FAKE_UUID)
+
+ self.assertNotEqual(server1['server']['hostId'],
+ server2['server']['hostId'])
+
def test_get_server_by_id(self):
self.flags(use_ipv6=True)
image_bookmark = "http://localhost/fake/images/10"