Every unit test creates and registers every OpenStack action

That means around 1300 database inserts (or, attempted inserts, some seem to
fail) before every test. This is very slow. Only one of the tests
actually verifies the OpenStack actions are registered.

Recently I5ab01395c507fc857dca7cf08ab344a07def0dcf gave us a way to set
a different mapping file in the config. This change makes every test use
the much smaller test mapping file, rather than the default file.

Given that one test is checking specific actions being registered, these
were added to the test file to make that test pass. Once the OpenStack actions
are moved to mistral-extra this will improve again. The tempest tests
verify the actions load and tests a number of the OpenStack actions directly,
so our coverage of them isn't reduced.

From a brief test on my laptop, this reduces the unit test run time by
between 60 and 90 seconds.

Related-Bug: #1669511
Change-Id: Icc4ec5ef7d93d5ebb64f21c62d0bf7fc91e2f084
This commit is contained in:
Dougal Matthews 2017-03-03 07:36:03 +00:00
parent d89a2d1524
commit 4d1770004a
3 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,16 @@
{
"_comment": "Mapping OpenStack action namespaces to all its actions. Each action name is mapped to python-client method name in this namespace.",
"nova": {
"servers_get": "servers.get"
"servers_get": "servers.get",
"servers_find": "servers.find",
"volumes_delete_server_volume": "volumes.delete_server_volume"
},
"keystone": {
"users_list": "users.list",
"trusts_create": "trusts.create"
},
"glance": {
"images_list": "images.list",
"images_delete": "images.delete"
}
}

View File

@ -90,8 +90,9 @@ class GeneratorTest(base.BaseTest):
cls = MODULE_MAPPING.get(generator_cls.action_namespace)[1]
if cls == actions.NovaAction:
self.assertEqual(['nova.servers_get'], action_names)
else:
self.assertIn('nova.servers_get', action_names)
self.assertEqual(3, len(action_names))
elif cls not in (actions.GlanceAction, actions.KeystoneAction):
self.assertEqual([], action_names)
def test_absolute_mapping_path(self):
@ -105,8 +106,9 @@ class GeneratorTest(base.BaseTest):
cls = MODULE_MAPPING.get(generator_cls.action_namespace)[1]
if cls == actions.NovaAction:
self.assertEqual(['nova.servers_get'], action_names)
else:
self.assertIn('nova.servers_get', action_names)
self.assertEqual(3, len(action_names))
elif cls not in (actions.GlanceAction, actions.KeystoneAction):
self.assertEqual([], action_names)

View File

@ -240,6 +240,8 @@ class DbTestCase(BaseTest):
if cfg.CONF.database.connection.startswith('sqlite'):
cfg.CONF.set_default('connection', 'sqlite://', group='database')
cfg.CONF.set_default("openstack_actions_mapping_path",
"tests/resources/openstack/test_mapping.json")
cfg.CONF.set_default('max_overflow', -1, group='database')
cfg.CONF.set_default('max_pool_size', 1000, group='database')