summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-06-16 19:32:41 +0530
committerdhebeha <dhebeha.mj71@wipro.com>2020-06-16 21:09:11 +0530
commit53d9a763f4d0a29af77b43d0d1dd049d8389b9ce (patch)
treef641f4bbc1f6b1a3f75fa480e58622c6eb88cc8c
parent89f8707d8512e39ed8f44949dfdda224b9d89329 (diff)
remove candidate if threshold field doesn't match
Issue-ID: OPTFRA-777 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: Ib5a7c312ce2d23d22c36a25857c73fcec28199cd
-rw-r--r--conductor/conductor/solver/optimizer/constraints/threshold.py6
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json2
-rw-r--r--conductor/conductor/tests/unit/solver/optimizer/constraints/test_threshold.py13
3 files changed, 16 insertions, 5 deletions
diff --git a/conductor/conductor/solver/optimizer/constraints/threshold.py b/conductor/conductor/solver/optimizer/constraints/threshold.py
index 48ea2c7..57eeca7 100644
--- a/conductor/conductor/solver/optimizer/constraints/threshold.py
+++ b/conductor/conductor/solver/optimizer/constraints/threshold.py
@@ -48,10 +48,10 @@ class Threshold(constraint.Constraint):
operation = OPERATIONS.get(prop.get('operator'))
attribute_value = candidate.get(attribute)
- if not operation(attribute_value, threshold):
+ if not attribute_value or not operation(attribute_value, threshold):
conflict_list.append(candidate)
- continue
+ break
filtered_candidates = [c for c in _candidate_list if c not in conflict_list]
- return filtered_candidates
+ return filtered_candidates \ No newline at end of file
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
index 2be5561..28a4f8f 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
@@ -14,12 +14,12 @@
"area_traffic_cap_ul":null,
"inventory_provider":"aai",
"exp_data_rate_ul":100,
+ "exp_data_rate_dl":100,
"max_number_of_ues":0,
"ue_mobility_level":"stationary",
"candidate_type":"nssi",
"traffic_density":0,
"payload_size":0,
- "exp_data_rate_dl":100,
"jitter":0,
"survival_time":0,
"resource_sharing_level":"0",
diff --git a/conductor/conductor/tests/unit/solver/optimizer/constraints/test_threshold.py b/conductor/conductor/tests/unit/solver/optimizer/constraints/test_threshold.py
index 276701c..311e790 100644
--- a/conductor/conductor/tests/unit/solver/optimizer/constraints/test_threshold.py
+++ b/conductor/conductor/tests/unit/solver/optimizer/constraints/test_threshold.py
@@ -30,7 +30,7 @@ class TestThreshold(unittest.TestCase):
candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json'
candidates = json.loads(open(candidates_file).read())
-
+ # test 1
properties = {'evaluate':
[{'attribute': 'latency', 'threshold': 30, 'operator': 'lte'},
{'attribute': 'exp_data_rate_ul', 'threshold': 70, 'operator': 'gte'}]}
@@ -43,6 +43,7 @@ class TestThreshold(unittest.TestCase):
self.assertEqual(candidates, threshold_obj.solve(decision_path, candidates, None))
+ # test 2
properties = {'evaluate':
[{'attribute': 'latency', 'threshold': 10, 'operator': 'lte'},
{'attribute': 'exp_data_rate_ul', 'threshold': 120, 'operator': 'gte'}]}
@@ -52,6 +53,16 @@ class TestThreshold(unittest.TestCase):
self.assertEqual([], threshold_obj.solve(decision_path, candidates, None))
+ # test 3
+ properties = {'evaluate':
+ [{'attribute': 'latency', 'threshold': 10, 'operator': 'lte'},
+ {'attribute': 'area_traffic_cap', 'threshold': 120, 'operator': 'gte'}]}
+
+ threshold_obj = Threshold('urllc_threshold', 'threshold', ['URLLC'], _priority=0,
+ _properties=properties)
+
+ self.assertEqual([], threshold_obj.solve(decision_path, candidates, None))
+
if __name__ == "__main__":
unittest.main()