summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py8
-rw-r--r--tests/carbon_tests/__init__.py8
-rw-r--r--tests/carbon_tests/emitter_test.py66
-rw-r--r--tests/carbon_tests/json_to_carbon_test.py116
-rw-r--r--tests/db_tests/__init__.py8
-rw-r--r--tests/db_tests/configuration_db_test.py66
-rw-r--r--tests/db_tests/graphite_db_test.py55
-rw-r--r--tests/db_tests/job_db_test.py192
-rw-r--r--tests/storperf_master_test.py69
-rw-r--r--tests/utilities_tests/__init__.py8
-rw-r--r--tests/utilities_tests/dictionary_test.py42
-rw-r--r--tests/utilities_tests/math_range_test.py120
-rw-r--r--tests/utilities_tests/math_slope_test.py67
-rw-r--r--tests/workload_tests/__init__.py8
-rw-r--r--tests/workload_tests/workload_subclass_test.py54
15 files changed, 887 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..73334c7
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/tests/carbon_tests/__init__.py b/tests/carbon_tests/__init__.py
new file mode 100644
index 0000000..73334c7
--- /dev/null
+++ b/tests/carbon_tests/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/tests/carbon_tests/emitter_test.py b/tests/carbon_tests/emitter_test.py
new file mode 100644
index 0000000..fe19ed2
--- /dev/null
+++ b/tests/carbon_tests/emitter_test.py
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+from storperf.carbon import converter
+from storperf.carbon.emitter import CarbonMetricTransmitter
+from time import sleep
+import SocketServer
+import json
+import threading
+import unittest
+
+
+class MetricsHandler(SocketServer.BaseRequestHandler):
+
+ def handle(self):
+ # Echo the back to the client
+ CarbonMetricTransmitterTest.response = self.request.recv(1024)
+ return
+
+
+class MetricsServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
+ pass
+
+
+class CarbonMetricTransmitterTest(unittest.TestCase):
+ listen_port = 0
+ response = None
+
+ def setUp(self):
+
+ address = ('localhost', 0)
+ server = MetricsServer(address, MetricsHandler)
+ ip, self.listen_port = server.server_address
+
+ t = threading.Thread(target=server.serve_forever)
+ t.setDaemon(True)
+ t.start()
+
+ def test_transmit_metrics(self):
+
+ testconv = converter.Converter()
+ json_object = json.loads("""{"timestamp" : "12345", "key":"value" }""")
+ result = testconv.convert_json_to_flat(json_object, "host.run-name")
+
+ emitter = CarbonMetricTransmitter()
+ emitter.carbon_port = self.listen_port
+ emitter.transmit_metrics(result)
+
+ count = 0
+
+ while (CarbonMetricTransmitterTest.response is None and count < 10):
+ count += 1
+ sleep(0.1)
+
+ self.assertEqual("host.run-name.key value 12345\n",
+ CarbonMetricTransmitterTest.response,
+ CarbonMetricTransmitterTest.response)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/carbon_tests/json_to_carbon_test.py b/tests/carbon_tests/json_to_carbon_test.py
new file mode 100644
index 0000000..523ff77
--- /dev/null
+++ b/tests/carbon_tests/json_to_carbon_test.py
@@ -0,0 +1,116 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+from storperf.carbon.converter import Converter
+import json
+import unittest
+
+
+class JSONToCarbonTest(unittest.TestCase):
+
+ single_json_text_element = """{ "key" : "value" }"""
+ single_json_numeric_element = """{ "key" : 123 }"""
+ single_json_key_with_spaces = """{ "key with spaces" : "value" }"""
+ single_json_value_with_spaces = """{ "key" : "value with spaces" }"""
+ json_map_name_with_spaces = \
+ """{ "map with spaces" : { "key" : "value" } }"""
+ json_list_name_with_spaces = \
+ """{ "list with spaces" : [{ "key" : "value" }] }"""
+
+ simple_fio_json = """
+{
+ "fio version" : "fio-2.2.10",
+ "timestamp" : 1444144664,
+ "time" : "Tue Oct 6 11:17:44 2015",
+ "jobs" : [
+ {
+ "jobname" : "random-read",
+ "groupid" : 0,
+ "error" : 0,
+ "eta" : 0,
+ "elapsed" : 26,
+ "read" : {
+ "io_bytes" : 7116,
+ "bw" : 275,
+ "iops" : 68.99,
+ "runtime" : 25788,
+ "total_ios" : 1779,
+ "short_ios" : 0,
+ "drop_ios" : 0,
+ "slat" : {
+ "min" : 0,
+ "max" : 0,
+ "mean" : 0.00,
+ "stddev" : 0.00
+ }
+ }
+ }]
+}
+"""
+
+ def setUp(self):
+ pass
+
+ def test_to_string(self):
+ testconv = Converter()
+ json_object = json.loads(self.simple_fio_json)
+ result = testconv.convert_json_to_flat(json_object, "host.run-name")
+ self.assertEqual("7116", result[
+ "host.run-name.jobs.1.read.io_bytes"],
+ result["host.run-name.jobs.1.read.io_bytes"])
+
+ def test_single_text_element_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.single_json_text_element))
+
+ self.assertEqual("value", result["key"], result["key"])
+
+ def test_single_numeric_element_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.single_json_numeric_element))
+
+ self.assertEqual("123", result["key"], result["key"])
+
+ def test_single_text_key_space_element_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.single_json_key_with_spaces))
+
+ self.assertEqual(
+ "value", result["key_with_spaces"], result["key_with_spaces"])
+
+ def test_single_text_value_space_element_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.single_json_value_with_spaces))
+
+ self.assertEqual("value_with_spaces", result["key"], result["key"])
+
+ def test_map_name_with_space_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.json_map_name_with_spaces))
+
+ self.assertEqual(
+ "value", result["map_with_spaces.key"],
+ result["map_with_spaces.key"])
+
+ def test_list_name_with_space_no_prefix(self):
+ testconv = Converter()
+ result = testconv.convert_json_to_flat(
+ json.loads(self.json_list_name_with_spaces))
+
+ self.assertEqual(
+ "value", result["list_with_spaces.1.key"],
+ result["list_with_spaces.1.key"])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/db_tests/__init__.py b/tests/db_tests/__init__.py
new file mode 100644
index 0000000..73334c7
--- /dev/null
+++ b/tests/db_tests/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/tests/db_tests/configuration_db_test.py b/tests/db_tests/configuration_db_test.py
new file mode 100644
index 0000000..e8b7188
--- /dev/null
+++ b/tests/db_tests/configuration_db_test.py
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+from storperf.db.configuration_db import ConfigurationDB
+import os
+import unittest
+
+
+class ConfigurationDBTest(unittest.TestCase):
+
+ def setUp(self):
+ ConfigurationDB.db_name = __name__ + ".db"
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
+
+ self.config_db = ConfigurationDB()
+
+ def test_create_key(self):
+ expected = "ABCDE-12345"
+
+ self.config_db.set_configuration_value(
+ "test", "key", expected)
+
+ actual = self.config_db.get_configuration_value(
+ "test", "key")
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_update_key(self):
+ expected = "ABCDE-12345"
+
+ self.config_db.set_configuration_value(
+ "test", "key", "initial_value")
+
+ self.config_db.set_configuration_value(
+ "test", "key", expected)
+
+ actual = self.config_db.get_configuration_value(
+ "test", "key")
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_deleted_key(self):
+ expected = None
+
+ self.config_db.set_configuration_value(
+ "test", "key", "initial_value")
+
+ self.config_db.delete_configuration_value(
+ "test", "key")
+
+ actual = self.config_db.get_configuration_value(
+ "test", "key")
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
diff --git a/tests/db_tests/graphite_db_test.py b/tests/db_tests/graphite_db_test.py
new file mode 100644
index 0000000..e13545b
--- /dev/null
+++ b/tests/db_tests/graphite_db_test.py
@@ -0,0 +1,55 @@
+##############################################################################
+# 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
+##############################################################################
+
+from storperf.db.graphite_db import GraphiteDB
+import unittest
+
+
+class GraphiteDBTest(unittest.TestCase):
+
+ def setUp(self):
+ self.graphdb = GraphiteDB()
+ self.graphdb._job_db = self
+
+ def test_wildcard_pattern(self):
+ workload = "job_id"
+ expected = "job_id.*.*.*.*.*.*"
+ actual = self.graphdb.make_fullname_pattern(workload)
+ self.assertEqual(expected, actual, actual)
+
+ def test_no_wildcard_pattern(self):
+ workload = "job_id.workload.host.queue-depth.1.block-size.16"
+ actual = self.graphdb.make_fullname_pattern(workload)
+ self.assertEqual(workload, actual, actual)
+
+ def test_fetch_averages(self):
+ # self.graphdb.fetch_averages(u'32d31724-fac1-44f3-9033-ca8e00066a36')
+ pass
+
+ def fetch_workloads(self, workload):
+ workloads = [[u'32d31724-fac1-44f3-9033-ca8e00066a36.'
+ u'_warm_up.queue-depth.32.block-size.8192.10-9-15-151',
+ u'1462379653', u'1462379893'],
+ [u'32d31724-fac1-44f3-9033-ca8e00066a36.'
+ u'_warm_up.queue-depth.32.block-size.8192.10-9-15-150',
+ u'1462379653', u'1462379898'],
+ [u'32d31724-fac1-44f3-9033-ca8e00066a36'
+ u'.rw.queue-depth.128.block-size.8192.10-9-15-151',
+ u'1462379898', u'1462380028'],
+ [u'32d31724-fac1-44f3-9033-ca8e00066a36'
+ u'.rw.queue-depth.128.block-size.8192.10-9-15-150',
+ u'1462379898', u'1462380032'],
+ [u'32d31724-fac1-44f3-9033-ca8e00066a36'
+ u'.rw.queue-depth.16.block-size.8192.10-9-15-151',
+ u'1462380032', u'1462380312'],
+ [u'32d31724-fac1-44f3-9033-ca8e00066a36'
+ u'.rw.queue-depth.16.block-size.8192.10-9-15-150',
+ u'1462380032', u'1462380329'],
+ ]
+ return workloads
diff --git a/tests/db_tests/job_db_test.py b/tests/db_tests/job_db_test.py
new file mode 100644
index 0000000..fe3d9f1
--- /dev/null
+++ b/tests/db_tests/job_db_test.py
@@ -0,0 +1,192 @@
+##############################################################################
+# 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
+##############################################################################
+
+from storperf.db.job_db import JobDB
+from storperf.workloads.rr import rr
+import os
+import sqlite3
+import unittest
+
+import mock
+
+
+class JobDBTest(unittest.TestCase):
+
+ def setUp(self):
+
+ JobDB.db_name = __name__ + '.db'
+ try:
+ os.remove(JobDB.db_name)
+ except OSError:
+ pass
+ self.job = JobDB()
+
+ @mock.patch("uuid.uuid4")
+ def test_create_job(self, mock_uuid):
+ expected = "ABCDE-12345"
+ mock_uuid.side_effect = (expected,)
+
+ self.job.create_job_id()
+
+ actual = self.job.job_id
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ @mock.patch("uuid.uuid4")
+ def test_duplicate_job_generated(self, mock_uuid):
+ duplicate = "EDCBA-12345"
+ expected = "EDCBA-54321"
+
+ mock_uuid.side_effect = (duplicate, duplicate, expected,)
+
+ self.job.create_job_id()
+ self.job.create_job_id()
+
+ actual = self.job.job_id
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ @mock.patch("uuid.uuid4")
+ @mock.patch("calendar.timegm")
+ def test_start_job(self, mock_calendar, mock_uuid):
+ job_id = "ABCDE-12345"
+ start_time = "12345"
+ mock_calendar.side_effect = (start_time,)
+ mock_uuid.side_effect = (job_id,)
+ workload = rr()
+
+ db = sqlite3.connect(JobDB.db_name)
+ cursor = db.cursor()
+
+ row = cursor.execute(
+ """select * from jobs
+ where job_id = ?
+ and workload = ?""",
+ (job_id, workload.fullname,))
+
+ self.assertEqual(None,
+ row.fetchone(),
+ "Should not have been a row in the db")
+
+ self.job.start_workload(workload)
+
+ cursor.execute(
+ """select job_id, workload, start from jobs
+ where job_id = ?
+ and workload = ?""",
+ (job_id, workload.fullname,))
+
+ row = cursor.fetchone()
+
+ self.assertNotEqual(None, row, "Should be a row in the db")
+ self.assertEqual(job_id, row[0], "Did not expect " + str(row[0]))
+ self.assertEqual(
+ workload.fullname, row[1], "Did not expect " + str(row[1]))
+ self.assertEqual(start_time, row[2], "Did not expect " + str(row[2]))
+
+ @mock.patch("uuid.uuid4")
+ @mock.patch("calendar.timegm")
+ def test_end_job(self, mock_calendar, mock_uuid):
+ job_id = "ABCDE-12345"
+ start_time = "12345"
+ end_time = "54321"
+ mock_calendar.side_effect = (start_time, end_time,)
+ mock_uuid.side_effect = (job_id,)
+ workload = rr()
+
+ self.job.start_workload(workload)
+ self.job.end_workload(workload)
+
+ db = sqlite3.connect(JobDB.db_name)
+ cursor = db.cursor()
+ cursor.execute(
+ """select job_id, workload, start, end from jobs
+ where job_id = ?
+ and workload = ?""",
+ (job_id, workload.fullname,))
+
+ row = cursor.fetchone()
+
+ self.assertNotEqual(None, row, "Should be a row in the db")
+ self.assertEqual(job_id, row[0], "Did not expect " + str(row[0]))
+ self.assertEqual(
+ workload.fullname, row[1], "Did not expect " + str(row[1]))
+ self.assertEqual(start_time, row[2], "Did not expect " + str(row[2]))
+ self.assertEqual(end_time, row[3], "Did not expect " + str(row[3]))
+
+ @mock.patch("uuid.uuid4")
+ @mock.patch("calendar.timegm")
+ def test_duplicate_start_job(self, mock_calendar, mock_uuid):
+ job_id = "ABCDE-12345"
+ start_time_1 = "12345"
+ start_time_2 = "12346"
+
+ mock_calendar.side_effect = (start_time_1, start_time_2)
+ mock_uuid.side_effect = (job_id,)
+ workload = rr()
+
+ db = sqlite3.connect(JobDB.db_name)
+ cursor = db.cursor()
+
+ self.job.start_workload(workload)
+ self.job.start_workload(workload)
+
+ cursor.execute(
+ """select job_id, workload, start from jobs
+ where job_id = ?
+ and workload = ?""",
+ (job_id, workload.fullname,))
+
+ row = cursor.fetchone()
+
+ self.assertNotEqual(None, row, "Should be a row in the db")
+ self.assertEqual(job_id, row[0], "Did not expect " + str(row[0]))
+ self.assertEqual(
+ workload.fullname, row[1], "Did not expect " + str(row[1]))
+ self.assertEqual(start_time_2, row[2], "Did not expect " + str(row[2]))
+
+ @mock.patch("uuid.uuid4")
+ @mock.patch("calendar.timegm")
+ def test_end_job_without_start(self, mock_calendar, mock_uuid):
+ job_id = "ABCDE-12345"
+ start_time = "12345"
+ end_time = "54321"
+ mock_calendar.side_effect = (start_time, end_time,)
+ mock_uuid.side_effect = (job_id,)
+ workload = rr()
+
+ self.job.end_workload(workload)
+
+ db = sqlite3.connect(JobDB.db_name)
+ cursor = db.cursor()
+ cursor.execute(
+ """select job_id, workload, start, end from jobs
+ where job_id = ?
+ and workload = ?""",
+ (job_id, workload.fullname,))
+
+ row = cursor.fetchone()
+
+ self.assertNotEqual(None, row, "Should be a row in the db")
+ self.assertEqual(job_id, row[0], "Did not expect " + str(row[0]))
+ self.assertEqual(
+ workload.fullname, row[1], "Did not expect " + str(row[1]))
+ # The start time is set to the same time as end if it was never set
+ # before
+ self.assertEqual(start_time, row[2], "Did not expect " + str(row[2]))
+ self.assertEqual(start_time, row[3], "Did not expect " + str(row[3]))
+
+ def test_job_params(self):
+ expected = {"a": "1", "b": "2"}
+ self.job.job_id = "ABCD"
+ self.job.record_workload_params(expected)
+ actual = self.job.fetch_workload_params(self.job.job_id)
+ self.assertEqual(expected, actual)
diff --git a/tests/storperf_master_test.py b/tests/storperf_master_test.py
new file mode 100644
index 0000000..2dc810d
--- /dev/null
+++ b/tests/storperf_master_test.py
@@ -0,0 +1,69 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+from storperf.db.configuration_db import ConfigurationDB
+from storperf.storperf_master import StorPerfMaster
+import os
+import unittest
+
+
+class StorPerfMasterTest(unittest.TestCase):
+
+ def setUp(self):
+ ConfigurationDB.db_name = __name__ + ".db"
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
+ self.storperf = StorPerfMaster()
+
+ def test_agent_count(self):
+ expected = 10
+
+ self.storperf.agent_count = expected
+ actual = self.storperf.agent_count
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_queue_depths(self):
+ expected = "1,2,3"
+
+ self.storperf.queue_depths = expected
+ actual = self.storperf.queue_depths
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_block_sizes(self):
+ expected = "8,2,1,0"
+
+ self.storperf.block_sizes = expected
+ actual = self.storperf.block_sizes
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_volume_size(self):
+ expected = 20
+
+ self.storperf.volume_size = expected
+ actual = self.storperf.volume_size
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
+
+ def test_agent_network(self):
+ expected = "ABCDEF"
+
+ self.storperf.public_network = expected
+ actual = self.storperf.public_network
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))
diff --git a/tests/utilities_tests/__init__.py b/tests/utilities_tests/__init__.py
new file mode 100644
index 0000000..73444b6
--- /dev/null
+++ b/tests/utilities_tests/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# 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
+##############################################################################
diff --git a/tests/utilities_tests/dictionary_test.py b/tests/utilities_tests/dictionary_test.py
new file mode 100644
index 0000000..0819cef
--- /dev/null
+++ b/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/tests/utilities_tests/math_range_test.py b/tests/utilities_tests/math_range_test.py
new file mode 100644
index 0000000..6484752
--- /dev/null
+++ b/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 math
+
+
+class MathRangeTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ def test_empty_series(self):
+ expected = 0
+ data_series = []
+ actual = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.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 = math.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_single_element(self):
+ expected = 0
+ data_series = [2.265]
+ actual = math.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_10000_values_processing(self):
+ expected = 28001.068
+ data_series = [uniform(-10000, 10000) for i in xrange(10000)]
+ data_series.insert(randrange(len(data_series) + 1), 15000.569)
+ data_series.insert(randrange(len(data_series) + 1), -13000.499)
+ actual = math.range_value(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_processing_100_values_100_times(self):
+ expected = 35911.3134
+ for index in range(1, 100):
+ data_series = [uniform(-10000, 10000) for i in xrange(100)]
+ data_series.insert(randrange(len(data_series) + 1), 16956.3334)
+ data_series.insert(randrange(len(data_series) + 1), -18954.98)
+ actual = math.range_value(data_series)
+ self.assertEqual(expected, actual)
diff --git a/tests/utilities_tests/math_slope_test.py b/tests/utilities_tests/math_slope_test.py
new file mode 100644
index 0000000..a34845b
--- /dev/null
+++ b/tests/utilities_tests/math_slope_test.py
@@ -0,0 +1,67 @@
+##############################################################################
+# 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 MathSlopeTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+ pass
+
+ def test_slope_empty_series(self):
+ expected = 0
+ actual = math.slope([])
+ self.assertEqual(expected, actual)
+
+ def test_slope_integer_series(self):
+ expected = 1.4
+ actual = math.slope([[1, 6], [2, 5], [3, 7], [4, 10]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_decimal_series(self):
+ expected = 1.4
+ actual = math.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 = math.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 = math.slope([[1.0, -2], [2, 2], [3, 2]])
+ self.assertEqual(expected, actual)
+
+ def test_slope_negative_x_series(self):
+ expected = 1.4
+ actual = math.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 = math.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 = math.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 = math.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 = math.slope([[0.0, 0], [1, 1], [2, 3]])
+ self.assertEqual(expected, actual)
diff --git a/tests/workload_tests/__init__.py b/tests/workload_tests/__init__.py
new file mode 100644
index 0000000..73334c7
--- /dev/null
+++ b/tests/workload_tests/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/tests/workload_tests/workload_subclass_test.py b/tests/workload_tests/workload_subclass_test.py
new file mode 100644
index 0000000..e9e47f3
--- /dev/null
+++ b/tests/workload_tests/workload_subclass_test.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+from storperf.workloads.rr import rr
+from storperf.workloads.rs import rs
+from storperf.workloads.rw import rw
+from storperf.workloads.wr import wr
+from storperf.workloads.ws import ws
+import unittest
+
+
+class WorkloadSubclassTest(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_local_name(self):
+ workload = rr()
+ self.assertEqual(workload.fullname,
+ "None.rr.queue-depth.1.block-size.64k.None",
+ workload.fullname)
+
+ def test_remote_name(self):
+ workload = rw()
+ workload.remote_host = "192.168.0.1"
+ self.assertEqual(workload.fullname,
+ "None.rw.queue-depth.1.block-size.64k.192-168-0-1",
+ workload.fullname)
+
+ def test_blocksize(self):
+ workload = rs()
+ workload.options["bs"] = "4k"
+ self.assertEqual(workload.fullname,
+ "None.rs.queue-depth.1.block-size.4k.None",
+ workload.fullname)
+
+ def test_queue_depth(self):
+ workload = wr()
+ workload.options["iodepth"] = "8"
+ self.assertEqual(workload.fullname,
+ "None.wr.queue-depth.8.block-size.64k.None",
+ workload.fullname)
+
+ def test_id(self):
+ workload = ws()
+ workload.id = "workloadid"
+ self.assertEqual(workload.fullname,
+ "workloadid.ws.queue-depth.1.block-size.64k.None",
+ workload.fullname)