<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/16231">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bts_osmotrx: Add support to run osmo-trx on LimeNet-micro<br><br>bts_osmotrx will check if target host can run the inst, and otherwise<br>run osmo-trx-lms already present in the system (installed by other<br>means). This way same class can be used both ways, since the only real<br>difference between the 2 scenarios is:<br>* copying inst vs not copying it.<br>* Running binary from inst vs running it from PATH.<br><br>This commit does not provide a mechanism to make sure the osmo-trx or its<br>dependencies are up-to-date in the target system. A solution for that<br>will be provided separately.<br><br>Related: SYS#4663<br>Change-Id: I6bd76f6d7e0cb2b6f7bdde971b6515846048a341<br>---<br>M example/resources.conf.prod<br>A example/scenarios/trx-lms-limenet-micro.conf<br>M src/osmo_gsm_tester/bts_osmotrx.py<br>3 files changed, 61 insertions(+), 23 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/example/resources.conf.prod b/example/resources.conf.prod</span><br><span>index e5911f1..6de4e2e 100644</span><br><span>--- a/example/resources.conf.prod</span><br><span>+++ b/example/resources.conf.prod</span><br><span>@@ -65,6 +65,20 @@</span><br><span> channels:</span><br><span> - rx_path: "LNAW"</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+- label: LimeNET-Micro</span><br><span style="color: hsl(120, 100%, 40%);">+ type: osmo-bts-trx</span><br><span style="color: hsl(120, 100%, 40%);">+ ipa_unit_id: 15</span><br><span style="color: hsl(120, 100%, 40%);">+ addr: 10.42.42.53</span><br><span style="color: hsl(120, 100%, 40%);">+ band: GSM-1800</span><br><span style="color: hsl(120, 100%, 40%);">+ ciphers: [a5_0, a5_1]</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_trx:</span><br><span style="color: hsl(120, 100%, 40%);">+ type: lms</span><br><span style="color: hsl(120, 100%, 40%);">+ launch_trx: true</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_user: pi</span><br><span style="color: hsl(120, 100%, 40%);">+ trx_ip: 10.42.42.123</span><br><span style="color: hsl(120, 100%, 40%);">+ clock_reference: external</span><br><span style="color: hsl(120, 100%, 40%);">+ dev_args: "LimeNET-Micro,serial=005839AF25B352"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> - label: sysmoCell 5000</span><br><span> type: osmo-bts-trx</span><br><span> ipa_unit_id: 7</span><br><span>diff --git a/example/scenarios/trx-lms-limenet-micro.conf b/example/scenarios/trx-lms-limenet-micro.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..2e2c1cc</span><br><span>--- /dev/null</span><br><span>+++ b/example/scenarios/trx-lms-limenet-micro.conf</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+resources:</span><br><span style="color: hsl(120, 100%, 40%);">+ bts:</span><br><span style="color: hsl(120, 100%, 40%);">+ - label: LimeNET-Micro</span><br><span style="color: hsl(120, 100%, 40%);">+ type: osmo-bts-trx</span><br><span>diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py</span><br><span>index f1fbdd1..9110d8a 100644</span><br><span>--- a/src/osmo_gsm_tester/bts_osmotrx.py</span><br><span>+++ b/src/osmo_gsm_tester/bts_osmotrx.py</span><br><span>@@ -295,35 +295,55 @@</span><br><span> os.chmod(wrapper_script, st.st_mode | stat.S_IEXEC)</span><br><span> return wrapper_script</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ def inst_compatible_for_remote(self):</span><br><span style="color: hsl(120, 100%, 40%);">+ proc = process.run_remote_sync(self.run_dir, self.remote_user, self.listen_ip, 'uname-m', ('uname', '-m'))</span><br><span style="color: hsl(120, 100%, 40%);">+ if "x86_64" in (proc.get_stdout() or ''):</span><br><span style="color: hsl(120, 100%, 40%);">+ return True</span><br><span style="color: hsl(120, 100%, 40%);">+ return False</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def start_remotely(self, keepalive):</span><br><span style="color: hsl(120, 100%, 40%);">+ # Run remotely through ssh. We need to run osmo-trx under a wrapper</span><br><span style="color: hsl(120, 100%, 40%);">+ # script since osmo-trx ignores SIGHUP and will keep running after</span><br><span style="color: hsl(120, 100%, 40%);">+ # we close local ssh session. The wrapper script catches SIGHUP and</span><br><span style="color: hsl(120, 100%, 40%);">+ # sends SIGINT to it.</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_run_dir = util.Dir(OsmoTrx.REMOTE_DIR)</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_config_file = remote_run_dir.child(OsmoTrx.CONF_OSMO_TRX)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ have_inst = self.inst_compatible_for_remote()</span><br><span style="color: hsl(120, 100%, 40%);">+ if have_inst:</span><br><span style="color: hsl(120, 100%, 40%);">+ self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-trx')))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ # if self.inst is None, we still want to copy config file, create remote run dir, etc.</span><br><span style="color: hsl(120, 100%, 40%);">+ self.remote_inst = process.copy_inst_ssh(self.run_dir, self.inst, remote_run_dir, self.remote_user,</span><br><span style="color: hsl(120, 100%, 40%);">+ self.listen_ip, self.binary_name(), self.config_file)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapper_script = self.generate_wrapper_script()</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_wrapper_script = remote_run_dir.child(OsmoTrx.WRAPPER_SCRIPT)</span><br><span style="color: hsl(120, 100%, 40%);">+ process.scp(self.run_dir, self.remote_user, self.listen_ip, 'scp-wrapper-to-remote', wrapper_script, remote_wrapper_script)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if have_inst:</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_lib = self.remote_inst.child('lib')</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_binary = self.remote_inst.child('bin', self.binary_name())</span><br><span style="color: hsl(120, 100%, 40%);">+ args = ('LD_LIBRARY_PATH=%s' % remote_lib, remote_wrapper_script, remote_binary, '-C', remote_config_file)</span><br><span style="color: hsl(120, 100%, 40%);">+ else: # Use whatever is available i nremote system PATH:</span><br><span style="color: hsl(120, 100%, 40%);">+ args = (remote_wrapper_script, self.binary_name(), '-C', remote_config_file)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ self.proc_trx = self.launch_process_remote(self.binary_name(), args, remote_cwd=remote_run_dir, keepalive=keepalive)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ##############</span><br><span> # PUBLIC (test API included)</span><br><span> ##############</span><br><span> def start(self, keepalive=False):</span><br><span> self.configure()</span><br><span style="color: hsl(120, 100%, 40%);">+ if self.remote_user:</span><br><span style="color: hsl(120, 100%, 40%);">+ self.start_remotely(keepalive)</span><br><span style="color: hsl(120, 100%, 40%);">+ return</span><br><span style="color: hsl(120, 100%, 40%);">+ # Run locally if ssh user is not set</span><br><span> self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-trx')))</span><br><span style="color: hsl(0, 100%, 40%);">- if not self.remote_user:</span><br><span style="color: hsl(0, 100%, 40%);">- # Run locally if ssh user is not set</span><br><span style="color: hsl(0, 100%, 40%);">- lib = self.inst.child('lib')</span><br><span style="color: hsl(0, 100%, 40%);">- self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }</span><br><span style="color: hsl(0, 100%, 40%);">- self.proc_trx = self.launch_process_local(keepalive, self.binary_name(),</span><br><span style="color: hsl(0, 100%, 40%);">- '-C', os.path.abspath(self.config_file))</span><br><span style="color: hsl(0, 100%, 40%);">- else:</span><br><span style="color: hsl(0, 100%, 40%);">- # Run remotely through ssh. We need to run osmo-trx under a wrapper</span><br><span style="color: hsl(0, 100%, 40%);">- # script since osmo-trx ignores SIGHUP and will keep running after</span><br><span style="color: hsl(0, 100%, 40%);">- # we close local ssh session. The wrapper script catches SIGHUP and</span><br><span style="color: hsl(0, 100%, 40%);">- # sends SIGINT to it.</span><br><span style="color: hsl(0, 100%, 40%);">- wrapper_script = self.generate_wrapper_script()</span><br><span style="color: hsl(0, 100%, 40%);">- remote_run_dir = util.Dir(OsmoTrx.REMOTE_DIR)</span><br><span style="color: hsl(0, 100%, 40%);">- self.remote_inst = process.copy_inst_ssh(self.run_dir, self.inst, remote_run_dir, self.remote_user,</span><br><span style="color: hsl(0, 100%, 40%);">- self.listen_ip, self.binary_name(), self.config_file)</span><br><span style="color: hsl(0, 100%, 40%);">- remote_wrapper_script = remote_run_dir.child(OsmoTrx.WRAPPER_SCRIPT)</span><br><span style="color: hsl(0, 100%, 40%);">- remote_config_file = remote_run_dir.child(OsmoTrx.CONF_OSMO_TRX)</span><br><span style="color: hsl(0, 100%, 40%);">- remote_lib = self.remote_inst.child('lib')</span><br><span style="color: hsl(0, 100%, 40%);">- remote_binary = self.remote_inst.child('bin', self.binary_name())</span><br><span style="color: hsl(0, 100%, 40%);">- process.scp(self.run_dir, self.remote_user, self.listen_ip, 'scp-wrapper-to-remote', wrapper_script, remote_wrapper_script)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- args = ('LD_LIBRARY_PATH=%s' % remote_lib, remote_wrapper_script, remote_binary, '-C', remote_config_file)</span><br><span style="color: hsl(0, 100%, 40%);">- self.proc_trx = self.launch_process_remote(self.binary_name(), args, remote_cwd=remote_run_dir, keepalive=keepalive)</span><br><span style="color: hsl(120, 100%, 40%);">+ lib = self.inst.child('lib')</span><br><span style="color: hsl(120, 100%, 40%);">+ self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }</span><br><span style="color: hsl(120, 100%, 40%);">+ self.proc_trx = self.launch_process_local(keepalive, self.binary_name(),</span><br><span style="color: hsl(120, 100%, 40%);">+ '-C', os.path.abspath(self.config_file))</span><br><span> </span><br><span> def trx_ready(self):</span><br><span> if not self.proc_trx or not self.proc_trx.is_running:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/16231">change 16231</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/16231"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-gsm-tester </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6bd76f6d7e0cb2b6f7bdde971b6515846048a341 </div>
<div style="display:none"> Gerrit-Change-Number: 16231 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>