Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable logging when pulling on python integration tests #20397

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions libbeat/tests/system/beat/compose.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import io
import logging
import os
import sys
import tarfile
import time
import io

from contextlib import contextmanager


INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False)
Expand Down Expand Up @@ -54,9 +57,12 @@ def is_healthy(container):
return container.inspect()['State']['Health']['Status'] == 'healthy'

project = cls.compose_project()
project.pull(
ignore_pull_failures=True,
service_names=cls.COMPOSE_SERVICES)

with disabled_logger('compose.service'):
project.pull(
ignore_pull_failures=True,
service_names=cls.COMPOSE_SERVICES)

project.up(
strategy=ConvergenceStrategy.always,
service_names=cls.COMPOSE_SERVICES,
Expand Down Expand Up @@ -231,3 +237,14 @@ def service_log_contains(cls, service, msg):
if line.find(msg.encode("utf-8")) >= 0:
counter += 1
return counter > 0


@contextmanager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of context managers!

def disabled_logger(name):
logger = logging.getLogger(name)
old_level = logger.getEffectiveLevel()
logger.setLevel(logging.CRITICAL)
try:
yield logger
finally:
logger.setLevel(old_level)