Skip to content

Commit 0ab7991

Browse files
authored
Merge pull request #219 from Helene/oentsdb_prof_test
Add Profiler test to OpenTSDB unit tests
2 parents 3a1e459 + d7f0268 commit 0ab7991

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_opentsdb.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import logging
2+
import os
23
from unittest import mock
34
from nose2.tools.decorators import with_setup
45
from source.queryHandler.QueryHandler import ColumnInfo, Key
6+
from source.profiler import Profiler
57
from source.collector import MetricTimeSeries, TimeSeries
68
from source.opentsdb import OpenTsdbApi
79

@@ -76,3 +78,19 @@ def test_case02():
7678
assert 'gpfs_fs_name' in resp[0].get('tags')
7779
assert 'node' in resp[0].get('tags')
7880
assert 'gpfs_cluster_name' in resp[0].get('tags')
81+
82+
83+
@with_setup(my_setup)
84+
def test_case03():
85+
with mock.patch('source.metadata.MetadataHandler') as md:
86+
md_instance = md.return_value
87+
logger = logging.getLogger(__name__)
88+
opentsdb = OpenTsdbApi(logger, md_instance, '9999')
89+
profiler = Profiler()
90+
resp = profiler.run(opentsdb.format_response, *(data, jreq))
91+
# resp = opentsdb.format_response(data, jreq)
92+
assert resp is not None
93+
assert os.path.exists(os.path.join(profiler.path, "profiling_format_response.prof"))
94+
response = profiler.stats(os.path.join(profiler.path, "profiling_format_response.prof"))
95+
assert response is not None
96+
print('\n'.join(response) + '\n')

0 commit comments

Comments
 (0)