Ejemplo n.º 1
0
 def __init__(self, name, num_tests):
     super().__init__(log.C_TST, name)
     self.test_basenames = [
         name + '-' + str(tid) for tid in range(num_tests)
     ]
     self.conf = {}
     self.suite_dir = util.Dir(example_trial_dir).new_child('suitedef' +
                                                            name)
Ejemplo n.º 2
0
def main():
    # Create a default log to stdout
    log.LogTarget().style(src=False)

    args = parser().parse_args()

    # We don't care what is happening to child processes we spawn!
    signal.signal(signal.SIGCHLD, signal.SIG_IGN)

    loop = SimpleLoop()

    tmp_dir = util.Dir(tempfile.mkdtemp(suffix="osmo-ms-driver"))
    log.log("Going to store files in ", tmp_dir=tmp_dir)

    # How long should starting all apps take
    time_start = datetime.timedelta(seconds=args.launch_duration)
    # In which steps to start processes
    time_step = datetime.timedelta(milliseconds=args.launch_interval)

    # Event server path
    event_server_path = os.path.join(str(tmp_dir), "osmo_ms_driver.unix")

    # The function that decides when to start something
    cdf = cdfs[args.cdf_name](time_start, time_step)

    # Event server to handle MS->test events
    ev_server = EventServer("ev_server", event_server_path)
    ev_server.listen(loop)

    # Just a single test for now.
    options = BinaryOptions("virtphy", "mobile", os.environ)
    result = {}
    starter = MobileTestStarter("lu_test", options, cdf, ev_server, tmp_dir,
                                result)
    test = MassUpdateLocationTest("lu_test", ev_server, result)

    # Add subscribers to the test.
    imsi_gen = imsi_ki_gen()
    for i in range(0, args.num_ms):
        imsi, ki = next(imsi_gen)
        conf = {
            'imsi': imsi,
            'ki': ki,
            'auth_algo': 'comp128v1',
            'run_lu_test': False,
        }
        starter.subscriber_add(ms_osmo_mobile.MSOsmoMobile("ms_%d" % i, conf))
    starter.configure_tasks()
    test.configure(args.num_ms)

    atexit.register(starter.stop_all)

    # Run until everything has been launched
    deadline = starter.start_all(loop, timedelta(seconds=args.test_duration))
    test.wait_for_test(loop, deadline)

    # Print stats
    test.print_stats()
Ejemplo n.º 3
0
    def start(self, loop, testenv=None):
        if testenv is not None:  # overwrite run_dir to store files if run from inside osmo-gsm-tester:
            self.run_dir = util.Dir(testenv.suite().get_run_dir().new_dir(
                self.name()))
        lua_filename = self.write_lua_cfg()
        mob_filename = self.write_mob_cfg(lua_filename, self._phy_filename)

        self.log("Starting mobile")
        # Let the kernel pick an unused port for the VTY.
        args = [self._binary, "-c", mob_filename]
        self._omob_proc = process.Process(self.name(),
                                          self.run_dir,
                                          args,
                                          env=self._env)
        if testenv is not None:
            testenv.remember_to_stop(self._omob_proc)
        self._omob_proc.launch()
Ejemplo n.º 4
0
    def start(self, loop, testenv=None):
        if testenv is not None:  # overwrite run_dir to store files if run from inside osmo-gsm-tester:
            self.run_dir = util.Dir(testenv.suite().get_run_dir().new_dir(
                self.name()))
        if len(self._phy_filename.encode()) > 107:
            raise log.Error(
                'Path for unix socket is longer than max allowed len for unix socket path (107):',
                self._phy_filename)

        self.log("Starting virtphy")
        args = [self._binary, "--l1ctl-sock=" + self._phy_filename]
        self._vphy_proc = process.Process(self.name(),
                                          self.run_dir,
                                          args,
                                          env=self._env)
        if testenv is not None:
            testenv.remember_to_stop(self._vphy_proc)
        self._vphy_proc.launch()
Ejemplo n.º 5
0
#!/usr/bin/env python3

import _prep

import time
import os

from osmo_gsm_tester.core import util
from osmo_gsm_tester.core.trial import Trial

workdir = util.get_tempdir()

trials_dir = util.Dir(workdir)

print('- make a few trials dirs')
print(trials_dir.mkdir('first'))
time.sleep(1)
print(trials_dir.mkdir('second'))
time.sleep(1)
print(trials_dir.mkdir('third'))

print('- fetch trial dirs in order')
t = Trial.next(trials_dir)
print(t)
print(repr(sorted(t.dir.children())))
print(Trial.next(trials_dir))
print(Trial.next(trials_dir))

print('- no more trial dirs left')
print(repr(Trial.next(trials_dir)))
Ejemplo n.º 6
0
#!/usr/bin/env python3

import _prep
import time
import os

from osmo_gsm_tester.core import process, util, log

tmpdir = util.Dir(util.get_tempdir())

dollar_path = '%s:%s' % (os.path.join(os.getcwd(),
                                      'process_test'), os.getenv('PATH'))

p = process.Process('foo',
                    tmpdir, ('foo.py', 'arg1', 'arg2'),
                    env={'PATH': dollar_path})

p.launch()
time.sleep(.5)
p.poll()
print('stdout:')
print(p.get_stdout())
print('stderr:')
print(p.get_stderr())

assert not p.terminated()
p.terminate()
assert p.terminated()
print('result: %r' % p.result)

print('stdout:')
Ejemplo n.º 7
0
 def get_run_dir(self):
     if self._run_dir is not None:
         return self._run_dir
     self._run_dir = util.Dir(self.dir.new_child('test_run'))
     self._run_dir.mkdir()
     return self._run_dir
Ejemplo n.º 8
0
 def __init__(self):
     super().__init__(log.C_TST, 'trial')
     self.dir = util.Dir(example_trial_dir)
     self._run_dir = None