From b17d060638d1a576f003fd4636d61d91eae10e6d Mon Sep 17 00:00:00 2001 From: jichenjc Date: Mon, 27 Oct 2014 19:20:47 +0800 Subject: [PATCH] Make unit test floating ips bulk faster The unit test is only used to test whether the code branch is executed with pre-defined logic, so it does make sense to create as less as dataset if we can achieve that goal. Currently the unit test for floating ip bulk operation in nova create a rather a big data set to run the test. This patch adjust it with smaller one. the results shows (ignore the first one because env setup) [former] [current] test_create_bad_cidr_fail OK 4.27 8.30 test_create_duplicate_fail OK 8.01 1.20 test_create_invalid_cidr_fail OK 0.10 0.14 test_create_ips OK 0.77 0.18 test_create_ips_pool OK 7.65 0.17 test_delete_ips OK 10.01 0.35 test_list_ip_by_host OK 0.14 0.27 test_list_ips OK 0.15 0.25 Change-Id: I2ee5b5186f0c88b80ed20a0dbc16af9360e28332 --- .../compute/contrib/test_floating_ips_bulk.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_floating_ips_bulk.py b/nova/tests/unit/api/openstack/compute/contrib/test_floating_ips_bulk.py index 8c81d99ab0bd..cb08b2557439 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_floating_ips_bulk.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_floating_ips_bulk.py @@ -51,11 +51,11 @@ class FloatingIPBulkV21(test.TestCase): self.assertEqual(res_dict, response) def test_create_ips(self): - ip_range = '192.168.1.0/24' + ip_range = '192.168.1.0/28' self._setup_floating_ips(ip_range) def test_create_ips_pool(self): - ip_range = '10.0.1.0/20' + ip_range = '10.0.1.0/29' pool = 'a new pool' body = {'floating_ips_bulk_create': {'ip_range': ip_range, @@ -92,7 +92,7 @@ class FloatingIPBulkV21(test.TestCase): self.controller.show, req, 'host') def test_delete_ips(self): - ip_range = '192.168.1.0/20' + ip_range = '192.168.1.0/29' self._setup_floating_ips(ip_range) body = {'ip_range': ip_range} @@ -109,10 +109,10 @@ class FloatingIPBulkV21(test.TestCase): self.assertEqual(res_dict, response) def test_create_duplicate_fail(self): - ip_range = '192.168.1.0/20' + ip_range = '192.168.1.0/30' self._setup_floating_ips(ip_range) - ip_range = '192.168.1.0/28' + ip_range = '192.168.1.0/29' body = {'floating_ips_bulk_create': {'ip_range': ip_range}} req = fakes.HTTPRequest.blank(self.url) self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,