summaryrefslogtreecommitdiffstats
path: root/docker/storperf-master/tests/utilities_tests
diff options
context:
space:
mode:
authormbeierl <mark.beierl@dell.com>2017-07-11 15:12:35 -0400
committermbeierl <mark.beierl@dell.com>2017-07-11 15:47:46 -0400
commit7602a54309adbe5c5346ee6befecc2e596976504 (patch)
tree60f15026780db30b0b8842ba1a1e2cc021e22625 /docker/storperf-master/tests/utilities_tests
parentfc09b37e95c19f820ec60db19d98c0dc3d670829 (diff)
Change all paths
Changes the paths of all source code so that it exists under the dockerfile location for each container. This way we can use COPY instead of git clone, as well as use the existing JJB. Change-Id: I883b2957d89659c164fff0a1ebc4d677c534796d JIRA: STORPERF-188 Signed-off-by: mbeierl <mark.beierl@dell.com>
Diffstat (limited to 'docker/storperf-master/tests/utilities_tests')
-rw-r--r--docker/storperf-master/tests/utilities_tests/__init__.py11
-rw-r--r--docker/storperf-master/tests/utilities_tests/data_handler_test.py297
-rw-r--r--docker/storperf-master/tests/utilities_tests/data_treatment_test.py81
-rw-r--r--docker/storperf-master/tests/utilities_tests/dictionary_test.py42
-rw-r--r--docker/storperf-master/tests/utilities_tests/math_average_test.py52
-rw-r--r--docker/storperf-master/tests/utilities_tests/math_range_test.py120
-rw-r--r--docker/storperf-master/tests/utilities_tests/math_slope_test.py72
-rw-r--r--docker/storperf-master/tests/utilities_tests/steady_state_test.py65
-rw-r--r--docker/storperf-master/tests/utilities_tests/thread_gate_test.py57
9 files changed, 797 insertions, 0 deletions
diff --git a/docker/storperf-master/tests/utilities_tests/__init__.py b/docker/storperf-master/tests/utilities_tests/__init__.py
new file mode 100644
index 0000000..6218fe3
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/__init__.py
@@ -0,0 +1,11 @@
+##############################################################################
+# Copyright (c) 2016 EMC 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 logging
+
+logging.basicConfig(level=logging.DEBUG)
diff --git a/docker/storperf-master/tests/utilities_tests/data_handler_test.py b/docker/storperf-master/tests/utilities_tests/data_handler_test.py
new file mode 100644
index 0000000..6d57b0d
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/data_handler_test.py
@@ -0,0 +1,297 @@
+##############################################################################
+# Copyright (c) 2016 EMC 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 os
+from storperf.utilities.data_handler import DataHandler
+import unittest
+
+import mock
+
+
+class MockGraphiteDB(object):
+
+ def __init__(self):
+ self.series = []
+
+ def fetch_series(self, job_id, timeframe):
+ return self.series
+
+
+class DataHandlerTest(unittest.TestCase):
+
+ def setUp(self):
+ self.event_listeners = set()
+ self.data_handler = DataHandler()
+ self._terminated = False
+ self.args = None
+ self.start_time = 0
+ self.steady_state_samples = 10
+ self.end_time = 1
+ self.metadata = {}
+ self.block_sizes = "1"
+ self.queue_depths = "1"
+ mock.job_id = "1"
+ self.job_db = mock
+ self.pushed = False
+ self.current_workload = None
+ self.db_results = None
+ pass
+
+ @property
+ def terminated(self):
+ return self._terminated
+
+ def push_results_to_db(self, *args):
+ self.pushed = True
+ self.db_results = args
+ results = {"href": "http://localhost/api/result/uuid-that-is-long"}
+ return results
+
+ def terminate(self):
+ self._terminated = True
+
+ def terminate_current_run(self):
+ self._terminated = True
+
+ @mock.patch("time.time")
+ @mock.patch.dict(os.environ, {'TEST_DB_URL': 'mock'})
+ @mock.patch("storperf.db.graphite_db.GraphiteDB.fetch_series")
+ def test_lookup_prior_data(self, mock_graphite_db, mock_time):
+ self._terminated = False
+ expected = [[1480455910, 205.345],
+ [1480455920, 201.59],
+ [1480455930, 205.76],
+ [1480455970, 215.655],
+ [1480455980, 214.16],
+ [1480455990, 213.57],
+ [1480456030, 219.37],
+ [1480456040, 219.28],
+ [1480456050, 217.75]]
+ mock_graphite_db.return_value = expected
+ mock_time.return_value = expected[-1][0] + 10
+
+ self.current_workload = ("%s.%s.queue-depth.%s.block-size.%s" %
+ ("job_id",
+ "rw",
+ 8,
+ 8192))
+
+ actual = self.data_handler._lookup_prior_data(self, 'read', 'iops')
+ self.assertEqual(expected, actual)
+
+ def test_short_sample(self):
+ series = [[1480455910, 205.345],
+ [1480455920, 201.59],
+ [1480455930, 205.76],
+ [1480455970, 215.655],
+ [1480455980, 214.16],
+ [1480455990, 213.57],
+ [1480456030, 219.37],
+ [1480456040, 219.28],
+ [1480456050, 217.75]]
+
+ actual = self.data_handler._evaluate_prior_data(
+ series, self.steady_state_samples)
+ self.assertEqual(False, actual)
+
+ def test_long_not_steady_sample(self):
+ series = [[4804559100, 205345],
+ [4804559200, 20159],
+ [4804559300, 20576],
+ [4804560300, 21937],
+ [4804560400, 21928],
+ [4804560500, 21775]]
+ actual = self.data_handler._evaluate_prior_data(
+ series, self.steady_state_samples)
+ self.assertEqual(False, actual)
+
+ def test_long_steady_sample(self):
+ series = [[4804559100, 205.345],
+ [4804559200, 201.59],
+ [4804559300, 205.76],
+ [4804559400, 205.76],
+ [4804559500, 205.76],
+ [4804559600, 205.76],
+ [4804559700, 205.76],
+ [4804560300, 219.37],
+ [4804560400, 219.28],
+ [4804560500, 217.75]]
+ actual = self.data_handler._evaluate_prior_data(
+ series, self.steady_state_samples)
+ self.assertEqual(True, actual)
+
+ @mock.patch.dict(os.environ, {'TEST_DB_URL': 'mock'})
+ @mock.patch("storperf.db.test_results_db.push_results_to_db")
+ @mock.patch("storperf.utilities.data_handler.GraphiteDB")
+ def test_terminated_report(self, mock_graphite_db, mock_results_db):
+ self._terminated = True
+ mock_results_db.side_effect = self.push_results_to_db
+ mock_graphite_db.side_effect = MockGraphiteDB
+ self.metadata = {
+ "steady_state": {
+ "rr.queue-depth.8.block-size.16384": True,
+ "rr.queue-depth.8.block-size.2048": False,
+ "rr.queue-depth.8.block-size.8192": True,
+ },
+ }
+
+ self.data_handler.data_event(self)
+ self.assertEqual(True, self.pushed)
+
+ @mock.patch.dict(os.environ, {'TEST_DB_URL': 'mock'})
+ @mock.patch("time.time")
+ @mock.patch("storperf.db.test_results_db.push_results_to_db")
+ @mock.patch("storperf.db.graphite_db.GraphiteDB.fetch_series")
+ @mock.patch("storperf.db.graphite_db.JobDB.fetch_workloads")
+ def test_non_terminated_report(self, mock_job_db, mock_graphite_db,
+ mock_results_db, mock_time):
+ self._terminated = False
+ mock_results_db.side_effect = self.push_results_to_db
+ series = \
+ [[1480455910, 205.345],
+ [1480455920, 201.59],
+ [1480455930, 205.76],
+ [1480455970, 215.655],
+ [1480455980, 214.16],
+ [1480455990, 213.57],
+ [1480456030, 219.37],
+ [1480456040, 219.28],
+ [1480456050, 217.75]]
+ mock_graphite_db.return_value = series
+ mock_time.return_value = series[-1][0] + 10
+ expected_slope = 12.292030334472656
+ expected_range = 17.78
+ expected_average = 212.49777777777774
+
+ self.current_workload = ("%s.%s.queue-depth.%s.block-size.%s" %
+ ("job_id",
+ "rw",
+ 8,
+ 8192))
+
+ mock_job_db.return_value = [[self.current_workload, 4804559000, None]]
+
+ self.data_handler.data_event(self)
+ self.assertEqual(False, self.pushed)
+ self.assertEqual(False, self._terminated)
+
+ self.assertEqual(expected_slope, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['slope'])
+ self.assertEqual(expected_range, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['range'])
+ self.assertEqual(expected_average, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['average'])
+
+ @mock.patch.dict(os.environ, {'TEST_DB_URL': 'mock'})
+ @mock.patch("time.time")
+ @mock.patch("storperf.db.test_results_db.push_results_to_db")
+ @mock.patch("storperf.db.graphite_db.GraphiteDB.fetch_series")
+ @mock.patch("storperf.db.graphite_db.JobDB.fetch_workloads")
+ def test_report_that_causes_termination(self,
+ mock_job_db,
+ mock_graphite_db,
+ mock_results_db,
+ mock_time):
+ self._terminated = False
+ mock_results_db.side_effect = self.push_results_to_db
+ series = [[4804559100, 205.345],
+ [4804559200, 201.59],
+ [4804559300, 205.76],
+ [4804559400, 205.76],
+ [4804559500, 205.76],
+ [4804559600, 205.76],
+ [4804559700, 205.76],
+ [4804560300, 219.37],
+ [4804560400, 219.28],
+ [4804560500, 217.75]]
+ report_data = [[2, 205.345],
+ [3, 201.59],
+ [5, 205.76],
+ [7, 205.76],
+ [8, 205.76],
+ [10, 205.76],
+ [12, 205.76],
+ [22, 219.37],
+ [23, 219.28],
+ [25, 217.75]]
+ mock_graphite_db.return_value = series
+ mock_time.return_value = 4804560500 + 10
+
+ expected_slope = 0.7419522662249607
+ expected_range = 17.78
+ expected_average = 209.2135
+
+ self.current_workload = ("%s.%s.queue-depth.%s.block-size.%s" %
+ ("job_id",
+ "rw",
+ 8,
+ 8192))
+
+ mock_job_db.return_value = [[self.current_workload, 4804559000, None]]
+
+ self.data_handler.data_event(self)
+
+ self.assertEqual(expected_slope, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['slope'])
+ self.assertEqual(expected_range, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['range'])
+ self.assertEqual(expected_average, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['average'])
+ self.assertEqual(report_data, self.metadata['report_data']
+ ['rw.queue-depth.8.block-size.8192']
+ ['lat.mean']
+ ['read']
+ ['series'])
+ self.assertEqual(True, self._terminated)
+
+ self.assertEqual(False, self.pushed)
+
+ @mock.patch.dict(os.environ, {'TEST_DB_URL': 'mock'})
+ @mock.patch("storperf.db.test_results_db.push_results_to_db")
+ def test_playload_report(self,
+ mock_results_db):
+ mock_results_db.side_effect = self.push_results_to_db
+ self.start_time = 1504559100
+ self.end_time = 1504560000
+ self.metadata = {
+ "scenario_name": "ceph_ws,wr,rs,rr,rw",
+ "status": "OK",
+ "steady_state": {
+ "rr.queue-depth.8.block-size.16384": True,
+ "rr.queue-depth.8.block-size.2048": False,
+ "rr.queue-depth.8.block-size.8192": True,
+ },
+ "storage_node_count": 5,
+ "volume_size": 10
+ }
+ self.data_handler._push_to_db(self)
+ self.assertEqual('FAIL', self.db_results[9],
+ 'Expected FAIL in criteria')
+ self.assertEqual('2017-09-04 21:05:00', self.db_results[3],
+ 'Start time')
+ self.assertEqual('2017-09-04 21:20:00', self.db_results[4],
+ 'End time')
diff --git a/docker/storperf-master/tests/utilities_tests/data_treatment_test.py b/docker/storperf-master/tests/utilities_tests/data_treatment_test.py
new file mode 100644
index 0000000..4450f92
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/data_treatment_test.py
@@ -0,0 +1,81 @@
+##############################################################################
+# 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 data_treatment as DataTreatment
+
+
+class DataTreatmentTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ def test_empty_series(self):
+ expected = {
+ 'slope_data': [],
+ 'range_data': [],
+ 'average_data': []
+ }
+ data_series = []
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_integer_series(self):
+ expected = {
+ 'slope_data': [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]],
+ 'range_data': [5, 2, 98, 669, 66],
+ 'average_data': [5, 2, 98, 669, 66]
+ }
+ data_series = [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series(self):
+ expected = {
+ 'slope_data': [[5.6, 12.7], [96.66, 78.212],
+ [639.568, 5.3], [4.65, 6.667]],
+ 'range_data': [12.7, 78.212, 5.3, 6.667],
+ 'average_data': [12.7, 78.212, 5.3, 6.667]
+ }
+ data_series = [
+ [5.6, 12.7], [96.66, 78.212], [639.568, 5.3], [4.65, 6.667]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_int_mix(self):
+ expected = {
+ 'slope_data': [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]],
+ 'range_data': [12.7, 7, 5.3, 6],
+ 'average_data': [12.7, 7, 5.3, 6]
+ }
+ data_series = [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_negative_values(self):
+ expected = {
+ 'slope_data': [[-15, 5.56], [41.3, -278], [41.3, -98],
+ [78.336, -0.12], [33.667, 66]],
+ 'range_data': [5.56, -278, -98, -0.12, 66],
+ 'average_data': [5.56, -278, -98, -0.12, 66]
+ }
+ data_series = [
+ [-15, 5.56], [41.3, -278], [41.3, -98],
+ [78.336, -0.12], [33.667, 66]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_single_value(self):
+ expected = {
+ 'slope_data': [[86.8, 65.36]],
+ 'range_data': [65.36],
+ 'average_data': [65.36]
+ }
+ data_series = [[86.8, 65.36]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/dictionary_test.py b/docker/storperf-master/tests/utilities_tests/dictionary_test.py
new file mode 100644
index 0000000..0819cef
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/dictionary_test.py
@@ -0,0 +1,42 @@
+##############################################################################
+# Copyright (c) 2016 EMC 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 dictionary
+
+
+class DictionaryTest(unittest.TestCase):
+
+ def setUp(self):
+ self.dictionary = {}
+ self.dictionary['key'] = 'value'
+ pass
+
+ def test_get_no_default(self):
+ expected = None
+ actual = dictionary.get_key_from_dict(self.dictionary, 'no-key')
+ self.assertEqual(expected, actual)
+
+ def test_get_with_default(self):
+ expected = 'value 2'
+ actual = dictionary.get_key_from_dict(
+ self.dictionary, 'no-key', expected)
+ self.assertEqual(expected, actual)
+
+ def test_get_with_value(self):
+ expected = 'value'
+ actual = dictionary.get_key_from_dict(
+ self.dictionary, 'key')
+ self.assertEqual(expected, actual)
+
+ def test_get_with_value_and_default(self):
+ expected = 'value'
+ actual = dictionary.get_key_from_dict(
+ self.dictionary, 'key', 'value 2')
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/math_average_test.py b/docker/storperf-master/tests/utilities_tests/math_average_test.py
new file mode 100644
index 0000000..3095f56
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/math_average_test.py
@@ -0,0 +1,52 @@
+##############################################################################
+# 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 as math
+
+
+class MathAverageTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ def test_empty_series(self):
+ expected = None
+ data_series = []
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_integer_series(self):
+ expected = 19.75
+ data_series = [5, 12, 7, 55]
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series(self):
+ expected = 63.475899999999996
+ data_series = [78.6, 45.187, 33.334, 96.7826]
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_int_mix(self):
+ expected = 472.104
+ data_series = [10, 557.33, 862, 56.99, 874.2]
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_negative_values(self):
+ expected = -17.314
+ data_series = [-15.654, 59.5, 16.25, -150, 3.334]
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_single_value(self):
+ expected = -66.6667
+ data_series = [-66.6667]
+ actual = math.average(data_series)
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/math_range_test.py b/docker/storperf-master/tests/utilities_tests/math_range_test.py
new file mode 100644
index 0000000..90519e7
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/math_range_test.py
@@ -0,0 +1,120 @@
+##############################################################################
+# 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
+##############################################################################
+from random import uniform, randrange
+import unittest
+
+from storperf.utilities import math as Range
+
+
+class MathRangeTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ def test_empty_series(self):
+ expected = None
+ data_series = []
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_integer_series(self):
+ expected = 11946
+ data_series = [5, 351, 847, 2, 1985, 18,
+ 96, 389, 687, 1, 11947, 758, 155]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_1_decimal(self):
+ expected = 778595.5
+ data_series = [736.4, 9856.4, 684.2, 0.3, 0.9, 778595.8]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_2_decimals(self):
+ expected = 5693.47
+ data_series = [51.36, 78.40, 1158.24, 5.50, 0.98, 5694.45]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_3_decimals(self):
+ expected = 992.181
+ data_series = [4.562, 12.582, 689.452,
+ 135.162, 996.743, 65.549, 36.785]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_4_decimals(self):
+ expected = 122985.3241
+ data_series = [39.4785, 896.7845, 11956.3654,
+ 44.2398, 6589.7134, 0.3671, 122985.6912]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_5_decimals(self):
+ expected = 8956208.84494
+ data_series = [12.78496, 55.91275, 668.94378,
+ 550396.5671, 512374.9999, 8956221.6299]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series_10_decimals(self):
+ expected = 5984.507397972699
+ data_series = [1.1253914785, 5985.6327894512,
+ 256.1875693287, 995.8497623415]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_mix(self):
+ expected = 60781.6245372199
+ data_series = [60785.9962, 899.4, 78.66, 69.58, 4.93795,
+ 587.195486, 96.7694536, 5.13755964,
+ 33.333333334, 60786.5624872199]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_integer_mix(self):
+ expected = 460781.05825
+ data_series = [460785.9962, 845.634, 24.1, 69.58, 89, 4.93795]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_negative_values(self):
+ expected = 596.78163
+ data_series = [-4.655, -33.3334, -596.78422, -0.00259, -66.785]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_negative_positive_mix(self):
+ expected = 58.859500000000004
+ data_series = [6.85698, -2.8945, 0, -0.15, 55.965]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_single_element(self):
+ expected = 0
+ data_series = [2.265]
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_10000_values_processing(self):
+ expected = 28001.068
+ data_series = [uniform(-10000, 10000) for _ in range(10000)]
+ data_series.insert(randrange(len(data_series)), 15000.569)
+ data_series.insert(randrange(len(data_series)), -13000.499)
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_processing_100_values_100_times(self):
+ expected = 35911.3134
+ for _ in range(1, 100):
+ data_series = [uniform(-10000, 10000) for _ in range(100)]
+ data_series.insert(randrange(len(data_series)), 16956.3334)
+ data_series.insert(randrange(len(data_series)), -18954.98)
+ actual = Range.range_value(data_series)
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/math_slope_test.py b/docker/storperf-master/tests/utilities_tests/math_slope_test.py
new file mode 100644
index 0000000..24d5cd7
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/math_slope_test.py
@@ -0,0 +1,72 @@
+##############################################################################
+# 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 as Slope
+
+
+class MathSlopeTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+ pass
+
+ def test_slope_empty_series(self):
+ expected = None
+ actual = Slope.slope([])
+ self.assertEqual(expected, actual)
+
+ def test_slope_integer_series(self):
+ expected = 1.4
+ actual = Slope.slope([[1, 6], [2, 5], [3, 7], [4, 10]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_decimal_series(self):
+ expected = 1.4
+ actual = Slope.slope([[1.0, 6.0], [2.0, 5.0], [3.0, 7.0], [4.0, 10.0]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_decimal_integer_mix(self):
+ expected = 1.4
+ actual = Slope.slope([[1.0, 6], [2, 5.0], [3, 7], [4.0, 10]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_negative_y_series(self):
+ expected = 2
+ actual = Slope.slope([[1.0, -2], [2, 2], [3, 2]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_negative_x_series(self):
+ expected = 1.4
+ actual = Slope.slope([[-24, 6.0], [-23, 5], [-22, 7.0], [-21, 10]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_out_of_order_series(self):
+ expected = 1.4
+ actual = Slope.slope([[2, 5.0], [4, 10], [3.0, 7], [1, 6]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_0_in_y(self):
+ expected = -0.5
+ actual = Slope.slope([[15.5, 1], [16.5, 0], [17.5, 0]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_0_in_x(self):
+ expected = 1.4
+ actual = Slope.slope([[0, 6.0], [1, 5], [2, 7], [3, 10]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_0_in_x_and_y(self):
+ expected = 1.5
+ actual = Slope.slope([[0.0, 0], [1, 1], [2, 3]])
+ self.assertEqual(expected, actual)
+
+ def test_infinte_slope(self):
+ expected = None
+ actual = Slope.slope([[1480623510, 1295.87], [1480623520, 1380.79]])
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/steady_state_test.py b/docker/storperf-master/tests/utilities_tests/steady_state_test.py
new file mode 100644
index 0000000..564c090
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/steady_state_test.py
@@ -0,0 +1,65 @@
+##############################################################################
+# 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)
+
+ def test_negative_slope(self):
+ expected = False
+ data_series = [[1.3, 1], [1.2, 1], [1.1, 1.1], [1.0, 1.1]]
+ actual = SteadyState.steady_state(data_series)
+ self.assertEqual(expected, actual)
diff --git a/docker/storperf-master/tests/utilities_tests/thread_gate_test.py b/docker/storperf-master/tests/utilities_tests/thread_gate_test.py
new file mode 100644
index 0000000..de8b15a
--- /dev/null
+++ b/docker/storperf-master/tests/utilities_tests/thread_gate_test.py
@@ -0,0 +1,57 @@
+##############################################################################
+# Copyright (c) 2016 EMC 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 time
+import unittest
+
+from storperf.utilities.thread_gate import FailureToReportException
+from storperf.utilities.thread_gate import ThreadGate
+
+
+class ThreadGateTest(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_one_one_report(self):
+ gate = ThreadGate(1)
+ self.assertEqual(True, gate.report(1))
+
+ def test_two_one_report(self):
+ gate = ThreadGate(2)
+ self.assertEqual(False, gate.report(1))
+
+ def test_two_two_reports(self):
+ gate = ThreadGate(2)
+ self.assertEqual(False, gate.report(1))
+ self.assertEqual(True, gate.report(2))
+
+ def test_two_one_duplicate_reports(self):
+ gate = ThreadGate(2)
+ self.assertEqual(False, gate.report(1))
+ self.assertEqual(False, gate.report(1))
+ self.assertEqual(True, gate.report(2))
+
+ def test_two_old_old_report(self):
+ timeout = 5
+ gate = ThreadGate(2, timeout)
+ report_time = time.time() - (timeout * 2)
+ gate._registrants[2] = report_time
+ self.assertEqual(False, gate.report(1))
+
+ def test_two_never_report(self):
+ timeout = 5
+ gate = ThreadGate(2, timeout)
+ report_time = time.time() - (timeout * 3)
+ gate._creation_time = report_time
+ try:
+ gate.report(1)
+ self.fail()
+ except FailureToReportException:
+ pass