diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-21 23:54:43 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-21 23:54:43 +0000 |
| commit | 962efab370f168bb077447eeb15d43063c8b2272 (patch) | |
| tree | fc163c29382456a0c7f2a13a0956d163170844e1 /nova | |
| parent | 0b48446631a4739572d7d89fe3cf7e0a944589e9 (diff) | |
| parent | ada550098ac874cdd3ca7c6637421edf6c7f7163 (diff) | |
| download | nova-962efab370f168bb077447eeb15d43063c8b2272.tar.gz nova-962efab370f168bb077447eeb15d43063c8b2272.tar.xz nova-962efab370f168bb077447eeb15d43063c8b2272.zip | |
Merge "Debugged extra_specs_ops.py"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/scheduler/filters/extra_specs_ops.py | 6 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 24 |
2 files changed, 28 insertions, 2 deletions
diff --git a/nova/scheduler/filters/extra_specs_ops.py b/nova/scheduler/filters/extra_specs_ops.py index 3720a2c9e..c77cd7b60 100644 --- a/nova/scheduler/filters/extra_specs_ops.py +++ b/nova/scheduler/filters/extra_specs_ops.py @@ -18,7 +18,7 @@ import operator # 1. The following operations are supported: # =, s==, s!=, s>=, s>, s<=, s<, <in>, <or>, ==, !=, >=, <= # 2. Note that <or> is handled in a different way below. -# 3. If the first word in the capability is not one of the operators, +# 3. If the first word in the extra_specs is not one of the operators, # it is ignored. _op_methods = {'=': lambda x, y: float(x) >= float(y), '<in>': lambda x, y: y in x, @@ -54,7 +54,9 @@ def match(value, req): return True if not words: break - op = words.pop(0) + op = words.pop(0) # remove a keyword <or> + if not words: + break return False if words and method(value, words[0]): diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index a25e9afae..5e42fed6f 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -688,24 +688,48 @@ class HostFiltersTestCase(test.TestCase): especs={'opt1': '<in> 12311321'}, passes=True) + def test_compute_filter_passes_extra_specs_with_op_in3(self): + self._do_test_compute_filter_extra_specs( + ecaps={'opt1': '12311321'}, + especs={'opt1': '<in> 12311321 <in>'}, + passes=True) + def test_compute_filter_fails_extra_specs_with_op_in(self): self._do_test_compute_filter_extra_specs( ecaps={'opt1': '12310321'}, especs={'opt1': '<in> 11'}, passes=False) + def test_compute_filter_fails_extra_specs_with_op_in2(self): + self._do_test_compute_filter_extra_specs( + ecaps={'opt1': '12310321'}, + especs={'opt1': '<in> 11 <in>'}, + passes=False) + def test_compute_filter_passes_extra_specs_with_op_or(self): self._do_test_compute_filter_extra_specs( ecaps={'opt1': '12'}, especs={'opt1': '<or> 11 <or> 12'}, passes=True) + def test_compute_filter_passes_extra_specs_with_op_or2(self): + self._do_test_compute_filter_extra_specs( + ecaps={'opt1': '12'}, + especs={'opt1': '<or> 11 <or> 12 <or>'}, + passes=True) + def test_compute_filter_fails_extra_specs_with_op_or(self): self._do_test_compute_filter_extra_specs( ecaps={'opt1': '13'}, especs={'opt1': '<or> 11 <or> 12'}, passes=False) + def test_compute_filter_fails_extra_specs_with_op_or2(self): + self._do_test_compute_filter_extra_specs( + ecaps={'opt1': '13'}, + especs={'opt1': '<or> 11 <or> 12 <or>'}, + passes=False) + def test_compute_filter_passes_extra_specs_with_op_le(self): self._do_test_compute_filter_extra_specs( ecaps={'opt1': 2, 'opt2': 2}, |
