summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-04 18:43:57 +0000
committerGerrit Code Review <review@openstack.org>2013-06-04 18:43:57 +0000
commitaae7b7a7ec3701e2cc7a9a1fa726ba0e14520f74 (patch)
treeebc0ed88816916c324f6e8f2331ff8919cb44fd9 /nova/tests
parent22604a972fb8369d5e826b9034e72d1478c1e7ae (diff)
parent1b7f77f22d847803a24b66a9f6c08dc4a564bddb (diff)
Merge "Fix postgresql failures related to Data type"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_fixed_ips.py19
-rw-r--r--nova/tests/test_db_api.py54
2 files changed, 71 insertions, 2 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_fixed_ips.py b/nova/tests/api/openstack/compute/contrib/test_fixed_ips.py
index 67417e60e..2f9f6c5bc 100644
--- a/nova/tests/api/openstack/compute/contrib/test_fixed_ips.py
+++ b/nova/tests/api/openstack/compute/contrib/test_fixed_ips.py
@@ -132,6 +132,11 @@ class FixedIpTest(test.TestCase):
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req,
'10.0.0.1')
+ def test_fixed_ips_get_invalid_ip_address(self):
+ req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/inv.ali.d.ip')
+ self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req,
+ 'inv.ali.d.ip')
+
def test_fixed_ips_get_deleted_ip_fail(self):
req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/10.0.0.2')
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req,
@@ -154,6 +159,13 @@ class FixedIpTest(test.TestCase):
self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req,
'10.0.0.1', body)
+ def test_fixed_ip_reserve_invalid_ip_address(self):
+ body = {'reserve': None}
+ req = fakes.HTTPRequest.blank(
+ '/v2/fake/os-fixed-ips/inv.ali.d.ip/action')
+ self.assertRaises(webob.exc.HTTPNotFound,
+ self.controller.action, req, 'inv.ali.d.ip', body)
+
def test_fixed_ip_reserve_deleted_ip(self):
body = {'reserve': None}
req = fakes.HTTPRequest.blank(
@@ -178,6 +190,13 @@ class FixedIpTest(test.TestCase):
self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req,
'10.0.0.1', body)
+ def test_fixed_ip_unreserve_invalid_ip_address(self):
+ body = {'unreserve': None}
+ req = fakes.HTTPRequest.blank(
+ '/v2/fake/os-fixed-ips/inv.ali.d.ip/action')
+ self.assertRaises(webob.exc.HTTPNotFound,
+ self.controller.action, req, 'inv.ali.d.ip', body)
+
def test_fixed_ip_unreserve_deleted_ip(self):
body = {'unreserve': None}
req = fakes.HTTPRequest.blank(
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index ca542790c..efe243d1b 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -27,8 +27,10 @@ import uuid as stdlib_uuid
import mox
from oslo.config import cfg
from sqlalchemy.dialects import sqlite
+from sqlalchemy import exc
from sqlalchemy.exc import IntegrityError
from sqlalchemy import MetaData
+from sqlalchemy.orm import query
from sqlalchemy.sql.expression import select
from nova.compute import vm_states
@@ -2782,6 +2784,13 @@ class FixedIPTestCase(BaseInstanceTypeTestCase):
network_id=None,
updated_at=new))
+ def mock_db_query_first_to_raise_data_error_exception(self):
+ self.mox.StubOutWithMock(query.Query, 'first')
+ query.Query.first().AndRaise(exc.DataError(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg()))
+ self.mox.ReplayAll()
+
def test_fixed_ip_disassociate_all_by_timeout_single_host(self):
now = timeutils.utcnow()
self._timeout_test(self.ctxt, now, False)
@@ -3118,7 +3127,7 @@ class FixedIPTestCase(BaseInstanceTypeTestCase):
self.assertRaises(exception.FixedIpNotFound,
db.fixed_ip_get, self.ctxt, 0)
- def test_fixed_ip_get_sucsess2(self):
+ def test_fixed_ip_get_success2(self):
adress = 'fixed_ip_adress'
instance_uuid = self._create_instance()
network_id = db.network_create_safe(self.ctxt, {})['id']
@@ -3139,7 +3148,7 @@ class FixedIPTestCase(BaseInstanceTypeTestCase):
self.assertRaises(exception.NotAuthorized, db.fixed_ip_get,
self.ctxt, fixed_ip_id)
- def test_fixed_ip_get_sucsess(self):
+ def test_fixed_ip_get_success(self):
adress = 'fixed_ip_adress'
instance_uuid = self._create_instance()
network_id = db.network_create_safe(self.ctxt, {})['id']
@@ -3165,6 +3174,11 @@ class FixedIPTestCase(BaseInstanceTypeTestCase):
self.assertRaises(exception.FixedIpNotFoundForAddress,
db.fixed_ip_get_by_address_detailed, self.ctxt, 'x')
+ def test_fixed_ip_get_by_address_with_data_error_exception(self):
+ self.mock_db_query_first_to_raise_data_error_exception()
+ self.assertRaises(exception.FixedIpInvalid,
+ db.fixed_ip_get_by_address_detailed, self.ctxt, 'x')
+
def test_fixed_ip_get_by_address_detailed_sucsess(self):
adress = 'fixed_ip_adress_123'
instance_uuid = self._create_instance()
@@ -3246,6 +3260,13 @@ class FloatingIpTestCase(test.TestCase, ModelsObjectComparatorMixin):
'interface': 'fake_interface',
}
+ def mock_db_query_first_to_raise_data_error_exception(self):
+ self.mox.StubOutWithMock(query.Query, 'first')
+ query.Query.first().AndRaise(exc.DataError(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg()))
+ self.mox.ReplayAll()
+
def _create_floating_ip(self, values):
if not values:
values = {}
@@ -3266,6 +3287,11 @@ class FloatingIpTestCase(test.TestCase, ModelsObjectComparatorMixin):
self.assertRaises(exception.FloatingIpNotFound,
db.floating_ip_get, self.ctxt, 100500)
+ def test_floating_ip_get_with_long_id_not_found(self):
+ self.mock_db_query_first_to_raise_data_error_exception()
+ self.assertRaises(exception.InvalidID,
+ db.floating_ip_get, self.ctxt, 123456789101112)
+
def test_floating_ip_get_pools(self):
values = [
{'address': '0.0.0.0', 'pool': 'abc'},
@@ -3571,6 +3597,12 @@ class FloatingIpTestCase(test.TestCase, ModelsObjectComparatorMixin):
db.floating_ip_get_by_address,
self.ctxt, 'non_exists_host')
+ def test_floating_ip_get_by_invalid_address(self):
+ self.mock_db_query_first_to_raise_data_error_exception()
+ self.assertRaises(exception.InvalidIpAddressError,
+ db.floating_ip_get_by_address,
+ self.ctxt, 'non_exists_host')
+
def test_floating_ip_get_by_fixed_address(self):
fixed_float = [
('1.1.1.1', '2.2.2.1'),
@@ -4186,6 +4218,13 @@ class VirtualInterfaceTestCase(test.TestCase, ModelsObjectComparatorMixin):
'uuid': str(stdlib_uuid.uuid4())
}
+ def mock_db_query_first_to_raise_data_error_exception(self):
+ self.mox.StubOutWithMock(query.Query, 'first')
+ query.Query.first().AndRaise(exc.DataError(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg()))
+ self.mox.ReplayAll()
+
def _create_virt_interface(self, values):
v = self._get_base_values()
v.update(values)
@@ -4222,6 +4261,17 @@ class VirtualInterfaceTestCase(test.TestCase, ModelsObjectComparatorMixin):
vif['address'])
self._assertEqualObjects(vif, real_vif)
+ def test_virtual_interface_get_by_address_not_found(self):
+ self.assertIsNone(db.virtual_interface_get_by_address(self.ctxt,
+ "i.nv.ali.ip"))
+
+ def test_virtual_interface_get_by_address_data_error_exception(self):
+ self.mock_db_query_first_to_raise_data_error_exception()
+ self.assertRaises(exception.InvalidIpAddressError,
+ db.virtual_interface_get_by_address,
+ self.ctxt,
+ "i.nv.ali.ip")
+
def test_virtual_interface_get_by_uuid(self):
vifs = [self._create_virt_interface({}),
self._create_virt_interface({})]