ms: Make the outer variables configurable
Do the easy part for making these variables configurable. Change-Id: If8bbedcf672f6481a12c30d3669564704063626c
This commit is contained in:
parent
89dbf6db21
commit
0f0ebd85db
|
@ -19,50 +19,65 @@
|
|||
from .event_server import EventServer
|
||||
from .simple_loop import SimpleLoop
|
||||
from .location_update_test import MassUpdateLocationTest
|
||||
from .cdf import ease_in_out_duration, linear_with_duration
|
||||
from .cdf import ease_in_out_duration, linear_with_duration, cdfs
|
||||
from osmo_gsm_tester import log
|
||||
|
||||
# System modules
|
||||
import argparse
|
||||
import datetime
|
||||
import subprocess
|
||||
import signal
|
||||
import tempfile
|
||||
import os.path
|
||||
import os
|
||||
|
||||
def parser():
|
||||
parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser.add_argument('-s', '--launch-duration', dest='launch_duration',
|
||||
default=60, type=int,
|
||||
help="Time launching applications should take in seconds")
|
||||
parser.add_argument('-i', '--launch-interval', dest='launch_interval',
|
||||
default=100, type=int,
|
||||
help="Time between launching in milliseconds")
|
||||
parser.add_argument('-d', '--distribution', dest="cdf_name",
|
||||
choices=cdfs.keys(), default="ease_in_out",
|
||||
help="Curve to use for starting within launch duration")
|
||||
parser.add_argument('-m', '--number-ms', dest="num_ms",
|
||||
default=10, type=int,
|
||||
help="Number of MobileStations to simulate")
|
||||
return parser
|
||||
|
||||
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()
|
||||
|
||||
# TODO: Parse parameters and test composition. Right now we test
|
||||
# with a single set of values.
|
||||
num_ms = 10
|
||||
|
||||
tmp_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=60)
|
||||
time_start=datetime.timedelta(seconds=args.launch_duration)
|
||||
# In which steps to start processes
|
||||
time_step=datetime.timedelta(milliseconds=100)
|
||||
time_step=datetime.timedelta(milliseconds=args.launch_interval)
|
||||
|
||||
# Event server path
|
||||
event_server_path = os.path.join(tmp_dir, "osmo_ms_driver.unix")
|
||||
|
||||
# The function that decides when to start something
|
||||
cdf = ease_in_out_duration(time_start, time_step)
|
||||
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.
|
||||
test = MassUpdateLocationTest("lu_test", num_ms, cdf, ev_server, tmp_dir)
|
||||
test = MassUpdateLocationTest("lu_test", args.num_ms, cdf, ev_server, tmp_dir)
|
||||
|
||||
# Run until everything has been launched
|
||||
test.launch(loop)
|
||||
|
|
|
@ -103,3 +103,10 @@ def ease_in_out_duration(duration, step_size=timedelta(milliseconds=20)):
|
|||
scale = 1.0/duration.total_seconds()
|
||||
return DistributionFunctionHandler(step_size, duration,
|
||||
lambda x: _in_out(x*scale))
|
||||
|
||||
|
||||
cdfs = {
|
||||
'immediate': lambda x,y: immediate(y),
|
||||
'linear': linear_with_duration,
|
||||
'ease_in_out': ease_in_out_duration,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue