Skip to content

Commit

Permalink
Upgrade vertica to stop logging to /dev/null (#5352)
Browse files Browse the repository at this point in the history
Co-authored-by: Ofek Lev <[email protected]>
  • Loading branch information
AlexandreYang and ofek authored Jan 3, 2020
1 parent 2934ab4 commit 7ec57dd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ six==1.12.0
supervisor==4.0.1
tuf==0.12.1
uptime==3.0.1
vertica-python==0.9.4
vertica-python==0.10.1
win-inet-pton==1.1.0; sys_platform == 'win32' and python_version < '3.0'
6 changes: 3 additions & 3 deletions vertica/datadog_checks/vertica/vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from __future__ import division

import os
import ssl
from collections import defaultdict
from datetime import datetime
Expand Down Expand Up @@ -565,8 +564,9 @@ def get_connection(self):
if self._client_lib_log_level:
connection_options['log_level'] = self._client_lib_log_level
# log_path is required by vertica client for using logging
# we still get vertica client logs in the agent log even if `log_path` is set to os.devnull
connection_options['log_path'] = os.devnull
# when log_path is set to '', vertica won't log to a file
# but we still get logs via parent root logger
connection_options['log_path'] = ''

if self._tls_verify: # no cov
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext
Expand Down
2 changes: 1 addition & 1 deletion vertica/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vertica-python==0.9.4
vertica-python==0.10.1
1 change: 1 addition & 0 deletions vertica/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
'password': 'monitor',
'timeout': 10,
'tags': ['foo:bar'],
'client_lib_log_level': 'DEBUG',
}
3 changes: 2 additions & 1 deletion vertica/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ def test_client_logging_enabled(aggregator, instance):
connection_load_balance=mock.ANY,
connection_timeout=mock.ANY,
log_level='DEBUG',
log_path=os.devnull,
log_path='',
)


def test_client_logging_disabled(aggregator, instance):
instance['client_lib_log_level'] = None
check = VerticaCheck('vertica', {}, [instance])

with mock.patch('datadog_checks.vertica.vertica.vertica') as vertica:
Expand Down
17 changes: 17 additions & 0 deletions vertica/tests/test_vertica.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# (C) Datadog, Inc. 2019
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os

import mock
import pytest

from datadog_checks.vertica import VerticaCheck

from . import common
from .metrics import ALL_METRICS


Expand All @@ -32,6 +35,20 @@ def test_check(aggregator, instance):
aggregator.assert_all_metrics_covered()


@pytest.mark.usefixtures('dd_environment')
def test_vertica_log_file_not_created(aggregator, instance):
instance['client_lib_log_level'] = 'DEBUG'

vertica_default_log = os.path.join(os.path.dirname(common.HERE), 'vertica_python.log')
if os.path.exists(vertica_default_log):
os.remove(vertica_default_log)

check = VerticaCheck('vertica', {}, [instance])
check.check(instance)

assert not os.path.exists(vertica_default_log)


@pytest.mark.usefixtures('dd_environment')
def test_check_connection_load_balance(instance):
instance['connection_load_balance'] = True
Expand Down

0 comments on commit 7ec57dd

Please sign in to comment.