[PATCH] osmo-gsm-tester[master]: Convert scenarios to restrict all objects of a given type

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Sep 11 10:46:12 UTC 2017


Review at  https://gerrit.osmocom.org/3907

Convert scenarios to restrict all objects of a given type

Before this commit, scenarios follow the same structure as suite.conf
files:
resources: { bts: [{attrX: valX}, {attrY: valY}] }

This was meant to match objects 1-to-1 with the ones appearing in the
suite.conf. However, after discussions it was decided that what we
actually prefer for scenarios (being more convinient) is to define
a restriction we want to apply to all objects of a given type.
Otherwise, the scenario cannot be generic and needs to have knowledge on
the suite.conf details (such as amount of BTS used), and
apply restrictions for each of them.

Thus, structure of scenarios config file is change to the following:
resource: { bts: {attrX: valX} }
Then, in suite.py:combined(), we apply the dictionary "bts" for each
object of type "bts" required in suite.conf.

A unit test is added to confirm it works as expected.

During creation of this patch, it was observed that suite.conf uses a
different schema (WANT_SCHEMA), which restricts attributes which can be
specified in suite.conf. It may be useful to extend that in the future
to let suite.conf contain more attributes (as in resources.conf or
scenarios), because it may be desirable to specify already in the
suite.conf some restriction which will always need to be enforced for a
given suite to work properly. This is left for future work as for now
this can be workarouned by applying a scenario.

Change-Id: I25eb639c7e3cf3b4c67a205422808bffbdd791e6
---
M example/scenarios/sysmo.conf
M example/scenarios/trx-b200.conf
M example/scenarios/trx-sysmocell5000.conf
M example/scenarios/trx.conf
M selftest/suite_test.ok
M selftest/suite_test.py
M selftest/suite_test/resources.conf
M selftest/suite_test/test_suite/suite.conf
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/suite.py
10 files changed, 146 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/07/3907/1

diff --git a/example/scenarios/sysmo.conf b/example/scenarios/sysmo.conf
index 624758b..2fff726 100644
--- a/example/scenarios/sysmo.conf
+++ b/example/scenarios/sysmo.conf
@@ -1,3 +1,3 @@
 resources:
   bts:
-  - type: osmo-bts-sysmo
+    type: osmo-bts-sysmo
diff --git a/example/scenarios/trx-b200.conf b/example/scenarios/trx-b200.conf
index 2bad7e8..f57eada 100644
--- a/example/scenarios/trx-b200.conf
+++ b/example/scenarios/trx-b200.conf
@@ -1,4 +1,4 @@
 resources:
   bts:
-  - label: Ettus B200
+    label: Ettus B200
     type: osmo-bts-trx
diff --git a/example/scenarios/trx-sysmocell5000.conf b/example/scenarios/trx-sysmocell5000.conf
index 62e9a3c..30e4ed7 100644
--- a/example/scenarios/trx-sysmocell5000.conf
+++ b/example/scenarios/trx-sysmocell5000.conf
@@ -1,4 +1,4 @@
 resources:
   bts:
-  - label: sysmoCell 5000
+    label: sysmoCell 5000
     type: osmo-bts-trx
diff --git a/example/scenarios/trx.conf b/example/scenarios/trx.conf
index f1d6d13..89d0d48 100644
--- a/example/scenarios/trx.conf
+++ b/example/scenarios/trx.conf
@@ -1,3 +1,3 @@
 resources:
   bts:
-  - type: osmo-bts-trx
+    type: osmo-bts-trx
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index 2808474..bc48a3e 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -16,6 +16,7 @@
 resources:
   bts:
   - times: '1'
+  - times: '2'
   ip_address:
   - times: '1'
   modem:
@@ -30,14 +31,30 @@
 ---------------------------------------------------------------------
 tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ...
 tst test_suite: DBG: {combining='resources'}
-tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'times': '1'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}}  [test_suite↪{combining_scenarios='resources'}]
-tst test_suite: Reserving 1 x bts (candidates: 3)
+tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'times': '1'}, {'times': '2'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}}  [test_suite↪{combining_scenarios='resources'}]
+tst test_suite: Reserving 3 x bts (candidates: 6)
 tst test_suite: DBG: Picked - _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
   addr: 10.42.42.114
   band: GSM-1800
   ipa_unit_id: '1'
   label: sysmoBTS 1002
   type: sysmo
