Remove hash seed dependency for unittests

latest tox has random hash seed enabled, that causes
unstable unittests errors.

Change-Id: I0e24304ca045c5347aa9fd97ee28ac3be774fa31
Closes-Bug: #1359982
This commit is contained in:
Valeriy Ponomaryov 2014-08-27 07:34:45 -04:00 committed by vponomaryov
parent d1c5da5e94
commit e089a1bc6f
7 changed files with 45 additions and 20 deletions

View File

@ -394,8 +394,8 @@ class IpNetnsCommand(IpCommandBase):
else: else:
env_params = [] env_params = []
if addl_env: if addl_env:
env_params = (['env'] + env_params = (['env'] + ['%s=%s' % pair
['%s=%s' % pair for pair in addl_env.items()]) for pair in sorted(addl_env.items())])
total_cmd = (['ip', 'netns', 'exec', self._parent.namespace] + total_cmd = (['ip', 'netns', 'exec', self._parent.namespace] +
env_params + list(cmds)) env_params + list(cmds))
return utils.execute(*total_cmd, run_as_root=True, return utils.execute(*total_cmd, run_as_root=True,

View File

@ -336,8 +336,8 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
return return
if export_dir_dict: if export_dir_dict:
export_dir_new = ",".join("/%s(%s)" % (d, "|".join(v)) export_dir_new = (",".join("/%s(%s)" % (d, "|".join(v))
for d, v in export_dir_dict.items()) for d, v in sorted(export_dir_dict.items())))
args, kw = self.gluster_address.make_gluster_args( args, kw = self.gluster_address.make_gluster_args(
'volume', 'set', self.gluster_address.volume, 'volume', 'set', self.gluster_address.volume,
NFS_EXPORT_DIR, export_dir_new) NFS_EXPORT_DIR, export_dir_new)

View File

@ -162,10 +162,10 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
except naapi.NaApiError as e: except naapi.NaApiError as e:
LOG.error(_("Could not get licenses list. %s.") % e) LOG.error(_("Could not get licenses list. %s.") % e)
else: else:
self._licenses = [ self._licenses = sorted([
l.get_child_content('package').lower() l.get_child_content('package').lower()
for l in licenses.get_child_by_name('licenses').get_children() for l in licenses.get_child_by_name('licenses').get_children()
] ])
log_data = { log_data = {
'backend': self.backend_name, 'backend': self.backend_name,
'licenses': ', '.join(self._licenses), 'licenses': ', '.join(self._licenses),

View File

@ -173,16 +173,24 @@ class FaultsXMLSerializationTestV11(test.TestCase):
} }
output = serializer.serialize(fixture) output = serializer.serialize(fixture)
actual = minidom.parseString(self._prepare_xml(output)) result = minidom.parseString(self._prepare_xml(output))
expected = minidom.parseString(self._prepare_xml(""" # result has 1 child - overLimit
<overLimit code="413" xmlns="%s"> self.assertEqual(result.firstChild, result.lastChild)
<message>sorry</message> self.assertEqual(result.firstChild.tagName, 'overLimit')
<retryAfter>4</retryAfter>
</overLimit>
""") % common.XML_NS_V1)
self.assertEqual(expected.toxml(), actual.toxml()) # overLimit has attrs code = '413' and xmlns = common.XML_NS_V1
self.assertEqual(result.firstChild.getAttribute('code'), '413')
self.assertEqual(result.firstChild.getAttribute('xmlns'),
common.XML_NS_V1)
# overLimit has childs message = 'sorry' and retryAfter = '4'
message = result.firstChild.getElementsByTagName('message')
retry_after = result.firstChild.getElementsByTagName('retryAfter')
self.assertEqual(len(message), 1)
self.assertEqual(len(retry_after), 1)
self.assertEqual(message[0].toxml(), '<message>sorry</message>')
self.assertEqual(retry_after[0].toxml(), '<retryAfter>4</retryAfter>')
def test_404_fault(self): def test_404_fault(self):
metadata = {'attributes': {"itemNotFound": 'code'}} metadata = {'attributes': {"itemNotFound": 'code'}}

View File

@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from xml.dom import minidom
from lxml import etree from lxml import etree
from manila.api import xmlutil from manila.api import xmlutil
@ -689,9 +691,26 @@ class TemplateBuilderTest(test.TestCase):
class MiscellaneousXMLUtilTests(test.TestCase): class MiscellaneousXMLUtilTests(test.TestCase):
def test_make_flat_dict(self): def test_make_flat_dict(self):
expected_xml = ("<?xml version='1.0' encoding='UTF-8'?>\n" expected = minidom.parseString(
'<wrapper><a>foo</a><b>bar</b></wrapper>') "<?xml version='1.0' encoding='UTF-8'?>"
"<wrapper><a>foo</a><b>bar</b></wrapper>"
)
root = xmlutil.make_flat_dict('wrapper') root = xmlutil.make_flat_dict('wrapper')
tmpl = xmlutil.MasterTemplate(root, 1) tmpl = xmlutil.MasterTemplate(root, 1)
result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar'))) result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar')))
self.assertEqual(result, expected_xml) actual = minidom.parseString(result)
self.assertEqual(expected.firstChild.tagName,
actual.firstChild.tagName)
expected_child_a = expected.firstChild.getElementsByTagName('a')
expected_child_b = expected.firstChild.getElementsByTagName('b')
actual_child_a = actual.firstChild.getElementsByTagName('a')
actual_child_b = actual.firstChild.getElementsByTagName('b')
self.assertEqual(len(expected_child_a), 1)
self.assertEqual(len(expected_child_b), 1)
self.assertEqual(len(actual_child_a), 1)
self.assertEqual(len(actual_child_b), 1)
self.assertEqual(expected_child_a[0].toxml(),
actual_child_a[0].toxml())
self.assertEqual(expected_child_b[0].toxml(),
actual_child_b[0].toxml())

View File

@ -665,7 +665,7 @@ class TestIpNetnsCommand(TestIPCmdBase):
env = dict(FOO=1, BAR=2) env = dict(FOO=1, BAR=2)
self.netns_cmd.execute(['ip', 'link', 'list'], env) self.netns_cmd.execute(['ip', 'link', 'list'], env)
execute.assert_called_once_with( execute.assert_called_once_with(
'ip', 'netns', 'exec', 'ns', 'env', 'FOO=1', 'BAR=2', 'ip', 'netns', 'exec', 'ns', 'env', 'BAR=2', 'FOO=1',
'ip', 'link', 'list', 'ip', 'link', 'list',
run_as_root=True, check_exit_code=True) run_as_root=True, check_exit_code=True)

View File

@ -5,8 +5,6 @@ envlist = py26,py27,pep8
[testenv] [testenv]
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
# NOTE (viktors): Workaround for bug 1359982
PYTHONHASHSEED=0
usedevelop = True usedevelop = True
install_command = pip install {opts} {packages} install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt