Skip to content

Commit

Permalink
Added logging to functional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Ushanov <[email protected]>
  • Loading branch information
gmmephisto committed May 12, 2016
1 parent 3fde56c commit 8ce3379
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 21 additions & 1 deletion tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,7 @@ def client(request):
os.getenv("scaleio_host"),
os.getenv("scaleio_user"),
os.getenv("scaleio_passwd"),
os.getenv("scaleio_is_secure")
bool(int(os.getenv("scaleio_is_secure")))
)
pyscaleio.add_client(client)
request.addfinalizer(ScaleIOClientsManager().deregister)
Expand Down Expand Up @@ -74,3 74,23 @@ def setup_teardown(request):
cleanup_pools()
request.addfinalizer(cleanup_volumes)
request.addfinalizer(cleanup_pools)


@pytest.fixture
def setup_logging(request):
"""Fixture that setups debug logging."""

import logging

logger = logging.getLogger("pyscaleio")
logger.setLevel(logging.DEBUG)

formatter = logging.Formatter(
"%(asctime)s.%(msecs)03d %(levelname)s: %(message)s",
"%Y.%m.%d %H:%M:%S")

handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)

request.addfinalizer(lambda: logger.removeHandler(handler))
5 changes: 3 additions & 2 deletions tests/functional/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 7,10 @@
from pyscaleio import constants

from . import _get_test_name
from . import client, setup_teardown
from . import client, setup_teardown, setup_logging
assert client
assert setup_teardown
assert setup_logging


@pytest.fixture
Expand All @@ -27,7 28,7 @@ def test_get_system():
assert len(System.all()) == 1


def test_create_volume(storage_pool):
def test_create_volume(storage_pool, setup_logging):

volume = Volume.create(4, storage_pool["id"], name=_get_test_name(1))

Expand Down

0 comments on commit 8ce3379

Please sign in to comment.