Skip to content

Commit 20466ab

Browse files
authored
Merge pull request #338 from reportportal/develop
Release
2 parents 76afa1d + c0d2237 commit 20466ab

File tree

8 files changed

+36
-29
lines changed

8 files changed

+36
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## [Unreleased]
44
### Fixed
5+
- `rp_thread_logging = False` config parameter handling, by @HardNorth
6+
- Recursive thread init issue in case of `rp_thread_logging = True`, by @HardNorth
7+
### Changed
8+
- Client version updated on [5.3.2](https://github.com/reportportal/client-Python/releases/tag/5.3.2), by @HardNorth
9+
10+
## [5.1.7]
11+
### Fixed
512
- Plugin Exception in case of Launch creation timed out, by @HardNorth
613
### Changed
714
- Client version updated on [5.3.1](https://github.com/reportportal/client-Python/releases/tag/5.3.1), by @HardNorth

pytest_reportportal/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def __init__(self, pytest_config):
5959
self.rp_log_batch_payload_size = MAX_LOG_BATCH_PAYLOAD_SIZE
6060
self.rp_log_level = get_actual_log_level(pytest_config, 'rp_log_level')
6161
self.rp_log_format = self.find_option(pytest_config, 'rp_log_format')
62-
self.rp_mode = self.find_option(pytest_config, 'rp_mode')
63-
self.rp_thread_logging = self.find_option(
62+
self.rp_thread_logging = bool(strtobool(str(self.find_option(
6463
pytest_config, 'rp_thread_logging'
65-
)
64+
) or False)))
65+
self.rp_mode = self.find_option(pytest_config, 'rp_mode')
6666
self.rp_parent_item_id = self.find_option(pytest_config,
6767
'rp_parent_item_id')
6868
self.rp_project = self.find_option(pytest_config,

pytest_reportportal/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
+ 'Reporting is disabled.'
4444

4545

46-
@pytest.mark.optionalhook
46+
@pytest.hookimpl(optionalhook=True)
4747
def pytest_configure_node(node):
4848
"""Configure xdist node controller.
4949

pytest_reportportal/rp_logging.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@
55
from contextlib import contextmanager
66
from functools import wraps
77

8-
from reportportal_client.client import RPClient
9-
108
from reportportal_client._local import current, set_current
119
from reportportal_client import RPLogger
10+
from reportportal_client.core.worker import APIWorker
11+
12+
13+
def is_api_worker(target):
14+
"""Check if target is an RP worker thread."""
15+
if target:
16+
method_name = getattr(target, '__name__', None)
17+
method_self = getattr(target, '__self__', None)
18+
if method_name == '_monitor' and method_self:
19+
clazz = getattr(method_self, '__class__', None)
20+
if clazz is APIWorker:
21+
return True
22+
return False
1223

1324

1425
@contextmanager
@@ -30,7 +41,8 @@ def wrap_start(original_func):
3041
def _start(self, *args, **kwargs):
3142
"""Save the invoking thread's client if there is one."""
3243
# Prevent an endless loop of workers being spawned
33-
if "_monitor" not in self.name:
44+
target = getattr(self, '_target', None)
45+
if not is_api_worker(self) and not is_api_worker(target):
3446
current_client = current()
3547
self.parent_rp_client = current_client
3648
return original_func(self, *args, **kwargs)
@@ -48,20 +60,7 @@ def _run(self, *args, **kwargs):
4860
and not current()
4961
):
5062
parent = self.parent_rp_client
51-
client = RPClient(
52-
endpoint=parent.endpoint,
53-
project=parent.project,
54-
token=parent.token,
55-
log_batch_size=parent.log_batch_size,
56-
is_skipped_an_issue=parent.is_skipped_an_issue,
57-
verify_ssl=parent.verify_ssl,
58-
retries=config.rp_retries,
59-
launch_id=parent.launch_id
60-
)
61-
if parent.current_item():
62-
client._item_stack.append(
63-
parent.current_item()
64-
)
63+
client = parent.clone()
6564
client.start()
6665
try:
6766
return original_func(self, *args, **kwargs)

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dill>=0.2.7.1
22
pytest>=3.8.0
3-
reportportal-client==5.3.1
4-
six>=1.15.0
3+
reportportal-client==5.3.4
4+
six>=1.16.0
55
aenum>=3.1.0
6-
requests
6+
requests>=2.27.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66

77

8-
__version__ = '5.1.7'
8+
__version__ = '5.1.8'
99

1010

1111
def read_file(fname):

tests/integration/test_threads_logs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
from tests.helpers import utils
55

66

7-
@mock.patch('pytest_reportportal.rp_logging.RPClient')
87
@mock.patch(REPORT_PORTAL_SERVICE)
9-
def test_rp_thread_logs_reporting(mock_client_init, mock_thread_client_init):
8+
def test_rp_thread_logs_reporting(mock_client_init):
109
"""Verify logs from threads are sent to correct items`.
1110
1211
:param mock_client_init: Pytest fixture
1312
"""
1413
mock_client = mock_client_init.return_value
15-
mock_thread_client = mock_thread_client_init.return_value
14+
mock_thread_client = mock_client.clone()
1615

1716
def init_thread_client(*_, **__):
1817
from reportportal_client._local import set_current
1918
set_current(mock_thread_client)
2019
return mock_thread_client
21-
mock_thread_client_init.side_effect = init_thread_client
20+
21+
mock_client.clone.side_effect = init_thread_client
2222
result = utils.run_tests_with_client(
2323
mock_client,
2424
['examples/threads/'],

tests/unit/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def getoption_side_effect(name, default=None):
6666
mocked_config.option.rp_hierarchy_dirs_level = '0'
6767
mocked_config.option.rp_rerun = False
6868
mocked_config.option.rp_launch_timeout = -1
69+
mocked_config.option.rp_thread_logging = True
6970
return mocked_config
7071

7172

0 commit comments

Comments
 (0)