[MERGED] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-04-05 Thread Holger Freyther
Holger Freyther has submitted this change and it was merged.

Change subject: ms: Create a cumulative distribution function class
..


ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A selftest/cdf_test.ok
A selftest/cdf_test.py
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
4 files changed, 259 insertions(+), 0 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/selftest/cdf_test.ok b/selftest/cdf_test.ok
new file mode 100644
index 000..aa753e4
--- /dev/null
+++ b/selftest/cdf_test.ok
@@ -0,0 +1,57 @@
+Testing the immediate CDF
+Done True
+1 1.0 False
+Testing linear with duration
+Done False
+0.0 0.0 True
+Done False
+0.2 0.2 True
+Done False
+0.4 0.4 True
+Done False
+0.6 0.6 True
+Done False
+0.8 0.8 True
+Done True
+1.0 1.0 True
+Testing linear with duration scaled
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+0.2 0.2 True
+200 200 True
+Done False
+0.4 0.4 True
+400 400 True
+Done False
+0.6 0.6 True
+600 600 True
+Done False
+0.8 0.8 True
+800 800 True
+Done True
+1.0 1.0 True
+100 100 True
+Testing in_out
+0.5 0.5 True
+0.87 0.87 True
+0.9 0.9 True
+0.95 0.95 True
+1.0 1.0 True
+Testing ease In and Out
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+5.0 5.0 True
+0.1 0.1 True
+Done False
+10.0 10.0 True
+0.5 0.5 True
+Done False
+15.0 15.0 True
+0.8 0.8 True
+Done True
+20.0 20 True
+1.0 1.0 True
diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
new file mode 100755
index 000..8d837c1
--- /dev/null
+++ b/selftest/cdf_test.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+
+import _prep
+
+from osmo_ms_driver import cdf
+from datetime import timedelta
+
+def print_fuzzy_compare(want, expe, len=3):
+want_str = str(want)[0:len]
+expe_str = str(expe)[0:len]
+print(want_str, expe_str, want_str == expe_str)
+
+
+def check_steps(a, steps, fun):
+print("Done", a.is_done())
+for step in steps:
+# Verify we can step
+
+# Compare and step once
+fun(a, step)
+if a.is_done():
+break
+a.step_once()
+print("Done", a.is_done())
+
+def compare_value(a, step):
+print_fuzzy_compare(a.current_value(), step)
+
+def compare_scaled_value(a, val):
+(step, scale) = val
+print_fuzzy_compare(a.current_value(), step)
+print_fuzzy_compare(a.current_scaled_value(), scale)
+
+def compare_x_value(a, val):
+(x, step) = val
+print(a._x, x, x == a._x)
+print_fuzzy_compare(a.current_value(), step)
+
+def testImmediate():
+print("Testing the immediate CDF")
+a = cdf.immediate()
+print("Done", a.is_done())
+print_fuzzy_compare(a.current_value(), 1.0)
+
+
+def testLinearWithDuration():
+print("Testing linear with duration")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
+check_steps(a, steps, compare_value)
+
+print("Testing linear with duration scaled")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+a.set_target(1000)
+steps = [(0.0, 0.0), (0.2, 200), (0.4, 400), (0.6, 600), (0.8, 800), (1.0, 
1)]
+check_steps(a, steps, compare_scaled_value)
+
+def testInOut():
+print("Testing in_out")
+print_fuzzy_compare(cdf._in_out(0.5), 0.5, 3)
+print_fuzzy_compare(cdf._in_out(0.75), 0.875, 4)
+print_fuzzy_compare(cdf._in_out(0.8), 0.92, 3)
+print_fuzzy_compare(cdf._in_out(0.85), 0.955, 4)
+print_fuzzy_compare(cdf._in_out(1.0), 1.0, 3)
+
+def testEaseInOutDuration():
+print("Testing ease In and Out")
+a = cdf.ease_in_out_duration(duration=timedelta(seconds=20), 
step_size=timedelta(seconds=5))
+steps = [(0.0, 0.0), (5.0, 0.125), (10.0, 0.5), (15.0, 0.875), (20, 1.0)]
+check_steps(a, steps, compare_x_value)
+
+testImmediate()
+testLinearWithDuration()
+testInOut()
+testEaseInOutDuration()
diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..0c7b4b9
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,22 @@
+# osmo_ms_driver: automated cellular network tests
+#
+# Copyright (C) 2018 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-04-05 Thread Pau Espin Pedrol

