|
1 | 1 | import logging
|
| 2 | +import os |
2 | 3 | from unittest import mock
|
3 | 4 | from nose2.tools.decorators import with_setup
|
4 | 5 | from source.queryHandler.QueryHandler import ColumnInfo, Key
|
| 6 | +from source.profiler import Profiler |
5 | 7 | from source.collector import MetricTimeSeries, TimeSeries
|
6 | 8 | from source.opentsdb import OpenTsdbApi
|
7 | 9 |
|
@@ -76,3 +78,19 @@ def test_case02():
|
76 | 78 | assert 'gpfs_fs_name' in resp[0].get('tags')
|
77 | 79 | assert 'node' in resp[0].get('tags')
|
78 | 80 | 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