+- _hash: 76c8d2f459113cd6c99ed62d1a94bbe9a291ba94
+  addr: 10.42.42.115
+  band: GSM-1800
+  ipa_unit_id: '5'
+  label: octBTS 3000
+  trx_list:
+  - hw_addr: 00:0c:90:32:b5:8a
+  type: oct
+- _hash: 0b7fabd512b36aec43d7d496abd00af4e193b0f8
+  addr: 10.42.42.190
+  band: GSM-1900
+  ipa_unit_id: '1902'
+  label: nanoBTS 1900
+  trx_list:
+  - hw_addr: 00:02:95:00:41:b3
+  type: nanobts
 tst test_suite: Reserving 1 x ip_address (candidates: 3)
 tst test_suite: DBG: Picked - _hash: cde1debf28f07f94f92c761b4b7c6bf35785ced4
   addr: 10.42.42.1
@@ -140,5 +157,84 @@
     skip: test_error.py (N.N sec)
     skip: test_fail.py (N.N sec)
     FAIL: test_fail_raise.py (N.N sec) ExpectedFail: This failure is expected
+- test with scenario
+cnf ResourcesPool: DBG: Found config file resources.conf as [PATH]/selftest/suite_test/resources.conf in ./suite_test which is [PATH]/selftest/suite_test  [config.py:[LINENR]]
+cnf ResourcesPool: DBG: Found path state_dir as [PATH]/selftest/suite_test/test_work/state_dir  [config.py:[LINENR]]
+
+---------------------------------------------------------------------
+trial test_suite
+---------------------------------------------------------------------
+tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ...  [suite.py:[LINENR]]
+tst test_suite: DBG: {combining='resources'}  [suite.py:[LINENR]]
+tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'times': '1'}, {'times': '2'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}}  [test_suite↪{combining_scenarios='resources'}]  [suite.py:[LINENR]]
+tst {combining_scenarios='resources', scenario='foo'}: DBG: {conf={bts={trx_list=[{'nominal_power': '10'}, {'nominal_power': '12'}], type='osmo-bts-trx'}}, scenario='foo'}  [test_suite↪{combining_scenarios='resources', scenario='foo'}]  [suite.py:[LINENR]]
+tst test_suite: Reserving 3 x bts (candidates: 6)  [resource.py:[LINENR]]
+tst test_suite: DBG: Picked - _hash: f1cab48db5b9004986e2030cb71730a5c55e823e
+  addr: 10.42.42.52
+  band: GSM-1800
+  ipa_unit_id: '6'
+  label: Ettus B200
+  launch_trx: 'True'
+  trx_list:
+  - nominal_power: '10'
+  - nominal_power: '12'
+  type: osmo-bts-trx
+- _hash: 1d00bd0d6643db5590cdbefff3152e70500abefc
+  addr: 10.42.42.53
+  band: GSM-1800
+  ipa_unit_id: '7'
+  label: sysmoCell 5000
+  trx_list:
+  - nominal_power: '10'
+  - nominal_power: '12'
+  trx_remote_ip: 10.42.42.112
+  type: osmo-bts-trx
+- _hash: 1d00bd0d6643db5590cdbefff3152e70500abefc
+  addr: 10.42.42.53
+  band: GSM-1800
+  ipa_unit_id: '7'
+  label: sysmoCell 5000
+  trx_list:
+  - nominal_power: '10'
+  - nominal_power: '12'
+  trx_remote_ip: 10.42.42.112
+  type: osmo-bts-trx
+  [resource.py:[LINENR]]
+tst test_suite: Reserving 1 x ip_address (candidates: 3)  [resource.py:[LINENR]]
+tst test_suite: DBG: Picked - _hash: cde1debf28f07f94f92c761b4b7c6bf35785ced4
+  addr: 10.42.42.1
+  [resource.py:[LINENR]]
+tst test_suite: Reserving 2 x modem (candidates: 16)  [resource.py:[LINENR]]
+tst test_suite: DBG: Picked - _hash: 19c69e45aa090fb511446bd00797690aa82ff52f
+  imsi: '901700000007801'
+  ki: D620F48487B1B782DA55DF6717F08FF9
+  label: m7801
+  path: /wavecom_0
+- _hash: e1a46516a1fb493b2617ab14fc1693a9a45ec254
+  imsi: '901700000007802'
+  ki: 47FDB2D55CE6A10A85ABDAD034A5B7B3
+  label: m7802
+  path: /wavecom_1
+  [resource.py:[LINENR]]
+
+----------------------------------------------
+trial test_suite hello_world.py
+----------------------------------------------
+tst hello_world.py:[LINENR]: hello world  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]
+tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]'  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]
+tst hello_world.py:[LINENR]: one  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]
+tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]
+tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]
+tst hello_world.py:[LINENR] Test passed (N.N sec)  [test_suite↪hello_world.py]  [suite.py:[LINENR]]
+---------------------------------------------------------------------
+trial test_suite PASS
+---------------------------------------------------------------------
+PASS: test_suite (pass: 1, skip: 5)
+    pass: hello_world.py (N.N sec)
+    skip: mo_mt_sms.py
+    skip: mo_sms.py
+    skip: test_error.py
+    skip: test_fail.py
+    skip: test_fail_raise.py
 
 - graceful exit.
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 86c4c25..9ea4fea 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -42,5 +42,13 @@
 output = report.suite_to_text(s)
 print(output)
 