Patch Set 8: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 8
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-04-04 Thread Holger Freyther
Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#8).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A selftest/cdf_test.ok
A selftest/cdf_test.py
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
4 files changed, 259 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/8

diff --git a/selftest/cdf_test.ok b/selftest/cdf_test.ok
new file mode 100644
index 000..aa753e4
--- /dev/null
+++ b/selftest/cdf_test.ok
@@ -0,0 +1,57 @@
+Testing the immediate CDF
+Done True
+1 1.0 False
+Testing linear with duration
+Done False
+0.0 0.0 True
+Done False
+0.2 0.2 True
+Done False
+0.4 0.4 True
+Done False
+0.6 0.6 True
+Done False
+0.8 0.8 True
+Done True
+1.0 1.0 True
+Testing linear with duration scaled
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+0.2 0.2 True
+200 200 True
+Done False
+0.4 0.4 True
+400 400 True
+Done False
+0.6 0.6 True
+600 600 True
+Done False
+0.8 0.8 True
+800 800 True
+Done True
+1.0 1.0 True
+100 100 True
+Testing in_out
+0.5 0.5 True
+0.87 0.87 True
+0.9 0.9 True
+0.95 0.95 True
+1.0 1.0 True
+Testing ease In and Out
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+5.0 5.0 True
+0.1 0.1 True
+Done False
+10.0 10.0 True
+0.5 0.5 True
+Done False
+15.0 15.0 True
+0.8 0.8 True
+Done True
+20.0 20 True
+1.0 1.0 True
diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
new file mode 100755
index 000..8d837c1
--- /dev/null
+++ b/selftest/cdf_test.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+
+import _prep
+
+from osmo_ms_driver import cdf
+from datetime import timedelta
+
+def print_fuzzy_compare(want, expe, len=3):
+want_str = str(want)[0:len]
+expe_str = str(expe)[0:len]
+print(want_str, expe_str, want_str == expe_str)
+
+
+def check_steps(a, steps, fun):
+print("Done", a.is_done())
+for step in steps:
+# Verify we can step
+
+# Compare and step once
+fun(a, step)
+if a.is_done():
+break
+a.step_once()
+print("Done", a.is_done())
+
+def compare_value(a, step):
+print_fuzzy_compare(a.current_value(), step)
+
+def compare_scaled_value(a, val):
+(step, scale) = val
+print_fuzzy_compare(a.current_value(), step)
+print_fuzzy_compare(a.current_scaled_value(), scale)
+
+def compare_x_value(a, val):
+(x, step) = val
+print(a._x, x, x == a._x)
+print_fuzzy_compare(a.current_value(), step)
+
+def testImmediate():
+print("Testing the immediate CDF")
+a = cdf.immediate()
+print("Done", a.is_done())
+print_fuzzy_compare(a.current_value(), 1.0)
+
+
+def testLinearWithDuration():
+print("Testing linear with duration")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
+check_steps(a, steps, compare_value)
+
+print("Testing linear with duration scaled")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+a.set_target(1000)
+steps = [(0.0, 0.0), (0.2, 200), (0.4, 400), (0.6, 600), (0.8, 800), (1.0, 
1)]
+check_steps(a, steps, compare_scaled_value)
+
+def testInOut():
+print("Testing in_out")
+print_fuzzy_compare(cdf._in_out(0.5), 0.5, 3)
+print_fuzzy_compare(cdf._in_out(0.75), 0.875, 4)
+print_fuzzy_compare(cdf._in_out(0.8), 0.92, 3)
+print_fuzzy_compare(cdf._in_out(0.85), 0.955, 4)
+print_fuzzy_compare(cdf._in_out(1.0), 1.0, 3)
+
+def testEaseInOutDuration():
+print("Testing ease In and Out")
+a = cdf.ease_in_out_duration(duration=timedelta(seconds=20), 
step_size=timedelta(seconds=5))
+steps = [(0.0, 0.0), (5.0, 0.125), (10.0, 0.5), (15.0, 0.875), (20, 1.0)]
+check_steps(a, steps, compare_x_value)
+
+testImmediate()
+testLinearWithDuration()
+testInOut()
+testEaseInOutDuration()
diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..0c7b4b9
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,22 @@
+# osmo_ms_driver: automated cellular network tests
+#
+# Copyright (C) 2018 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-04-02 Thread Holger Freyther

