From aa20b986cebf031489f4280988b4574a9acbc647 Mon Sep 17 00:00:00 2001 From: Tim Rault Date: Fri, 15 Jul 2016 16:32:51 -0400 Subject: Add Steady State Detection module Added a Steady State Detection module containing a steady_state(data_series) function that is able to return a boolean indicating wether or not steady state is reached with the data_series being passed. This module requires a data_treatment(data_series) and an average(data_series) modules that have been added in this commit as well. The data treatment function aims at formatting the data series that is passed to the high level steady_state function to reach the requirement of each sub-module (slope, average and range). Modified the Slope and Range functions so they return None when passed an empty data series instead of 0 which was wrong. Modified the corresponding test cases. Modified the math_range_test.py file to fix a bug in the 2 last tests. Change-Id: I9c3854cb0a21cc37b0787b8afca0821eefaa203d JIRA: STORPERF-60 JIRA: STORPERF-59 JIRA: STORPERF-61 JIRA: STORPERF-62 Signed-off-by: Tim Rault --- tests/utilities_tests/steady_state_test.py | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/utilities_tests/steady_state_test.py (limited to 'tests/utilities_tests/steady_state_test.py') diff --git a/tests/utilities_tests/steady_state_test.py b/tests/utilities_tests/steady_state_test.py new file mode 100644 index 0000000..d80c60d --- /dev/null +++ b/tests/utilities_tests/steady_state_test.py @@ -0,0 +1,59 @@ +############################################################################## +# 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 steady_state as SteadyState + + +class SteadyStateTest(unittest.TestCase): + + def setUp(self): + unittest.TestCase.setUp(self) + + def test_integer_values(self): + expected = True + data_series = [[305, 20], [306, 21], [307, 21], [308, 19]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_float_values(self): + expected = True + data_series = [ + [55.5, 40.5], [150.2, 42.3], [150.8, 41.8], [151.2, 41.5]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_float_integer_mix_false(self): + expected = False + data_series = [[1, 2], [2, 2.2], [3, 1.8], [4, 1.8]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_float_integer_mix_true(self): + expected = True + data_series = [[12, 18], [12.5, 18.2], [13, 16.8], [15, 16.8]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_empty_series(self): + expected = False + data_series = [] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_negative_values(self): + expected = True + data_series = [[-1, -24.2], [0.5, -23.8], [1.1, -24.0], [3.2, -24.0]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) + + def test_out_of_order_series(self): + expected = True + data_series = [[-15, 0.43], [-16, 0.41], [-3, 0.45], [4, 0.42]] + actual = SteadyState.steady_state(data_series) + self.assertEqual(expected, actual) -- cgit 1.2.3-korg