From 5051297e7294406453ac4ff2e14f35762a77b249 Mon Sep 17 00:00:00 2001 From: mbeierl Date: Thu, 2 Aug 2018 16:25:28 -0400 Subject: Calculate Data Series Adds the min, max and actual slope values to the final report metrics so that end users do not have to calculate these values. Change-Id: Ic98ec5cbfcdf7447d2bffc46e9bd05e087c72965 JIRA: STORPERF-257 Signed-off-by: mbeierl --- .../tests/utilities_tests/math_range_test.py | 22 ++++++++++ .../utilities_tests/math_slope_series_test.py | 48 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 docker/storperf-master/tests/utilities_tests/math_slope_series_test.py (limited to 'docker/storperf-master/tests/utilities_tests') diff --git a/docker/storperf-master/tests/utilities_tests/math_range_test.py b/docker/storperf-master/tests/utilities_tests/math_range_test.py index 90519e7..9208fb7 100644 --- a/docker/storperf-master/tests/utilities_tests/math_range_test.py +++ b/docker/storperf-master/tests/utilities_tests/math_range_test.py @@ -118,3 +118,25 @@ class MathRangeTest(unittest.TestCase): data_series.insert(randrange(len(data_series)), -18954.98) actual = Range.range_value(data_series) self.assertEqual(expected, actual) + + def test_min_series(self): + expected = [427.7333333333333, + 427.7333333333333, + 427.7333333333333, + 427.7333333333333, + 427.7333333333333, + 427.7333333333333] + data_series = [5, 351, 847, 2, 1985, 18] + actual = Range.min_series(data_series) + self.assertEqual(expected, actual) + + def test_max_series(self): + expected = [641.5999999999999, + 641.5999999999999, + 641.5999999999999, + 641.5999999999999, + 641.5999999999999, + 641.5999999999999] + data_series = [5, 351, 847, 2, 1985, 18] + actual = Range.max_series(data_series) + self.assertEqual(expected, actual) diff --git a/docker/storperf-master/tests/utilities_tests/math_slope_series_test.py b/docker/storperf-master/tests/utilities_tests/math_slope_series_test.py new file mode 100644 index 0000000..cfa6efe --- /dev/null +++ b/docker/storperf-master/tests/utilities_tests/math_slope_series_test.py @@ -0,0 +1,48 @@ +############################################################################## +# Copyright (c) 2016 CENGN and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +import unittest +from storperf.utilities import math + + +class MathSlopeSeriesTest(unittest.TestCase): + + def setUp(self): + unittest.TestCase.setUp(self) + pass + + def test_slope_empty_series(self): + expected = [] + actual = math.slope_series([]) + self.assertEqual(expected, actual) + + def test_slope_integer_series(self): + expected = [[1, 4.9], [2, 6.3], [3, 7.7], [4, 9.1]] + actual = math.slope_series([[1, 6], [2, 5], [3, 7], [4, 10]]) + self.assertEqual(expected, actual) + + def test_slope_mix_series(self): + expected = [[1, 4.9], [2, 6.3], [3, 7.7], [4, 9.1]] + actual = math.slope_series([[1.0, 6], [2, 5.0], [3, 7], [4.0, 10]]) + self.assertEqual(expected, actual) + + def test_slope_0_in_y(self): + expected = [ + [15.5, 0.8333333333333333], + [16.5, 0.3333333333333333], + [17.5, -0.16666666666666669]] + actual = math.slope_series([[15.5, 1], [16.5, 0], [17.5, 0]]) + self.assertEqual(expected, actual) + + def test_slope_gaps_in_x(self): + expected = [ + [1, 1.3571428571428572], + [2, 2.0], + [4, 2.642857142857143]] + actual = math.slope_series([[1, 1], [2, 2], [4, 3]]) + self.assertEqual(expected, actual) -- cgit 1.2.3-korg