summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authormbeierl <mark.beierl@dell.com>2018-08-15 22:29:15 -0400
committermbeierl <mark.beierl@dell.com>2018-08-15 22:29:15 -0400
commit5930150915999fd410d7a2da38723065bcf7c91f (patch)
tree5f873ea28f34ccca381382397a3cfe83cbd01739 /docker
parent5051297e7294406453ac4ff2e14f35762a77b249 (diff)
Fixing Suprious Exception
When the results are too small to calculate the slope, an exception is reported in the logs. This change avoids triggering the exception criteria. Change-Id: Iae886cde6244e9077ff94812bd830c48adaef365 Signed-off-by: mbeierl <mark.beierl@dell.com>
Diffstat (limited to 'docker')
-rw-r--r--docker/storperf-master/storperf/utilities/math.py3
-rw-r--r--docker/storperf-master/tests/utilities_tests/math_slope_test.py5
2 files changed, 8 insertions, 0 deletions
diff --git a/docker/storperf-master/storperf/utilities/math.py b/docker/storperf-master/storperf/utilities/math.py
index 2e78c9d..601ae37 100644
--- a/docker/storperf-master/storperf/utilities/math.py
+++ b/docker/storperf-master/storperf/utilities/math.py
@@ -133,6 +133,9 @@ def slope_series(data_series):
avg = average(average_series)
slp = slope(data_series)
+ if slp is None or avg is None:
+ return new_series
+
multiplier = float(len(data_series) + 1) / 2.0 - len(data_series)
for index, _ in data_series:
new_value = avg + (slp * multiplier)
diff --git a/docker/storperf-master/tests/utilities_tests/math_slope_test.py b/docker/storperf-master/tests/utilities_tests/math_slope_test.py
index 24d5cd7..5c286ad 100644
--- a/docker/storperf-master/tests/utilities_tests/math_slope_test.py
+++ b/docker/storperf-master/tests/utilities_tests/math_slope_test.py
@@ -21,6 +21,11 @@ class MathSlopeTest(unittest.TestCase):
actual = Slope.slope([])
self.assertEqual(expected, actual)
+ def test_slope_one_series(self):
+ expected = None
+ actual = Slope.slope([[1, 0.0]])
+ self.assertEqual(expected, actual)
+
def test_slope_integer_series(self):
expected = 1.4
actual = Slope.slope([[1, 6], [2, 5], [3, 7], [4, 10]])