summaryrefslogtreecommitdiffstats
path: root/tests/fio_tests
diff options
context:
space:
mode:
authormbeierl <mark.beierl@dell.com>2017-02-16 10:40:35 -0500
committermbeierl <mark.beierl@dell.com>2017-02-16 13:16:51 -0500
commitac7b5490cb305468b0bd961fc5caad9c51b8b77b (patch)
tree8c4975a2dab26fc551ce0d933395c37375f5a423 /tests/fio_tests
parentacfadc79623d9ac6ec0a625ba69b356b71606252 (diff)
Prevent notifications after termination
Changes the event notification logic inside the FIO invoker so that it no longer publishes events after termination. Prevents false reports after steady state has been detected. Change-Id: I694f77b6493b88820fe4f4cc7f634e3e62c45a9a JIRA: STORPERF-105 Signed-off-by: mbeierl <mark.beierl@dell.com>
Diffstat (limited to 'tests/fio_tests')
-rw-r--r--tests/fio_tests/__init__.py11
-rw-r--r--tests/fio_tests/fio_invoker_test.py88
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/fio_tests/__init__.py b/tests/fio_tests/__init__.py
new file mode 100644
index 0000000..df29e18
--- /dev/null
+++ b/tests/fio_tests/__init__.py
@@ -0,0 +1,11 @@
+##############################################################################
+# Copyright (c) 2017 Dell 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/tests/fio_tests/fio_invoker_test.py b/tests/fio_tests/fio_invoker_test.py
new file mode 100644
index 0000000..4672651
--- /dev/null
+++ b/tests/fio_tests/fio_invoker_test.py
@@ -0,0 +1,88 @@
+##############################################################################
+# Copyright (c) 2017 Dell 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 StringIO import StringIO
+import json
+import unittest
+
+from storperf.fio.fio_invoker import FIOInvoker
+
+
+class Test(unittest.TestCase):
+
+ simple_dictionary = {'Key': 'Value'}
+
+ def exceptional_event(self, callback_id, metric):
+ self.exception_called = True
+ raise Exception
+
+ def event(self, callback_id, metric):
+ self.metric = metric
+
+ def setUp(self):
+ self.exception_called = False
+ self.metric = None
+ self.fio_invoker = FIOInvoker()
+
+ def testStdoutValidJSON(self):
+ self.fio_invoker.register(self.event)
+ string = json.dumps(self.simple_dictionary, indent=4, sort_keys=True)
+
+ output = StringIO(string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(self.simple_dictionary, self.metric)
+
+ def testStdoutValidJSONWithFIOOutput(self):
+ self.fio_invoker.register(self.event)
+ string = json.dumps(self.simple_dictionary, indent=4, sort_keys=True)
+ terminating = "fio: terminating on signal 2\n"
+ output = StringIO(terminating + string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(self.simple_dictionary, self.metric)
+
+ def testStdoutNoJSON(self):
+ self.fio_invoker.register(self.event)
+ string = "{'key': 'value'}"
+
+ output = StringIO(string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(None, self.metric)
+
+ def testStdoutInvalidJSON(self):
+ self.fio_invoker.register(self.event)
+ string = "{'key':\n}"
+
+ output = StringIO(string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(None, self.metric)
+
+ def testStdoutAfterTerminated(self):
+ self.fio_invoker.register(self.event)
+ string = json.dumps(self.simple_dictionary, indent=4, sort_keys=True)
+
+ self.fio_invoker.terminated = True
+ output = StringIO(string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(None, self.metric)
+
+ def testStdoutCallbackException(self):
+ self.fio_invoker.register(self.exceptional_event)
+ self.fio_invoker.register(self.event)
+ string = json.dumps(self.simple_dictionary, indent=4, sort_keys=True)
+
+ output = StringIO(string + "\n")
+ self.fio_invoker.stdout_handler(output)
+
+ self.assertEqual(self.simple_dictionary, self.metric)
+ self.assertEqual(self.exception_called, True)