Ensure test_metaplugin handles random hashseeds

2 tests fail in test_metaplugin when using hashseed 2701526934 this is
down to the nature of using dictionaries and sets in Python having
unpredictable ordering when retrieving data stored in them. This patch
ensures that no matter the order fake1 and fake2 get placed into
self.plugins that the test can assert both possible scenarios.

Change-Id: I65fa6979cc0d6e3531e50f249c53db6be83a6cfe
Partial-Bug: 1348818
This commit is contained in:
Sam Betts 2014-10-20 13:26:33 +01:00
parent 5de1d2ed67
commit 706deaeaed
1 changed files with 14 additions and 1 deletions

View File

@ -306,7 +306,20 @@ class MetaNeutronPluginV2Test(testlib_api.SqlTestCase,
self.plugin.get_router(self.context, router_ret1['id'])
def test_extension_method(self):
self.assertEqual('fake1', self.plugin.fake_func())
"""Test if plugin methods are accessible from self.plugin
This test compensates for the nondeterministic ordering of
self.plugin's plugins dictionary. Fake Plugin 1 and Fake Plugin 2
both have a function called fake_func and the order of
self.plugin.plugins will determine which fake_func is called.
"""
fake1 = self.plugin.plugins.keys().index('fake1')
fake2 = self.plugin.plugins.keys().index('fake2')
fake1_before_fake2 = fake1 < fake2
fake_func_return = 'fake1' if fake1_before_fake2 else 'fake2'
self.assertEqual(fake_func_return, self.plugin.fake_func())
self.assertEqual('fake2', self.plugin.fake_func2())
def test_extension_not_implemented_method(self):