Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [Unreleased]
### Changed
- `log_batch_payload_size` was renamed to `log_batch_payload_limit` as it was originally supposed, by @HardNorth

## [5.6.6]
### Added
- OAuth 2.0 Password Grant authentication, by @HardNorth

Expand Down
20 changes: 16 additions & 4 deletions reportportal_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""This package is the base package for ReportPortal client."""

import sys
import warnings
from typing import Optional, Tuple, TypedDict, Union

# noinspection PyUnreachableCode
Expand Down Expand Up @@ -120,14 +121,25 @@ def create_client(
execution.
:return: ReportPortal Client instance.
"""
my_kwargs = kwargs.copy()
if "log_batch_payload_size" in my_kwargs:
warnings.warn(
message="Your agent is using `log_batch_payload_size` property which was introduced by mistake. "
"The real property name is `log_batch_payload_limit`. Please consider Agent version update.",
category=DeprecationWarning,
stacklevel=2,
)
if "log_batch_payload_limit" not in my_kwargs:
my_kwargs["log_batch_payload_limit"] = my_kwargs.pop("log_batch_payload_size")

if client_type is ClientType.SYNC:
return RPClient(endpoint, project, **kwargs)
return RPClient(endpoint, project, **my_kwargs)
if client_type is ClientType.ASYNC:
return AsyncRPClient(endpoint, project, **kwargs)
return AsyncRPClient(endpoint, project, **my_kwargs)
if client_type is ClientType.ASYNC_THREAD:
return ThreadedRPClient(endpoint, project, **kwargs)
return ThreadedRPClient(endpoint, project, **my_kwargs)
if client_type is ClientType.ASYNC_BATCHED:
return BatchedRPClient(endpoint, project, **kwargs)
return BatchedRPClient(endpoint, project, **my_kwargs)
raise ValueError(f"Unknown ReportPortal Client type requested: {client_type}")


