[PATCH] osmo-gsm-tester[master]: config: replicate_times: insert replicates in place

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
Tue Sep 12 15:36:51 UTC 2017


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

config: replicate_times: insert replicates in place

In the following suite.conf, position matters when matching against scenarios:

[suite.conf]
resources:
  bts:
  - type: sysmo
    times: 2
  - type: osmo-bts-trx
    times: 1

[scenario]
resources:
  bts:
  -
  - ip_addr: 1.2.3.4

In this case, for instance, we make it clear that we want the second
sysmo bts which has IP 1.2.3.4. With old behaviour, the replicated sysmo
would have been created at the end (3rd position), and the ip_addr would
match against the osmo-bts-trx BTS.

Change-Id: Id78e2326db964d5efb6648854b57d8addce4deb0
---
M src/osmo_gsm_tester/config.py
1 file changed, 7 insertions(+), 7 deletions(-)


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

diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py
index a0fe969..4e7f504 100644
--- a/src/osmo_gsm_tester/config.py
+++ b/src/osmo_gsm_tester/config.py
@@ -277,13 +277,13 @@
     'replicate items that have a "times" > 1'
     d = copy.deepcopy(d)
     for key, item_list in d.items():
-        more_items = []
-        for item in item_list:
-            times = int(item.pop('times'))
-            if times and times > 1:
-                for i in range(times - 1):
-                    more_items.append(copy.deepcopy(item))
-        item_list.extend(more_items)
+        idx = 0
+        while idx < len(item_list):
+            item = item_list[idx]
+            times = int(item.pop('times', 1))
+            for j in range(1, times):
+                item_list.insert(idx + j, copy.deepcopy(item))
+            idx += times
     return d
 
 # vim: expandtab tabstop=4 shiftwidth=4

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id78e2326db964d5efb6648854b57d8addce4deb0
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