Patch Set 3:

(2 comments)

> (2 comments)
 

 > I'm not sure I overlook the bigger picture, but do go ahead.

Which size of the frame do we want? For simulation we want different models of 
when a subscriber comes into a serving a area.

* Everything at once
* Linear over time
* Slow start, bulk, trailing end

In real-life osmo-bts can ramp up power slowly. E.g. to catch few subscribers 
in the beginning and then more and more. I thought the concept of a cumulative 
distribution function (CDF) let's us model this the easiest way (by emulating 
visibility with starting the osmocom-bb later)

https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/__init__.py
File src/osmo_ms_driver/__init__.py:

Line 5: # Authors: D. Lazlo Sitzer 
> Also, frankly, this is just a list of authors, the copyright is two lines f
Accurate point but I didn't write any of the lines and just cp'ed that file. 
But let's not lose any time on this one?

We should talk about how I copied it without updating "update_version.sh" and 
not providing any _version.py ;)


https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/cdf.py
File src/osmo_ms_driver/cdf.py:

Line 29: y-axis we have the percentage (from 0.0 to 1.0) of how many
> technically from 0..1 would not be a percentage as the word implies the 0..
Your point is the von Neumann statement that floating point is for people that 
can't move the comma/dot? But I think it is common for probability and 
percentage to range from 0.0 to 1.0?

s/percentage/value? Better?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-23 Thread Neels Hofmeyr

Patch Set 7: Code-Review+1

(2 comments)

I'm not sure I overlook the bigger picture, but do go ahead.

https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/__init__.py
File src/osmo_ms_driver/__init__.py:

Line 5: # Authors: D. Lazlo Sitzer 
> That's not how copyright works but you have an expert in your proximity but
Also, frankly, this is just a list of authors, the copyright is two lines 
further up.


https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/cdf.py
File src/osmo_ms_driver/cdf.py:

Line 29: y-axis we have the percentage (from 0.0 to 1.0) of how many
technically from 0..1 would not be a percentage as the word implies the 0..100 
range; more like a fraction or factor :)


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-21 Thread Pau Espin Pedrol

Patch Set 7:

Current status for this patchset to be merged is basically to investigate why 
the cdf_test.py is not being run. Other than that it looks fine. I see that the 
latest patch is neither running this test, so we can probably try running it 
with a new patch attempting to fix it later.

Holger can you confirm that at least it passes locally and attempt to fix this 
issue in jenkins? It's fine to fix it in an extra commit.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-16 Thread Holger Freyther

Patch Set 7:

Hmm.. So even with _prep missing the test should have been executed... I am 
retriggering the build and check if the workspace is updated..

https://jenkins.osmocom.org/jenkins/job/osmo-gsm-tester_gerrit/ws/osmo-gsm-tester/selftest/
 doesn't contain a cdf_test.py... that's strange..

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-16 Thread Holger Freyther

Patch Set 6:

> I think your new cdf_test is not yet being executed. I had to add
 > the import _prep to successfully run them locally. Did you try
 > yourself?

I had a PYTHONPATH changed and emulated a "testsuite -k testname" behavior by 
setting the array of tests. I thought _prep is a python internal module and I 
wondered how it would help me.. it took me a bit to realize that it is our test 
preparation. :}

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 6
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-16 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#7).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A selftest/cdf_test.ok
A selftest/cdf_test.py
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
4 files changed, 266 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/7

