From 9f5b776c1b5a54d2ca5942424111f3ff55d5737c Mon Sep 17 00:00:00 2001 From: Mark Beierl Date: Fri, 2 Dec 2016 22:25:48 -0500 Subject: 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 --- tests/db_tests/graphite_db_test.py | 59 +++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'tests/db_tests') diff --git a/tests/db_tests/graphite_db_test.py b/tests/db_tests/graphite_db_test.py index e13545b..d4c6fb6 100644 --- a/tests/db_tests/graphite_db_test.py +++ b/tests/db_tests/graphite_db_test.py @@ -7,9 +7,19 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from storperf.db.graphite_db import GraphiteDB import unittest +import mock + +from storperf.db.graphite_db import GraphiteDB + + +class MockResponse(): + + def __init__(self): + self.content = "" + self.status_code = 200 + class GraphiteDBTest(unittest.TestCase): @@ -32,6 +42,53 @@ class GraphiteDBTest(unittest.TestCase): # self.graphdb.fetch_averages(u'32d31724-fac1-44f3-9033-ca8e00066a36') pass + @mock.patch("requests.get") + def test_fetch_series(self, mock_requests): + + response = MockResponse() + response.content = """ +[ + { + "datapoints": [ + [null,1480455880], + [null,1480455890], + [null,1480455900], + [205.345,1480455910], + [201.59,1480455920], + [205.76,1480455930], + [null,1480455940], + [null,1480455950], + [null,1480455960], + [215.655,1480455970], + [214.16,1480455980], + [213.57,1480455990], + [null,1480456000], + [null,1480456010], + [null,1480456020], + [219.37,1480456030], + [219.28,1480456040], + [217.75,1480456050], + [null,1480456060] + ], + "target":"averageSeries(.8192.*.jobs.1.write.iops)" + } +]""" + 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_requests.side_effect = (response, ) + + actual = self.graphdb.fetch_series("workload", "iops", + "write", 0, 600) + self.assertEqual(expected, actual) + 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', -- cgit 1.2.3-korg