Skip to content

Commit e96c92f

Browse files
authored
Merge pull request #340 from reportportal/develop
Release
2 parents 20466ab + da77a0b commit e96c92f

File tree

13 files changed

+261
-47
lines changed

13 files changed

+261
-47
lines changed

CHANGELOG.md

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

33
## [Unreleased]
4+
### Added
5+
- `rp_api_retries` configuration parameter, by @HardNorth
6+
### Changed
7+
- Client version updated on [5.3.5](https://github.com/reportportal/client-Python/releases/tag/5.3.5), by @HardNorth
8+
- `rp_uuid` configuration parameter was renamed to `rp_api_key` to maintain common convention, by @HardNorth
9+
10+
## [5.1.8]
411
### Fixed
512
- `rp_thread_logging = False` config parameter handling, by @HardNorth
613
- Recursive thread init issue in case of `rp_thread_logging = True`, by @HardNorth

README.rst

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ any one using pytest command line option:
6060
6161
The :code:`pytest.ini` file should have next mandatory fields:
6262

63-
- :code:`rp_uuid` - value could be found in the User Profile section
63+
- :code:`rp_api_key` - value could be found in the User Profile section
6464
- :code:`rp_project` - name of project in Report Portal
6565
- :code:`rp_endpoint` - address of Report Portal Server
6666

@@ -69,43 +69,41 @@ Example of :code:`pytest.ini`:
6969
.. code-block:: text
7070
7171
[pytest]
72-
rp_uuid = fb586627-32be-47dd-93c1-678873458a5f
72+
rp_api_key = fb586627-32be-47dd-93c1-678873458a5f
7373
rp_endpoint = http://192.168.1.10:8080
7474
rp_project = user_personal
7575
rp_launch = AnyLaunchName
7676
rp_launch_attributes = 'PyTest' 'Smoke'
7777
rp_launch_description = 'Smoke test'
7878
rp_ignore_attributes = 'xfail' 'usefixture'
7979
80-
- The :code:`rp_uuid` can also be set with the environment variable `RP_UUID`. This will override the value set for :code:`rp_uuid` in pytest.ini
80+
- The :code:`rp_api_key` can also be set with the environment variable `RP_API_KEY`. This will override the value set for :code:`rp_api_key` in pytest.ini
8181

8282
The following parameters are optional:
8383

84-
- :code:`rp_launch = AnyLaunchName` - launch name (could be overridden
85-
by pytest --rp-launch option, default value is 'Pytest Launch')
86-
- :code:`rp_launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing launch (the session will not handle the lifecycle of the given launch)
87-
- :code:`rp_launch_attributes = 'PyTest' 'Smoke' 'Env:Python3'` - list of attributes for launch
88-
- :code:`rp_parent_item_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing test item for session to use as parent item for the tests (the session will not handle the lifecycle of the given test item)
89-
- :code:`rp_tests_attributes = 'PyTest' 'Smoke'` - list of attributes that will be added for each item in the launch
90-
- :code:`rp_launch_description = 'Smoke test'` - launch description (could be overridden
91-
by pytest --rp-launch-description option, default value is '')
92-
93-
- :code:`rp_log_batch_size = 20` - size of batch log request
94-
- :code:`rp_log_batch_payload_size = 65000000` - maximum payload size in bytes of async batch log requests
95-
- :code:`rp_log_level = INFO` - The log level that will be reported
84+
- :code:`rp_launch = AnyLaunchName` - launch name (could be overridden by pytest --rp-launch option, default value is 'Pytest Launch').
85+
- :code:`rp_launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing launch (the session will not handle the lifecycle of the given launch).
86+
- :code:`rp_launch_attributes = 'PyTest' 'Smoke' 'Env:Python3'` - list of attributes for launch.
87+
- :code:`rp_parent_item_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing test item for session to use as parent item for the tests (the session will not handle the lifecycle of the given test item).
88+
- :code:`rp_tests_attributes = 'PyTest' 'Smoke'` - list of attributes that will be added for each item in the launch.
89+
- :code:`rp_launch_description = 'Smoke test'` - launch description (could be overridden by pytest --rp-launch-description option, default value is '').
90+
- :code:`rp_log_batch_size = 20` - size of batch log request.
91+
- :code:`rp_log_batch_payload_size = 65000000` - maximum payload size in bytes of async batch log requests.
92+
- :code:`rp_log_level = INFO` - The log level that will be reported.
9693
- :code:`rp_log_format = [%(levelname)7s] (%(name)s) %(message)s (%(filename)s:%(lineno)s)` - Format string to be used for logs sent to the service.
97-
- :code:`rp_ignore_attributes = 'xfail' 'usefixture'` - Ignore specified pytest markers
94+
- :code:`rp_ignore_attributes = 'xfail' 'usefixture'` - Ignore specified pytest markers.
9895
- :code:`rp_is_skipped_an_issue = False` - Treat skipped tests as required investigation. Default is True.
99-
- :code:`rp_hierarchy_dirs_level = 0` - Directory starting hierarchy level (from pytest.ini level) (default `0`)
96+
- :code:`rp_hierarchy_dirs_level = 0` - Directory starting hierarchy level (from pytest.ini level) (default `0`).
10097
- :code:`rp_hierarchy_dirs = True` - Enables hierarchy for tests directories, default `False`. Doesn't support 'xdist' plugin.
101-
- :code:`rp_hierarchy_dir_path_separator` - Path separator to display directories in test hierarchy. In case of empty value current system path separator will be used (os.path.sep)
98+
- :code:`rp_hierarchy_dir_path_separator` - Path separator to display directories in test hierarchy. In case of empty value current system path separator will be used (os.path.sep).
10299
- :code:`rp_hierarchy_code` - Enables hierarchy for inner classes and parametrized tests, default `False`. Doesn't support 'xdist' plugin.
103-
- :code:`rp_issue_system_url = https://bugzilla.some.com/show_bug.cgi?id={issue_id}` - issue URL (issue_id will be filled by parameter from pytest mark)
104-
- :code:`rp_issue_id_marks = True` - Enables adding marks for issue ids (e.g. "issue:123456")
105-
- :code:`rp_verify_ssl = True` - Verify SSL when connecting to the server
106-
- :code:`rp_mode = DEFAULT` - DEBUG or DEFAULT launch mode. DEBUG launches are displayed in a separate tab and not visible to anyone except owner
100+
- :code:`rp_issue_system_url = https://bugzilla.some.com/show_bug.cgi?id={issue_id}` - issue URL (issue_id will be filled by parameter from pytest mark).
101+
- :code:`rp_issue_id_marks = True` - Enables adding marks for issue ids (e.g. "issue:123456").
102+
- :code:`rp_verify_ssl = True` - Verify SSL when connecting to the server.
103+
- :code:`rp_mode = DEFAULT` - DEBUG or DEFAULT launch mode. DEBUG launches are displayed in a separate tab and not visible to anyone except owner.
107104
- :code:`rp_thread_logging` - EXPERIMENTAL - Enables support for reporting logs from threads by patching the builtin Thread class. Use with caution.
108-
- :code:`rp_launch_timeout = 86400` - Maximum time to wait for child processes finish, default value: 86400 seconds (1 day)
105+
- :code:`rp_launch_timeout = 86400` - Maximum time to wait for child processes finish, default value: 86400 seconds (1 day).
106+
- :code:`rp_api_retries = 0` - Amount of retries for performing REST calls to RP server.
109107

110108

111109

pytest_reportportal/config.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains class that stores RP agent configuration data."""
2+
import warnings
23

34
from distutils.util import strtobool
45
from os import getenv
@@ -69,14 +70,55 @@ def __init__(self, pytest_config):
6970
'rp_project')
7071
self.rp_rerun_of = self.find_option(pytest_config,
7172
'rp_rerun_of')
72-
self.rp_retries = int(self.find_option(pytest_config,
73-
'retries'))
7473
self.rp_skip_connection_test = str(
7574
self.find_option(pytest_config,
7675
'rp_skip_connection_test')).lower() in (
7776
'true', '1', 'yes', 'y')
78-
self.rp_uuid = getenv('RP_UUID') or self.find_option(pytest_config,
79-
'rp_uuid')
77+
78+
rp_api_retries_str = self.find_option(pytest_config, 'rp_api_retries')
79+
rp_api_retries = rp_api_retries_str and int(rp_api_retries_str)
80+
if rp_api_retries and rp_api_retries > 0:
81+
self.rp_api_retries = rp_api_retries
82+
else:
83+
rp_api_retries_str = self.find_option(pytest_config, 'retries')
84+
rp_api_retries = rp_api_retries_str and int(rp_api_retries_str)
85+
if rp_api_retries and rp_api_retries > 0:
86+
self.rp_api_retries = rp_api_retries
87+
warnings.warn(
88+
'Parameter `retries` is deprecated since 5.1.9 '
89+
'and will be subject for removing in the next '
90+
'major version. Use `rp_api_retries` argument '
91+
'instead.',
92+
DeprecationWarning,
93+
2
94+
)
95+
else:
96+
self.rp_api_retries = 0
97+
98+
self.rp_api_key = getenv(
99+
'RP_API_KEY') or self.find_option(pytest_config, 'rp_api_key')
100+
if not self.rp_api_key:
101+
self.rp_api_key = getenv(
102+
'RP_UUID') or self.find_option(pytest_config, 'rp_uuid')
103+
if self.rp_api_key:
104+
warnings.warn(
105+
'Parameter `rp_uuid` is deprecated since 5.1.9 '
106+
'and will be subject for removing in the next '
107+
'major version. Use `rp_api_key` argument '
108+
'instead.',
109+
DeprecationWarning,
110+
2
111+
)
112+
else:
113+
warnings.warn(
114+
'Argument `rp_api_key` is `None` or empty string, '
115+
'that is not supposed to happen because Report '
116+
'Portal is usually requires an authorization key. '
117+
'Please check your configuration.',
118+
RuntimeWarning,
119+
2
120+
)
121+
80122
rp_verify_ssl = self.find_option(pytest_config, 'rp_verify_ssl', True)
81123
try:
82124
self.rp_verify_ssl = bool(strtobool(rp_verify_ssl))

pytest_reportportal/config.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class AgentConfig:
2727
rp_parent_item_id: Optional[Text]
2828
rp_project: Text
2929
rp_rerun_of: Optional[Text]
30-
rp_retries: int
30+
rp_api_retries: int
3131
rp_skip_connection_test: bool
32-
rp_uuid: Text
32+
rp_api_key: Text
3333
rp_verify_ssl: Union[bool, Text]
3434
rp_launch_timeout: int
3535

pytest_reportportal/plugin.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'One of the following mandatory parameters is unset: ' + \
3737
'rp_project: {}, ' + \
3838
'rp_endpoint: {}, ' + \
39-
'rp_uuid: {}'
39+
'rp_api_key: {}'
4040

4141
FAILED_LAUNCH_WAIT = 'Failed to initialize reportportal-client service. ' \
4242
+ 'Waiting for Launch start timed out. ' \
@@ -172,7 +172,7 @@ def check_connection(agent_config):
172172
"""
173173
url = '{0}/api/v1/project/{1}'.format(agent_config.rp_endpoint,
174174
agent_config.rp_project)
175-
headers = {'Authorization': 'bearer {0}'.format(agent_config.rp_uuid)}
175+
headers = {'Authorization': 'bearer {0}'.format(agent_config.rp_api_key)}
176176
try:
177177
resp = requests.get(url, headers=headers,
178178
verify=agent_config.rp_verify_ssl)
@@ -203,7 +203,7 @@ def pytest_configure(config):
203203
agent_config = AgentConfig(config)
204204

205205
cond = (agent_config.rp_project, agent_config.rp_endpoint,
206-
agent_config.rp_uuid)
206+
agent_config.rp_api_key)
207207
config._rp_enabled = all(cond)
208208
if not config._rp_enabled:
209209
log.debug(MANDATORY_PARAMETER_MISSED_PATTERN.format(*cond))
@@ -379,7 +379,13 @@ def add_shared_option(name, help_str, default=None, action='store'):
379379
help_str='Create all test item as child items of the given (already '
380380
'existing) item.',
381381
)
382-
add_shared_option(name='rp_uuid', help_str='UUID')
382+
add_shared_option(name='rp_uuid', help_str='Deprecated: use `rp_api_key` '
383+
'instead.')
384+
add_shared_option(
385+
name='rp_api_key',
386+
help_str='API key of Report Portal. Usually located on UI profile '
387+
'page.'
388+
)
383389
add_shared_option(name='rp_endpoint', help_str='Server endpoint')
384390
add_shared_option(
385391
name='rp_mode',
@@ -468,6 +474,10 @@ def add_shared_option(name, help_str, default=None, action='store'):
468474
parser.addini(
469475
'retries',
470476
default='0',
477+
help='Deprecated: use `rp_api_retries` instead')
478+
parser.addini(
479+
'rp_api_retries',
480+
default='0',
471481
help='Amount of retries for performing REST calls to RP server')
472482
parser.addini(
473483
'rp_skip_connection_test',

pytest_reportportal/service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,18 +859,18 @@ def start(self):
859859
).union({'parametrize'})
860860
)
861861
log.debug('ReportPortal - Init service: endpoint=%s, '
862-
'project=%s, uuid=%s', self._config.rp_endpoint,
863-
self._config.rp_project, self._config.rp_uuid)
862+
'project=%s, api_key=%s', self._config.rp_endpoint,
863+
self._config.rp_project, self._config.rp_api_key)
864864
launch_id = self._launch_id
865865
if self._config.rp_launch_id:
866866
launch_id = self._config.rp_launch_id
867867
self.rp = RPClient(
868868
endpoint=self._config.rp_endpoint,
869869
project=self._config.rp_project,
870-
token=self._config.rp_uuid,
870+
api_key=self._config.rp_api_key,
871871
is_skipped_an_issue=self._config.rp_is_skipped_an_issue,
872872
log_batch_size=self._config.rp_log_batch_size,
873-
retries=self._config.rp_retries,
873+
retries=self._config.rp_api_retries,
874874
verify_ssl=self._config.rp_verify_ssl,
875875
launch_id=launch_id,
876876
log_batch_payload_size=self._config.rp_log_batch_payload_size

requirements.txt

Lines changed: 1 addition & 1 deletion
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.4
3+
reportportal-client==5.3.5
44
six>=1.16.0
55
aenum>=3.1.0
66
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.8'
8+
__version__ = '5.1.9'
99

1010

1111
def read_file(fname):

tests/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
from six import add_move, MovedModule
1818
add_move(MovedModule('mock', 'mock', 'unittest.mock'))
1919

20-
REPORT_PORTAL_SERVICE = (
21-
'pytest_reportportal.service.RPClient')
20+
REPORT_PORTAL_PACKAGE = 'pytest_reportportal'
21+
22+
REPORT_PORTAL_SERVICE = REPORT_PORTAL_PACKAGE + '.service.RPClient'

tests/helpers/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'rp_launch': 'Pytest',
2525
'rp_endpoint': 'http://localhost:8080',
2626
'rp_project': 'default_personal',
27-
'rp_uuid': 'test_uuid',
27+
'rp_api_key': 'test_api_key',
2828
'rp_skip_connection_test': 'True'
2929
}
3030

0 commit comments

Comments
 (0)