diff --git a/selftest/cdf_test.ok b/selftest/cdf_test.ok
new file mode 100644
index 000..aa753e4
--- /dev/null
+++ b/selftest/cdf_test.ok
@@ -0,0 +1,57 @@
+Testing the immediate CDF
+Done True
+1 1.0 False
+Testing linear with duration
+Done False
+0.0 0.0 True
+Done False
+0.2 0.2 True
+Done False
+0.4 0.4 True
+Done False
+0.6 0.6 True
+Done False
+0.8 0.8 True
+Done True
+1.0 1.0 True
+Testing linear with duration scaled
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+0.2 0.2 True
+200 200 True
+Done False
+0.4 0.4 True
+400 400 True
+Done False
+0.6 0.6 True
+600 600 True
+Done False
+0.8 0.8 True
+800 800 True
+Done True
+1.0 1.0 True
+100 100 True
+Testing in_out
+0.5 0.5 True
+0.87 0.87 True
+0.9 0.9 True
+0.95 0.95 True
+1.0 1.0 True
+Testing ease In and Out
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+5.0 5.0 True
+0.1 0.1 True
+Done False
+10.0 10.0 True
+0.5 0.5 True
+Done False
+15.0 15.0 True
+0.8 0.8 True
+Done True
+20.0 20 True
+1.0 1.0 True
diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
new file mode 100755
index 000..8d837c1
--- /dev/null
+++ b/selftest/cdf_test.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+
+import _prep
+
+from osmo_ms_driver import cdf
+from datetime import timedelta
+
+def print_fuzzy_compare(want, expe, len=3):
+want_str = str(want)[0:len]
+expe_str = str(expe)[0:len]
+print(want_str, expe_str, want_str == expe_str)
+
+
+def check_steps(a, steps, fun):
+print("Done", a.is_done())
+for step in steps:
+# Verify we can step
+
+# Compare and step once
+fun(a, step)
+if a.is_done():
+break
+a.step_once()
+print("Done", a.is_done())
+
+def compare_value(a, step):
+print_fuzzy_compare(a.current_value(), step)
+
+def compare_scaled_value(a, val):
+(step, scale) = val
+print_fuzzy_compare(a.current_value(), step)
+print_fuzzy_compare(a.current_scaled_value(), scale)
+
+def compare_x_value(a, val):
+(x, step) = val
+print(a._x, x, x == a._x)
+print_fuzzy_compare(a.current_value(), step)
+
+def testImmediate():
+print("Testing the immediate CDF")
+a = cdf.immediate()
+print("Done", a.is_done())
+print_fuzzy_compare(a.current_value(), 1.0)
+
+
+def testLinearWithDuration():
+print("Testing linear with duration")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
+check_steps(a, steps, compare_value)
+
+print("Testing linear with duration scaled")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+a.set_target(1000)
+steps = [(0.0, 0.0), (0.2, 200), (0.4, 400), (0.6, 600), (0.8, 800), (1.0, 
1)]
+check_steps(a, steps, compare_scaled_value)
+
+def testInOut():
+print("Testing in_out")
+print_fuzzy_compare(cdf._in_out(0.5), 0.5, 3)
+print_fuzzy_compare(cdf._in_out(0.75), 0.875, 4)
+print_fuzzy_compare(cdf._in_out(0.8), 0.92, 3)
+print_fuzzy_compare(cdf._in_out(0.85), 0.955, 4)
+print_fuzzy_compare(cdf._in_out(1.0), 1.0, 3)
+
+def testEaseInOutDuration():
+print("Testing ease In and Out")
+a = cdf.ease_in_out_duration(duration=timedelta(seconds=20), 
step_size=timedelta(seconds=5))
+steps = [(0.0, 0.0), (5.0, 0.125), (10.0, 0.5), (15.0, 0.875), (20, 1.0)]
+check_steps(a, steps, compare_x_value)
+
+testImmediate()
+testLinearWithDuration()
+testInOut()
+testEaseInOutDuration()
diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-15 Thread Pau Espin Pedrol

Patch Set 6:

I think your new cdf_test is not yet being executed. I had to add the import 
_prep to successfully run them locally. Did you try yourself?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 6
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-07 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#6).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A selftest/cdf_test.ok
A selftest/cdf_test.py
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
4 files changed, 265 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/6

