Skip to content

Commit

Permalink
test: test directly cloudwatch init
Browse files Browse the repository at this point in the history
  • Loading branch information
jdobes authored and blayson committed Nov 18, 2020
1 parent 9178e79 commit c501046
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/common_tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import os
import logging
from common.logging import init_logging
from common.logging import setup_cw_logging


class TestLogging:
Expand All @@ -14,26 +14,29 @@ class TestLogging:
def test_cw_disabled(self, caplog):
"""tests disabled cloudwatch logging"""
with caplog.at_level(logging.INFO):
init_logging(num_servers=4)
logger = logging.getLogger("test_cw")
setup_cw_logging(logger)
assert caplog.records[0].msg == "CloudWatch logging disabled"
caplog.clear()

def test_init_logging_no_cw(self, caplog):
"""test_init_logging_no_cw"""
def test_no_cw(self, caplog):
"""test_no_cw"""
os.environ["CW_ENABLED"] = "TRUE"
with caplog.at_level(logging.INFO):
init_logging(num_servers=4)
logger = logging.getLogger("test_cw")
setup_cw_logging(logger)
assert caplog.records[0].msg == "CloudWatch logging disabled due to missing access key"
caplog.clear()
del os.environ["CW_ENABLED"]

def test_init_logging_cw_err(self, caplog):
"""test_init_logging_cw_err"""
def test_cw_err(self, caplog):
"""test_cw_err"""
os.environ["CW_ENABLED"] = "TRUE"
os.environ["CW_AWS_ACCESS_KEY_ID"] = "cw-aws-access-key-id"
os.environ["CW_AWS_SECRET_ACCESS_KEY"] = "cw-aws-secret-access-key"
with caplog.at_level(logging.INFO):
init_logging(num_servers=4)
logger = logging.getLogger("test_cw")
setup_cw_logging(logger)
assert caplog.records[0].msg.startswith("Unable to enable CloudWatch logging:")
caplog.clear()
del os.environ["CW_ENABLED"]
Expand Down

0 comments on commit c501046

Please sign in to comment.