forked from DataDog/dd-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] add a switch to disable profiling, but still use developer mode
- Loading branch information
Showing
4 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import mock | ||
|
||
from tests.checks.common import AgentCheckTest, load_check | ||
|
||
class TestNoProfiling(AgentCheckTest): | ||
|
||
CHECK_NAME = 'redisdb' | ||
|
||
def test_no_profiling(self): | ||
agentConfig = { | ||
'api_key': 'XXXtest_apikey', | ||
'developer_mode': True, | ||
'allow_profiling': False | ||
} | ||
# this must be SystemExit, because otherwise the Exception is eaten | ||
mocks = { | ||
'_set_internal_profiling_stats': mock.MagicMock(side_effect=SystemExit), | ||
} | ||
redis_config = { | ||
"init_config": {}, | ||
"instances": [{"host": "localhost", "port": 6379}] | ||
} | ||
check = load_check('redisdb', redis_config, agentConfig) | ||
|
||
self.assertFalse(check.allow_profiling) | ||
self.assertTrue(check.in_developer_mode) | ||
|
||
for func_name, mock1 in mocks.iteritems(): | ||
if not hasattr(check, func_name): | ||
continue | ||
else: | ||
setattr(check, func_name, mock1) | ||
|
||
check.run() | ||
# If we get here, no Exception was thrown |
Binary file not shown.