diff --git a/selftest/cdf_test.ok b/selftest/cdf_test.ok
new file mode 100644
index 000..aa753e4
--- /dev/null
+++ b/selftest/cdf_test.ok
@@ -0,0 +1,57 @@
+Testing the immediate CDF
+Done True
+1 1.0 False
+Testing linear with duration
+Done False
+0.0 0.0 True
+Done False
+0.2 0.2 True
+Done False
+0.4 0.4 True
+Done False
+0.6 0.6 True
+Done False
+0.8 0.8 True
+Done True
+1.0 1.0 True
+Testing linear with duration scaled
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+0.2 0.2 True
+200 200 True
+Done False
+0.4 0.4 True
+400 400 True
+Done False
+0.6 0.6 True
+600 600 True
+Done False
+0.8 0.8 True
+800 800 True
+Done True
+1.0 1.0 True
+100 100 True
+Testing in_out
+0.5 0.5 True
+0.87 0.87 True
+0.9 0.9 True
+0.95 0.95 True
+1.0 1.0 True
+Testing ease In and Out
+Done False
+0.0 0.0 True
+0.0 0.0 True
+Done False
+5.0 5.0 True
+0.1 0.1 True
+Done False
+10.0 10.0 True
+0.5 0.5 True
+Done False
+15.0 15.0 True
+0.8 0.8 True
+Done True
+20.0 20 True
+1.0 1.0 True
diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
new file mode 100755
index 000..282ea75
--- /dev/null
+++ b/selftest/cdf_test.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+
+from osmo_ms_driver import cdf
+from datetime import timedelta
+
+
+def print_fuzzy_compare(want, expe, len=3):
+want_str = str(want)[0:len]
+expe_str = str(expe)[0:len]
+print(want_str, expe_str, want_str == expe_str)
+
+
+def check_steps(a, steps, fun):
+print("Done", a.is_done())
+for step in steps:
+# Verify we can step
+
+# Compare and step once
+fun(a, step)
+if a.is_done():
+break
+a.step_once()
+print("Done", a.is_done())
+
+def compare_value(a, step):
+print_fuzzy_compare(a.current_value(), step)
+
+def compare_scaled_value(a, val):
+(step, scale) = val
+print_fuzzy_compare(a.current_value(), step)
+print_fuzzy_compare(a.current_scaled_value(), scale)
+
+def compare_x_value(a, val):
+(x, step) = val
+print(a._x, x, x == a._x)
+print_fuzzy_compare(a.current_value(), step)
+
+def testImmediate():
+print("Testing the immediate CDF")
+a = cdf.immediate()
+print("Done", a.is_done())
+print_fuzzy_compare(a.current_value(), 1.0)
+
+
+def testLinearWithDuration():
+print("Testing linear with duration")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
+check_steps(a, steps, compare_value)
+
+print("Testing linear with duration scaled")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+a.set_target(1000)
+steps = [(0.0, 0.0), (0.2, 200), (0.4, 400), (0.6, 600), (0.8, 800), (1.0, 
1)]
+check_steps(a, steps, compare_scaled_value)
+
+def testInOut():
+print("Testing in_out")
+print_fuzzy_compare(cdf._in_out(0.5), 0.5, 3)
+print_fuzzy_compare(cdf._in_out(0.75), 0.875, 4)
+print_fuzzy_compare(cdf._in_out(0.8), 0.92, 3)
+print_fuzzy_compare(cdf._in_out(0.85), 0.955, 4)
+print_fuzzy_compare(cdf._in_out(1.0), 1.0, 3)
+
+def testEaseInOutDuration():
+print("Testing ease In and Out")
+a = cdf.ease_in_out_duration(duration=timedelta(seconds=20), 
step_size=timedelta(seconds=5))
+steps = [(0.0, 0.0), (5.0, 0.125), (10.0, 0.5), (15.0, 0.875), (20, 1.0)]
+check_steps(a, steps, compare_x_value)
+
+testImmediate()
+testLinearWithDuration()
+testInOut()
+testEaseInOutDuration()
diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-07 Thread Holger Freyther

Patch Set 5:

> Thanks for moving the tests to the existing test system. It seems
 > however the new test is not being run in jenkins. Running it
 > locally (make check) in my PC actually shows it's missing exec
 > permission on the file (I don't know why jenkins doesn't fail). you
 > need to +x it.

Sorry about that. I wrote it in an airplane but didn't have ofono installed and 
couldn't run the tests (it didn't seem possible to just run a single test). I 
am surprised by the _prep import?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 5
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-07 Thread Pau Espin Pedrol

Patch Set 5: Code-Review-1

Thanks for moving the tests to the existing test system. It seems however the 
new test is not being run in jenkins. Running it locally (make check) in my PC 
actually shows it's missing exec permission on the file (I don't know why 
jenkins doesn't fail). you need to +x it.

Also, I had to apply the following changes locally to have it working, please 
add them and re-submit. Once you have it working, also run:
cd selftest && ./cdf_test.py > cdf_test.ok
To have the expected output in a file, otherwise it's not checked.

diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
old mode 100644
new mode 100755
index ec970df..7ef65f9
--- a/selftest/cdf_test.py
+++ b/selftest/cdf_test.py
@@ -1,13 +1,13 @@
+#!/usr/bin/env python3
+import _prep
 from osmo_ms_driver import cdf
 from datetime import timedelta

