aboutsummaryrefslogtreecommitdiffstats
path: root/selftest
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-09-14 15:33:15 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-09-14 15:33:26 +0200
commita5c8ca121cf21cb049ea8ca0a3a2837b80a2c0e7 (patch)
tree110b8cc3a61b2b10d048b8112ae8e74981b9dd87 /selftest
parent7c965ed38aa5392748b6d48abd1c8798be0c7464 (diff)
resource: Handle lists correctly in item_matches
We want to handle lists in the same way as we handle them in combine(). Without this commit, reserve()->find() failed to match objects containing dictionaries inside lists correctly (such as trx configs). A few attributes are added to trx_list of some resources in suite_test/resources.conf to show a case in which resource reservation would fail without this patch. It failed because before this patch, dictionaries inside lists are compared to be equal instead of being compared element by element to see if one dictionary is a subset of the other one (for each element in the lists). Change-Id: I8588d5b788b9f74a9cc84b8bdcb049921788bb48
Diffstat (limited to 'selftest')
-rw-r--r--selftest/resource_test.ok6
-rwxr-xr-xselftest/resource_test.py23
-rw-r--r--selftest/suite_test.ok13
-rw-r--r--selftest/suite_test/resources.conf4
4 files changed, 41 insertions, 5 deletions
diff --git a/selftest/resource_test.ok b/selftest/resource_test.ok
index d366cf9..416e477 100644
--- a/selftest/resource_test.ok
+++ b/selftest/resource_test.ok
@@ -243,3 +243,9 @@ modem:
~~~ end: currently reserved
+- item_matches:
+1st subset matches correctly, pass
+2nd subset matches correctly, pass
+3rd subset should not match, pass
+3rd subset should not match, pass
+4th subset should not match, pass
diff --git a/selftest/resource_test.py b/selftest/resource_test.py
index a0ec490..fa1901d 100755
--- a/selftest/resource_test.py
+++ b/selftest/resource_test.py
@@ -94,4 +94,27 @@ with open(rrfile, 'r') as f:
print(f.read())
print('~~~ end: currently reserved\n')
+print('- item_matches:')
+superset = { 'hello': 'world', 'foo': 'bar', 'ordered_list': [{'xkey': 'xvalue'},{'ykey': 'yvalue'}], 'unordered_list_set': [1, 2, 3]}
+
+subset = { 'foo': 'bar', 'ordered_list': [{'xkey': 'xvalue'},{'ykey': 'yvalue'}], 'unordered_list_set': [2, 1] }
+if resource.item_matches(superset, subset):
+ print('1st subset matches correctly, pass')
+
+subset = { 'ordered_list': [{},{'ykey': 'yvalue'}], 'unordered_list_set': [] }
+if resource.item_matches(superset, subset):
+ print('2nd subset matches correctly, pass')
+
+subset = { 'ordered_list': [{'ykey': 'yvalue'}, {'xkey': 'xvalue'}] }
+if not resource.item_matches(superset, subset):
+ print('3rd subset should not match, pass')
+
+subset = { 'ordered_list': [{'xkey': 'xvalue'}, {'ykey': 'yvalue'}, {'zkey': 'zvalue'}] }
+if not resource.item_matches(superset, subset):
+ print('3rd subset should not match, pass')
+
+subset = { 'unordered_list_set': [4] }
+if not resource.item_matches(superset, subset):
+ print('4th subset should not match, pass')
+
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index 365fcaa..9c73588 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -240,24 +240,27 @@ tst test_suite: DBG: {combining='resources'} [suite.py:[LINENR]]
tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{}, {}, {}], ip_address=[{}], modem=[{}, {}]}} [test_suite↪{combining_scenarios='resources'}] [suite.py:[LINENR]]
tst {combining_scenarios='resources', scenario='foo'}: [RESOURCE_DICT]
tst test_suite: Reserving 3 x bts (candidates: 6) [resource.py:[LINENR]]
-tst test_suite: DBG: Picked - _hash: f1cab48db5b9004986e2030cb71730a5c55e823e
+tst test_suite: DBG: Picked - _hash: 89e45aaea42027162cc33f4389f055077338c82b
addr: 10.42.42.52
band: GSM-1800
ipa_unit_id: '6'
label: Ettus B200
launch_trx: 'True'
trx_list:
- - nominal_power: '10'
+ - max_power_red: '2'
+ nominal_power: '10'
- nominal_power: '12'
type: osmo-bts-trx
-- _hash: 1d00bd0d6643db5590cdbefff3152e70500abefc
+- _hash: 076ff06a4b719e61779492d3fb99f42a6635bb72
addr: 10.42.42.53
band: GSM-1800
ipa_unit_id: '7'
label: sysmoCell 5000
trx_list:
- - nominal_power: '10'
- - nominal_power: '12'
+ - max_power_red: '3'
+ nominal_power: '10'
+ - max_power_red: '0'
+ nominal_power: '12'
trx_remote_ip: 10.42.42.112
type: osmo-bts-trx
- _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
diff --git a/selftest/suite_test/resources.conf b/selftest/suite_test/resources.conf
index 001d286..440e55c 100644
--- a/selftest/suite_test/resources.conf
+++ b/selftest/suite_test/resources.conf
@@ -36,6 +36,7 @@ bts:
launch_trx: true
trx_list:
- nominal_power: 10
+ max_power_red: 2
- nominal_power: 12
- label: sysmoCell 5000
@@ -46,7 +47,9 @@ bts:
trx_remote_ip: 10.42.42.112
trx_list:
- nominal_power: 10
+ max_power_red: 3
- nominal_power: 12
+ max_power_red: 0
- label: sysmoCell 5000
type: osmo-bts-trx
@@ -57,6 +60,7 @@ bts:
trx_list:
- nominal_power: 10
- nominal_power: 12
+ max_power_red: 1
arfcn:
- arfcn: 512