+print('- test with scenario')
+trial = log.Origin(log.C_TST, 'trial')
+scenario = config.Scenario('foo', 'bar')
+scenario['resources'] = { 'bts': {'type': 'osmo-bts-trx', 'trx_list': [{'nominal_power': '10'}, {'nominal_power': '12'}]} }
+s = suite.SuiteRun(trial, 'test_suite', s_def, [scenario])
+results = s.run_tests('hello_world.py')
+print(report.suite_to_text(s))
+
 print('\n- graceful exit.')
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/selftest/suite_test/resources.conf b/selftest/suite_test/resources.conf
index 2005590..e302373 100644
--- a/selftest/suite_test/resources.conf
+++ b/selftest/suite_test/resources.conf
@@ -28,6 +28,36 @@
   trx_list:
   - hw_addr: 00:02:95:00:41:b3
 
+- label: Ettus B200
+  type: osmo-bts-trx
+  ipa_unit_id: 6
+  addr: 10.42.42.52
+  band: GSM-1800
+  launch_trx: true
+  trx_list:
+    - nominal_power: 10
+    - nominal_power: 12
+
+- label: sysmoCell 5000
+  type: osmo-bts-trx
+  ipa_unit_id: 7
+  addr: 10.42.42.53
+  band: GSM-1800
+  trx_remote_ip: 10.42.42.112
+  trx_list:
+    - nominal_power: 10
+    - nominal_power: 12
+
+- label: sysmoCell 5000
+  type: osmo-bts-trx
+  ipa_unit_id: 7
+  addr: 10.42.42.53
+  band: GSM-1800
+  trx_remote_ip: 10.42.42.112
+  trx_list:
+    - nominal_power: 10
+    - nominal_power: 12
+
 arfcn:
   - arfcn: 512
     band: GSM-1800
diff --git a/selftest/suite_test/test_suite/suite.conf b/selftest/suite_test/test_suite/suite.conf
index 376f6cd..890f66a 100644
--- a/selftest/suite_test/test_suite/suite.conf
+++ b/selftest/suite_test/test_suite/suite.conf
@@ -3,6 +3,7 @@
   - times: 1
   bts:
   - times: 1
+  - times: 2
   modem:
   - times: 2
 
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index da543f7..fa876d9 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -58,6 +58,7 @@
         'bts[].launch_trx': schema.BOOL_STR,
         'bts[].trx_list[].hw_addr': schema.HWADDR,
         'bts[].trx_list[].net_device': schema.STR,
+        'bts[].trx_list[].nominal_power': schema.INT,
         'arfcn[].arfcn': schema.INT,
         'arfcn[].band': schema.BAND,
         'modem[].label': schema.STR,
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index 2ac2062..b108703 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -217,7 +217,10 @@
             log.dbg(scenario=scenario.name(), conf=c)
             if c is None:
                 continue
-            config.combine(combination, c)
+            for obj_type, obj_li in combination.items():
+                obj_scenario = c.get(obj_type, {})
+                for obj in obj_li:
+                    config.combine(obj, obj_scenario)
         return combination
 
     def get_run_dir(self):

-- 
To view, visit https://gerrit.osmocom.org/3907
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25eb639c7e3cf3b4c67a205422808bffbdd791e6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list