python3: iteration order of dict is unpredictable

In Python 3.3, hash randomization is enabled by default. It causes the
iteration order of dicts and sets to be unpredictable and differ
across Python runs.

Sort the metadata.keys() in reverse order to keep the test cases as is.

Change-Id: I233ada4dae4e9c0bc97bf8fd7d912a0eff9dd5b8
Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
Chuck Short 2013-10-13 09:01:51 -04:00
parent 0c2839414f
commit 68fe7735c0
2 changed files with 6 additions and 2 deletions
cinderclient

@ -352,7 +352,9 @@ def do_metadata(cs, args):
if args.action == 'set':
cs.volumes.set_metadata(volume, metadata)
elif args.action == 'unset':
cs.volumes.delete_metadata(volume, list(metadata))
# NOTE(zul): Make sure py2/py3 sorting is the same
cs.volumes.delete_metadata(volume, sorted(metadata.keys(),
reverse=True))
@utils.arg(

@ -390,7 +390,9 @@ def do_metadata(cs, args):
if args.action == 'set':
cs.volumes.set_metadata(volume, metadata)
elif args.action == 'unset':
cs.volumes.delete_metadata(volume, list(metadata))
# NOTE(zul): Make sure py2/py3 sorting is the same
cs.volumes.delete_metadata(volume, sorted(metadata.keys(),
reverse=True))
@utils.arg('--all-tenants',