diff options
author | Avishay Traeger <avishay@il.ibm.com> | 2013-03-06 12:21:31 +0200 |
---|---|---|
committer | Avishay Traeger <avishay@il.ibm.com> | 2013-03-07 18:25:08 +0200 |
commit | 2e8b5e8446432542901b3c814670a4c67e629137 (patch) | |
tree | f2ba2b1ca36f18eeeba9301c151a3270e65ac906 /tests/unit/scheduler/test_host_filters.py | |
parent | 2cb8e4557b05f92fbd9f56b7a6a6d4f35c8a883a (diff) | |
download | oslo-2e8b5e8446432542901b3c814670a4c67e629137.tar.gz oslo-2e8b5e8446432542901b3c814670a4c67e629137.tar.xz oslo-2e8b5e8446432542901b3c814670a4c67e629137.zip |
Add 'is' operator to extra specs ops.
Boolean values for capabilities don't work because extra_specs are
all converted to unicode. The scheduler will then check, for example,
if the boolean 'True' is equal to the unicode string 'True', and will
always return False. This patch allows admins to specify '<is> True'
in extra_specs, which will compare successfully to boolean True.
Fixes bug: 1146306
Change-Id: Id0e6dcfb71eb0943a16bba551ec23c4d57206550
Diffstat (limited to 'tests/unit/scheduler/test_host_filters.py')
-rw-r--r-- | tests/unit/scheduler/test_host_filters.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/scheduler/test_host_filters.py b/tests/unit/scheduler/test_host_filters.py index 7d3a0e4..566a9fb 100644 --- a/tests/unit/scheduler/test_host_filters.py +++ b/tests/unit/scheduler/test_host_filters.py @@ -169,6 +169,36 @@ class ExtraSpecsOpsTestCase(utils.BaseTestCase): req='<in> 11 <in>', matches=False) + def test_extra_specs_matches_with_op_is(self): + self._do_extra_specs_ops_test( + value=True, + req='<is> True', + matches=True) + + def test_extra_specs_matches_with_op_is2(self): + self._do_extra_specs_ops_test( + value=False, + req='<is> False', + matches=True) + + def test_extra_specs_matches_with_op_is3(self): + self._do_extra_specs_ops_test( + value=False, + req='<is> Nonsense', + matches=True) + + def test_extra_specs_fails_with_op_is(self): + self._do_extra_specs_ops_test( + value=True, + req='<is> False', + matches=False) + + def test_extra_specs_fails_with_op_is2(self): + self._do_extra_specs_ops_test( + value=False, + req='<is> True', + matches=False) + def test_extra_specs_matches_with_op_or(self): self._do_extra_specs_ops_test( value='12', |