summaryrefslogtreecommitdiffstats
path: root/storperf/tests
diff options
context:
space:
mode:
Diffstat (limited to 'storperf/tests')
-rw-r--r--storperf/tests/db_tests/graphite_db_test.py14
-rw-r--r--storperf/tests/db_tests/job_db_test.py7
-rw-r--r--storperf/tests/utilities/__init__.py8
-rw-r--r--storperf/tests/utilities/dictionary.py42
4 files changed, 65 insertions, 6 deletions
diff --git a/storperf/tests/db_tests/graphite_db_test.py b/storperf/tests/db_tests/graphite_db_test.py
index ce970bb..e13545b 100644
--- a/storperf/tests/db_tests/graphite_db_test.py
+++ b/storperf/tests/db_tests/graphite_db_test.py
@@ -1,5 +1,13 @@
+##############################################################################
+# 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 this
import unittest
@@ -9,13 +17,13 @@ class GraphiteDBTest(unittest.TestCase):
self.graphdb = GraphiteDB()
self.graphdb._job_db = self
- def test_wilcard_pattern(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_wilcard_pattern(self):
+ 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)
diff --git a/storperf/tests/db_tests/job_db_test.py b/storperf/tests/db_tests/job_db_test.py
index 0972f84..fe3d9f1 100644
--- a/storperf/tests/db_tests/job_db_test.py
+++ b/storperf/tests/db_tests/job_db_test.py
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 2015 EMC and others.
+# 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
@@ -186,6 +186,7 @@ class JobDBTest(unittest.TestCase):
def test_job_params(self):
expected = {"a": "1", "b": "2"}
- self.job.record_workload_params("ABCD", expected)
- actual = self.job.fetch_workload_params("ABCD")
+ 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/storperf/tests/utilities/__init__.py b/storperf/tests/utilities/__init__.py
new file mode 100644
index 0000000..73444b6
--- /dev/null
+++ b/storperf/tests/utilities/__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/storperf/tests/utilities/dictionary.py b/storperf/tests/utilities/dictionary.py
new file mode 100644
index 0000000..0819cef
--- /dev/null
+++ b/storperf/tests/utilities/dictionary.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)