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.orgPau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11462 Change subject: WIP: gprs ...................................................................... WIP: gprs Change-Id: Icb06bdfcdd37c797be95ab5addb28da2d9f6681c --- A example/scenarios/modem-ec20.conf M src/osmo_gsm_tester/modem.py M src/osmo_gsm_tester/process.py M src/osmo_gsm_tester/suite.py M suites/gprs/ping.py A utils/osmo-gsm-tester_netns_exec.sh 6 files changed, 47 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/62/11462/1 diff --git a/example/scenarios/modem-ec20.conf b/example/scenarios/modem-ec20.conf new file mode 100644 index 0000000..c6dc8f9 --- /dev/null +++ b/example/scenarios/modem-ec20.conf @@ -0,0 +1,3 @@ +resources: + modem: + - label: ec20 diff --git a/src/osmo_gsm_tester/modem.py b/src/osmo_gsm_tester/modem.py index d0bbf23..f7acd8c 100644 --- a/src/osmo_gsm_tester/modem.py +++ b/src/osmo_gsm_tester/modem.py @@ -17,13 +17,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from . import log, util, sms +from . import log, util, sms, process from .event_loop import MainLoop from pydbus import SystemBus, Variant import time import pprint import sys +import os # Required for Gio.Cancellable. # See https://lazka.github.io/pgi-docs/Gio-2.0/classes/Cancellable.html#Gio.Cancellable @@ -326,15 +327,17 @@ CTX_PROT_IPv6 = 'ipv6' CTX_PROT_IPv46 = 'dual' - def __init__(self, conf): + def __init__(self, suite_run, conf): + self.suite_run = suite_run self.conf = conf self.syspath = conf.get('path') self.dbuspath = get_dbuspath_from_syspath(self.syspath) super().__init__(log.C_TST, self.dbuspath) - self.dbg('creating from syspath %s', self.syspath) + self.dbg('creating from syspath %s' % self.syspath) self.msisdn = None self._ki = None self._imsi = None + self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name().strip('/'))) self.sms_received_list = [] self.dbus = ModemDbusInteraction(self.dbuspath) self.register_attempts = 0 @@ -361,6 +364,9 @@ self.dbus.cleanup() self.dbus = None + def netns(self): + return os.path.basename(self.syspath.rstrip('/')) + def properties(self, *args, **kwargs): '''Return a dict of properties on this modem. For the actual arguments, see ModemDbusInteraction.properties(), which this function calls. The @@ -630,6 +636,23 @@ connmgr.RemoveContext(ctx_id) self.log('context deactivated', path=ctx_id) + def run_netns_wait(self, name, popen_args): + proc = process.NetNSProcess(name, self.run_dir.new_dir(name), self.netns(), popen_args, + env={}) + process.run_proc_sync(proc) + + def setup_context_data_plane(self, ctx_id): + self.dbg('setup_context_data', path=ctx_id) + ctx = systembus_get(ctx_id) + ctx_settings = ctx.GetProperties().get('Settings', None) + if not ctx_settings: + raise log.Error('%s no Settings found! No way to get iface!' % ctx_id) + iface = ctx_settings.get('Interface', None) + if not iface: + raise log.Error('%s Settings contains no iface! %r' % (ctx_id, repr(ctx_settings))) + self.run_netns_wait('ifup', ('ip', 'link', 'set', 'dev', iface, 'up')) + self.run_netns_wait('dhcp', ('udhcpc', '-q', '-i', iface)) + def sms_send(self, to_msisdn_or_modem, *tokens): if isinstance(to_msisdn_or_modem, Modem): to_msisdn = to_msisdn_or_modem.msisdn diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py index fb5c6f6..3764409 100644 --- a/src/osmo_gsm_tester/process.py +++ b/src/osmo_gsm_tester/process.py @@ -274,4 +274,12 @@ scp(run_dir, remote_user, remote_addr, 'scp-cfg-to-remote', cfg_file_name, remote_config_file) return remote_inst +class NetNSProcess(Process): + NETNS_EXEC_BIN = 'osmo-gsm-tester_netns_exec.sh' + def __init__(self, name, run_dir, netns, popen_args, **popen_kwargs): + super().__init__(name, run_dir, popen_args, **popen_kwargs) + self.netns = netns + + self.popen_args = ['sudo', self.NETNS_EXEC_BIN, self.netns] + list(popen_args) + self.dbg(self.popen_args, dir=self.run_dir, conf=self.popen_kwargs) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py index 3a49574..bf8156d 100644 --- a/src/osmo_gsm_tester/suite.py +++ b/src/osmo_gsm_tester/suite.py @@ -323,7 +323,7 @@ def modem(self, specifics=None): conf = self.reserved_resources.get(resource.R_MODEM, specifics=specifics) self.dbg('create Modem object', conf=conf) - ms = modem.Modem(conf) + ms = modem.Modem(self, conf) self.register_for_cleanup(ms) return ms diff --git a/suites/gprs/ping.py b/suites/gprs/ping.py index 1647445..5a821fe 100755 --- a/suites/gprs/ping.py +++ b/suites/gprs/ping.py @@ -48,8 +48,10 @@ # We need to use inet46 since ofono qmi only uses ipv4v6 eua (OS#2713) ctx_id_v4 = ms.activate_context(apn='inet46', protocol=ms.CTX_PROT_IPv4) -sleep(5) -# TODO: send ping to server or open TCP conn with a socket in python +print("Setting up data plan for %r" % repr(ctx_id_v4)) +ms.setup_context_data_plane(ctx_id_v4) +print("Running 10 ping requrests for %r" % repr(ctx_id_v4)) +ms.run_netns_wait('ping', ('ping', '-c', '10', ggsn.addr())) ms.deactivate_context(ctx_id_v4) # We need to use inet46 since ofono qmi only uses ipv4v6 eua (OS#2713) diff --git a/utils/osmo-gsm-tester_netns_exec.sh b/utils/osmo-gsm-tester_netns_exec.sh new file mode 100755 index 0000000..336b746 --- /dev/null +++ b/utils/osmo-gsm-tester_netns_exec.sh @@ -0,0 +1,5 @@ +#!/bin/bash +netns="$1" +shift +#TODO: Later on I may want to call myself with specific ENV and calling sudo in order to run inside the netns but with dropped privileges +ip netns exec $netns "$@" -- To view, visit https://gerrit.osmocom.org/11462 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Icb06bdfcdd37c797be95ab5addb28da2d9f6681c Gerrit-Change-Number: 11462 Gerrit-PatchSet: 1 Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181025/a14ccf57/attachment.htm>