-
 def print_fuzzy_compare(want, expe, len=3):
 want_str = str(want)[0:len]
 expe_str = str(expe)[0:len]
 print(want_str, expe_str, want_str == expe_str)

-
 def check_steps(a, steps, fun):
 print("Done", a.is_done())
 for step in steps:
@@ -39,7 +39,6 @@ def testImmediate():
 print("Done", a.is_done())
 print_fuzzy_compare(a.current_value(), 1.0)

-
 def testLinearWithDuration():
 print("Testing linear with duration")
 a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 5
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-07 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#5).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A selftest/cdf_test.py
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
3 files changed, 206 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/5

diff --git a/selftest/cdf_test.py b/selftest/cdf_test.py
new file mode 100644
index 000..ec970df
--- /dev/null
+++ b/selftest/cdf_test.py
@@ -0,0 +1,72 @@
+from osmo_ms_driver import cdf
+from datetime import timedelta
+
+
+def print_fuzzy_compare(want, expe, len=3):
+want_str = str(want)[0:len]
+expe_str = str(expe)[0:len]
+print(want_str, expe_str, want_str == expe_str)
+
+
+def check_steps(a, steps, fun):
+print("Done", a.is_done())
+for step in steps:
+# Verify we can step
+
+# Compare and step once
+fun(a, step)
+if a.is_done():
+break
+a.step_once()
+print("Done", a.is_done())
+
+def compare_value(a, step):
+print_fuzzy_compare(a.current_value(), step)
+
+def compare_scaled_value(a, val):
+(step, scale) = val
+print_fuzzy_compare(a.current_value(), step)
+print_fuzzy_compare(a.current_scaled_value(), scale)
+
+def compare_x_value(a, val):
+(x, step) = val
+print(a._x, x, x == a._x)
+print_fuzzy_compare(a.current_value(), step)
+
+def testImmediate():
+print("Testing the immediate CDF")
+a = cdf.immediate()
+print("Done", a.is_done())
+print_fuzzy_compare(a.current_value(), 1.0)
+
+
+def testLinearWithDuration():
+print("Testing linear with duration")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
+check_steps(a, steps, compare_value)
+
+print("Testing linear with duration scaled")
+a = cdf.linear_with_duration(timedelta(seconds=10), 
step_size=timedelta(seconds=2))
+a.set_target(1000)
+steps = [(0.0, 0.0), (0.2, 200), (0.4, 400), (0.6, 600), (0.8, 800), (1.0, 
1)]
+check_steps(a, steps, compare_scaled_value)
+
+def testInOut():
+print("Testing in_out")
+print_fuzzy_compare(cdf._in_out(0.5), 0.5, 3)
+print_fuzzy_compare(cdf._in_out(0.75), 0.875, 4)
+print_fuzzy_compare(cdf._in_out(0.8), 0.92, 3)
+print_fuzzy_compare(cdf._in_out(0.85), 0.955, 4)
+print_fuzzy_compare(cdf._in_out(1.0), 1.0, 3)
+
+def testEaseInOutDuration():
+print("Testing ease In and Out")
+a = cdf.ease_in_out_duration(duration=timedelta(seconds=20), 
step_size=timedelta(seconds=5))
+steps = [(0.0, 0.0), (5.0, 0.125), (10.0, 0.5), (15.0, 0.875), (20, 1.0)]
+check_steps(a, steps, compare_x_value)
+
+testImmediate()
+testLinearWithDuration()
+testInOut()
+testEaseInOutDuration()
diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+__version__ = 'UNKNOWN'
+
+try:
+from ._version import _version
+__version__ = _version
+except:
+pass
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
new file mode 100644
index 000..781349b
--- /dev/null
+++ b/src/osmo_ms_driver/cdf.py
@@ -0,0 +1,105 @@
+# osmo_ms_driver: A cumululative distribution function class.
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-03-05 Thread Pau Espin Pedrol

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-26 Thread Pau Espin Pedrol

Patch Set 4: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-26 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#4).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
2 files changed, 252 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/4

diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+__version__ = 'UNKNOWN'
+
+try:
+from ._version import _version
+__version__ = _version
+except:
+pass
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
new file mode 100644
index 000..d5809e1
--- /dev/null
+++ b/src/osmo_ms_driver/cdf.py
@@ -0,0 +1,223 @@
+# osmo_ms_driver: A cumululative distribution function class.
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+
+from datetime import timedelta
+
+class DistributionFunctionHandler(object):
+"""
+The goal is to start n "mobile" processes. We like to see some
+conflicts (RACH bursts being ignored) but starting n processes
+at the same time is not a realistic model.
+We use the concept of cumulative distribution function here. On
+the x-axis we have time (maybe in steps of 10ms) and on the
+y-axis we have the percentage (from 0.0 to 1.0) of how many
+processes should run at the given time.
+"""
+
+def __init__(self, step, duration, fun):
+self._step = step
+self._fun = fun
+self._x = 0.0
+self._y = self._fun(self._x)
+self._target = 1.0
+self._duration = duration
+
+def step_size(self):
+return self._step
+
+def set_target(self, scale):
+"""
+Scale the percentage to the target value..
+"""
+self._target = scale
+
+def is_done(self):
+return self._y >= 1.0
+
+def current_value(self):
+return self._y
+
+def current_scaled_value(self):
+return self._y * self._target
+
+def step_once(self):
+self._x = self._x + self._step.total_seconds()
+self._y = self._fun(self._x)
+
+def duration(self):
+return self._duration
+
+
+def immediate(step_size=timedelta(milliseconds=20)):
+"""
+Reaches 100% at the first step.
+
+Example:
+>>> a = immediate()
+>>> a.is_done()
+True
+>>> a.current_value()
+1
+"""
+duration = timedelta(seconds=0)
+return DistributionFunctionHandler(step_size, duration, lambda x: 1)
+
+def linear_with_slope(slope, duration, step_size=timedelta(milliseconds=20)):
+"""
+Use the slope and step size you want
+"""
+return DistributionFunctionHandler(step_size, duration, lambda x: slope*x)
+
+def 

osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-26 Thread Pau Espin Pedrol

Patch Set 3:

(1 comment)

https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/cdf.py
File src/osmo_ms_driver/cdf.py:

Line 89: Linear progression that reaches 100% after duration.total_seconds()
> As a follow-up please. What is the reasoning for it? What is the concern ag
I'm not against it, I'm just saying that since you already basially wrote a 
list of tests on how it should behave, it would be nice to integrate it into 
selftest. It's fine if you do it as a follow-up.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-26 Thread Holger Freyther

Patch Set 3:

(3 comments)

https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/__init__.py
File src/osmo_ms_driver/__init__.py:

Line 5: # Authors: D. Lazlo Sitzer 
> Better use your name here as this subdir is all from you?
That's not how copyright works but you have an expert in your proximity but I 
doubt that this file can be copyrighted at all.


https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/cdf.py
File src/osmo_ms_driver/cdf.py:

Line 65: 
> ws
Done


Line 89: Linear progression that reaches 100% after duration.total_seconds()
> it would make a lot of sense to move this to selftest directory with its ow
As a follow-up please. What is the reasoning for it? What is the concern 
against doctest?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-25 Thread Pau Espin Pedrol

Patch Set 3: Code-Review-1

(3 comments)

https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/__init__.py
File src/osmo_ms_driver/__init__.py:

Line 5: # Authors: D. Lazlo Sitzer 
Better use your name here as this subdir is all from you?


https://gerrit.osmocom.org/#/c/6230/3/src/osmo_ms_driver/cdf.py
File src/osmo_ms_driver/cdf.py:

Line 65: 
ws


Line 89: Linear progression that reaches 100% after duration.total_seconds()
it would make a lot of sense to move this to selftest directory with its own 
testsuite. You can do it in nexts commits it it's easier for you.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-25 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#3).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
2 files changed, 252 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/3

diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+__version__ = 'UNKNOWN'
+
+try:
+from ._version import _version
+__version__ = _version
+except:
+pass
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
new file mode 100644
index 000..067b62e
--- /dev/null
+++ b/src/osmo_ms_driver/cdf.py
@@ -0,0 +1,223 @@
+# osmo_ms_driver: A cumululative distribution function class.
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+
+from datetime import timedelta
+
+class DistributionFunctionHandler(object):
+"""
+The goal is to start n "mobile" processes. We like to see some
+conflicts (RACH bursts being ignored) but starting n processes
+at the same time is not a realistic model.
+We use the concept of cumulative distribution function here. On
+the x-axis we have time (maybe in steps of 10ms) and on the
+y-axis we have the percentage (from 0.0 to 1.0) of how many
+processes should run at the given time.
+"""
+
+def __init__(self, step, duration, fun):
+self._step = step
+self._fun = fun
+self._x = 0.0
+self._y = self._fun(self._x)
+self._target = 1.0
+self._duration = duration
+
+def step_size(self):
+return self._step
+
+def set_target(self, scale):
+"""
+Scale the percentage to the target value..
+"""
+self._target = scale
+
+def is_done(self):
+return self._y >= 1.0
+
+def current_value(self):
+return self._y
+
+def current_scaled_value(self):
+return self._y * self._target
+
+def step_once(self):
+self._x = self._x + self._step.total_seconds()
+self._y = self._fun(self._x)
+
+def duration(self):
+return self._duration
+
+
+def immediate(step_size=timedelta(milliseconds=20)):
+"""
+Reaches 100% at the first step.
+
+Example:
+>>> a = immediate()
+>>> a.is_done()
+True
+>>> a.current_value()
+1
+"""
+duration = timedelta(seconds=0)
+return DistributionFunctionHandler(step_size, duration, lambda x: 1)
+
+def linear_with_slope(slope, duration, step_size=timedelta(milliseconds=20)):
+"""
+Use the slope and step size you want
+"""
+return DistributionFunctionHandler(step_size, duration, lambda x: slope*x)
+
+def 

[PATCH] osmo-gsm-tester[master]: ms: Create a cumulative distribution function class

2018-02-25 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6230

to look at the new patch set (#2).

ms: Create a cumulative distribution function class

We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
---
A src/osmo_ms_driver/__init__.py
A src/osmo_ms_driver/cdf.py
2 files changed, 252 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/30/6230/2

diff --git a/src/osmo_ms_driver/__init__.py b/src/osmo_ms_driver/__init__.py
new file mode 100644
index 000..d3c1590
--- /dev/null
+++ b/src/osmo_ms_driver/__init__.py
@@ -0,0 +1,29 @@
+# osmo_gsm_tester: automated cellular network hardware tests
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Authors: D. Lazlo Sitzer 
+#  Neels Hofmeyr 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+__version__ = 'UNKNOWN'
+
+try:
+from ._version import _version
+__version__ = _version
+except:
+pass
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
new file mode 100644
index 000..3a6faa3
--- /dev/null
+++ b/src/osmo_ms_driver/cdf.py
@@ -0,0 +1,223 @@
+# osmo_ms_driver: A cumululative distribution function class.
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+
+from datetime import timedelta
+
+class DistributionFunctionHandler(object):
+"""
+The goal is to start n "mobile" processes. We like to see some
+conflicts (RACH bursts being ignored) but starting n processes
+at the same time is not a realistic model.
+We use the concept of cumulative distribution function here. On
+the x-axis we have time (maybe in steps of 10ms) and on the
+y-axis we have the percentage (from 0.0 to 1.0) of how many
+processes should run at the given time.
+"""
+
+def __init__(self, step, duration, fun):
+self._step = step
+self._fun = fun
+self._x = 0.0
+self._y = self._fun(self._x)
+self._target = 1.0
+self._duration = duration
+
+def step_size(self):
+return self._step
+
+def set_target(self, scale):
+"""
+Scale the percentage to the target value..
+"""
+self._target = scale
+
+def is_done(self):
+return self._y >= 1.0
+
+def current_value(self):
+return self._y
+
+def current_scaled_value(self):
+return self._y * self._target
+
+def step_once(self):
+self._x = self._x + self._step.total_seconds()
+self._y = self._fun(self._x)
+
+def duration(self):
+return self._duration
+
+
+def immediate(step_size=timedelta(milliseconds=20)):
+"""
+Reaches 100% at the first step.
+
+Example:
+>>> a = immediate()
+>>> a.is_done()
+True
+>>> a.current_value()
+1
+"""
+duration = timedelta(seconds=0)
+return DistributionFunctionHandler(step_size, duration, lambda x: 1)
+
+def linear_with_slope(slope, duration, step_size=timedelta(milliseconds=20)):
+"""
+Use the slope and step size you want
+"""
+return DistributionFunctionHandler(step_size, duration, lambda x: slope*x)
+
+def