From 2d55474511a5057015e77547c326120c1649c0b7 Mon Sep 17 00:00:00 2001 From: ahothan Date: Tue, 22 Aug 2017 17:41:16 -0700 Subject: NFVBENCH-6 Add support for sending logs to fluentd with fluentd client library Change-Id: I1bc01b26f9e43f78c169b5fcd26247debcfe31bf Signed-off-by: ahothan --- test/test_nfvbench.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/test_nfvbench.py b/test/test_nfvbench.py index a70e71a..ad78a9e 100644 --- a/test/test_nfvbench.py +++ b/test/test_nfvbench.py @@ -15,9 +15,12 @@ # from attrdict import AttrDict +import logging from nfvbench.config import get_err_config from nfvbench.connection import SSH from nfvbench.credentials import Credentials +from nfvbench.fluentd import FluentLogHandler +import nfvbench.log from nfvbench.network import Interface from nfvbench.network import Network from nfvbench.specs import Encaps @@ -632,6 +635,9 @@ def test_ndr_pdr_search(traffic_client): # Other tests # ========================================================================= +def setup_module(module): + nfvbench.log.setup(mute_stdout=True) + def test_no_credentials(): cred = Credentials('/completely/wrong/path/openrc', None, False) if cred.rc_auth_url: @@ -656,3 +662,15 @@ def test_config(): assert(get_err_config({2: 100}, refcfg) == {2: 100}) # both correctly fail and invalid value type assert(get_err_config({2: 100, 5: 10}, refcfg) == {2: 100, 5: 10}) + +def test_fluentd(): + logger = logging.getLogger('fluent-logger') + handler = FluentLogHandler('nfvbench', fluentd_port=7081) + logger.addHandler(handler) + logger.setLevel(logging.INFO) + logger.info('test') + logger.warning('test %d', 100) + try: + raise Exception("test") + except Exception: + logger.exception("got exception") -- cgit 1.2.3-korg