Expand Down
60 changes: 30 additions & 30 deletions reportportal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class RPClient(RP):
__launch_uuid: str
use_own_launch: bool
log_batch_size: int
log_batch_payload_size: int
log_batch_payload_limit: int
__project: str
api_key: Optional[str]
oauth_uri: Optional[str]
Expand Down Expand Up @@ -470,7 +470,7 @@ def __init__(
max_pool_size: int = 50,
launch_uuid: str = None,
http_timeout: Union[float, Tuple[float, float]] = (10, 10),
log_batch_payload_size: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
log_batch_payload_limit: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
mode: str = "DEFAULT",
launch_uuid_print: bool = False,
print_output: OutputType = OutputType.STDOUT,
Expand All @@ -487,31 +487,31 @@ def __init__(
) -> None:
"""Initialize the class instance with arguments.

:param endpoint: Endpoint of the ReportPortal service.
:param project: Project name to report to.
:param api_key: Authorization API key.
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
:param oauth_username: Username for OAuth 2.0 authentication.
:param oauth_password: Password for OAuth 2.0 authentication.
:param oauth_client_id: OAuth 2.0 client ID.
:param oauth_client_secret: OAuth 2.0 client secret (optional).
:param oauth_scope: OAuth 2.0 scope (optional).
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
batch.
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
server side.
:param verify_ssl: Option to skip ssl verification.
:param retries: Number of retry attempts to make in case of connection / server errors.
:param max_pool_size: Option to set the maximum number of connections to save the pool.
:param launch_uuid: A launch UUID to use instead of starting own one.
:param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
specific connect and read separately.
:param log_batch_payload_size: Maximum size in bytes of logs that can be processed in one batch.
:param mode: Launch mode, all Launches started by the client will be in that mode.
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
:param print_output: Set output stream for Launch UUID printing.
:param log_batcher: Use existing LogBatcher instance instead of creation of own one.
:param truncate_attributes: Truncate test item attributes to default maximum length.
:param endpoint: Endpoint of the ReportPortal service.
:param project: Project name to report to.
:param api_key: Authorization API key.
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
:param oauth_username: Username for OAuth 2.0 authentication.
:param oauth_password: Password for OAuth 2.0 authentication.
:param oauth_client_id: OAuth 2.0 client ID.
:param oauth_client_secret: OAuth 2.0 client secret (optional).
:param oauth_scope: OAuth 2.0 scope (optional).
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
batch.
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
server side.
:param verify_ssl: Option to skip ssl verification.
:param retries: Number of retry attempts to make in case of connection / server errors.
:param max_pool_size: Option to set the maximum number of connections to save the pool.
:param launch_uuid: A launch UUID to use instead of starting own one.
:param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
specific connect and read separately.
:param log_batch_payload_limit: Maximum size in bytes of logs that can be processed in one batch.
:param mode: Launch mode, all Launches started by the client will be in that mode.
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
:param print_output: Set output stream for Launch UUID printing.
:param log_batcher: Use existing LogBatcher instance instead of creation of own one.
:param truncate_attributes: Truncate test item attributes to default maximum length.
"""
set_current(self)
self.api_v1, self.api_v2 = "v1", "v2"
Expand All @@ -533,8 +533,8 @@ def __init__(
self.__launch_uuid = launch_id
self.use_own_launch = not bool(self.__launch_uuid)
self.log_batch_size = log_batch_size
self.log_batch_payload_size = log_batch_payload_size
self._log_batcher = log_batcher or LogBatcher(self.log_batch_size, self.log_batch_payload_size)
self.log_batch_payload_limit = log_batch_payload_limit
self._log_batcher = log_batcher or LogBatcher(self.log_batch_size, self.log_batch_payload_limit)
self.verify_ssl = verify_ssl
self.retries = retries
self.max_pool_size = max_pool_size
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def clone(self) -> "RPClient":
max_pool_size=self.max_pool_size,
launch_uuid=self.__launch_uuid,
http_timeout=self.http_timeout,
log_batch_payload_size=self.log_batch_payload_size,
log_batch_payload_limit=self.log_batch_payload_limit,
mode=self.mode,
log_batcher=self._log_batcher,
oauth_uri=self.oauth_uri,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import find_packages, setup

__version__ = "5.6.6"
__version__ = "5.6.7"

TYPE_STUBS = ["*.pyi"]

Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_clone():
"max_pool_size": 30,
"launch_id": "test-123",
"http_timeout": (30, 30),
"log_batch_payload_size": 1000000,
"log_batch_payload_limit": 1000000,
"mode": "DEBUG",
}
client = RPClient(*args, **kwargs)
Expand All @@ -155,7 +155,7 @@ def test_clone():
and cloned.launch_uuid == kwargs["launch_id"]
and cloned.launch_id == kwargs["launch_id"]
and cloned.http_timeout == kwargs["http_timeout"]
and cloned.log_batch_payload_size == kwargs["log_batch_payload_size"]
and cloned.log_batch_payload_limit == kwargs["log_batch_payload_limit"]
and cloned.mode == kwargs["mode"]
)
assert cloned._item_stack.qsize() == 1 and client.current_item() == cloned.current_item()
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_clone_with_oauth():
"max_pool_size": 30,
"launch_id": "test-123",
"http_timeout": (30, 30),
"log_batch_payload_size": 1000000,
"log_batch_payload_limit": 1000000,
"mode": "DEBUG",
}
client = RPClient(*args, **kwargs)
Expand All @@ -430,7 +430,7 @@ def test_clone_with_oauth():
and cloned.launch_uuid == kwargs["launch_id"]
and cloned.launch_id == kwargs["launch_id"]
and cloned.http_timeout == kwargs["http_timeout"]
and cloned.log_batch_payload_size == kwargs["log_batch_payload_size"]
and cloned.log_batch_payload_limit == kwargs["log_batch_payload_limit"]
and cloned.mode == kwargs["mode"]
)
assert cloned._item_stack.qsize() == 1 and client.current_item() == cloned.current_item()
Expand Down
26 changes: 26 additions & 0 deletions tests/test_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,29 @@
def test_client_factory_types(requested_type: ClientType, expected_type):
result = create_client(requested_type, "http://endpoint", "default_personal", api_key="test_api_key")
assert isinstance(result, expected_type)


@pytest.mark.parametrize(
"client_type",
[
ClientType.SYNC,
ClientType.ASYNC,
ClientType.ASYNC_THREAD,
ClientType.ASYNC_BATCHED,
],
)
def test_client_factory_payload_size_warning(client_type: ClientType):
payload_size = 123
with pytest.warns(DeprecationWarning) as warnings:
# noinspection PyArgumentList
client = create_client(
client_type,
"http://endpoint",
"default_personal",
api_key="test_api_key",
log_batch_payload_size=payload_size,
)
assert "Your agent is using `log_batch_payload_size` property" in warnings[0].message.args[0]

# noinspection PyUnresolvedReferences
assert client.log_batch_payload_limit == payload_size