diff options
author | Mark Beierl <mark.beierl@dell.com> | 2016-12-02 22:25:48 -0500 |
---|---|---|
committer | mbeierl <mark.beierl@dell.com> | 2016-12-05 13:11:08 -0500 |
commit | 9f5b776c1b5a54d2ca5942424111f3ff55d5737c (patch) | |
tree | 56bff326b62256d1c3108453dc3ef2d33dd7ea12 /tests/carbon_tests | |
parent | f56d13f2aac136b3b8762e06ca15688dd88ff502 (diff) |
Steady state detection
Detection of steady state after 10+ samples of data
Change-Id: I29368b06188c6370d17b3d567fece6486d171235
JIRA: STORPERF-72 STORPERF-73
Signed-off-by: Mark Beierl <mark.beierl@dell.com>
Diffstat (limited to 'tests/carbon_tests')
-rw-r--r-- | tests/carbon_tests/emitter_test.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/carbon_tests/emitter_test.py b/tests/carbon_tests/emitter_test.py index fe19ed2..7f61049 100644 --- a/tests/carbon_tests/emitter_test.py +++ b/tests/carbon_tests/emitter_test.py @@ -7,14 +7,16 @@ # 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 +from storperf.carbon import converter +from storperf.carbon.emitter import CarbonMetricTransmitter import threading +from time import sleep, strptime import unittest +import mock + class MetricsHandler(SocketServer.BaseRequestHandler): @@ -42,10 +44,14 @@ class CarbonMetricTransmitterTest(unittest.TestCase): t.setDaemon(True) t.start() - def test_transmit_metrics(self): + @mock.patch("time.gmtime") + def test_transmit_metrics(self, mock_time): + + mock_time.return_value = strptime("30 Nov 00", "%d %b %y") testconv = converter.Converter() - json_object = json.loads("""{"timestamp" : "12345", "key":"value" }""") + json_object = json.loads( + """{"timestamp" : "975542400", "key":"value" }""") result = testconv.convert_json_to_flat(json_object, "host.run-name") emitter = CarbonMetricTransmitter() @@ -58,7 +64,7 @@ class CarbonMetricTransmitterTest(unittest.TestCase): count += 1 sleep(0.1) - self.assertEqual("host.run-name.key value 12345\n", + self.assertEqual("host.run-name.key value 975542400\n", CarbonMetricTransmitterTest.response, CarbonMetricTransmitterTest.response) |