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

CPU consumption fix, missed Test Case ID bypass fix #169

Merged
merged 31 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
047ba5b
Fix for CPU consumption
HardNorth Jan 17, 2022
309ab78
Style fixes
HardNorth Jan 17, 2022
435c3c0
Style fixes
HardNorth Jan 17, 2022
d9d2399
Constructor annotations fix
HardNorth Jan 25, 2022
db1763b
Add TestCaseID bypass
HardNorth Feb 10, 2022
2e3786f
Review fixes
HardNorth Feb 11, 2022
8b73ab6
'evaluate_status' helper method add
HardNorth Feb 16, 2022
f100135
Docstring add
HardNorth Feb 16, 2022
be2e0a3
'evaluate_status' method removed
HardNorth Feb 17, 2022
245dd82
Compilation fixes
HardNorth Feb 17, 2022
1f496f2
None status handling
HardNorth Feb 17, 2022
9dddcd7
pydoc fix
HardNorth Feb 17, 2022
9bbc76e
Add processing priority
HardNorth Feb 24, 2022
38dad2d
Priority handling update
HardNorth Mar 1, 2022
9fc52ba
Import fix
HardNorth Mar 1, 2022
84b090b
Processing fix
HardNorth Mar 1, 2022
49f13d3
Priority tuning
HardNorth Mar 1, 2022
918375d
Deserialization thread start fixes
HardNorth Mar 2, 2022
d25e041
flake8 fixes
HardNorth Mar 2, 2022
74ab065
Direct worker stop wait changed on conditional lock
HardNorth Mar 3, 2022
b2d3ae4
Start / stop updated to avoid infinitive waits
HardNorth Mar 4, 2022
5e93ca8
ExternalSystemIssue field name fix
HardNorth Mar 10, 2022
18e95b1
Type annotation fix
HardNorth Mar 12, 2022
f416cd6
Remove redundant field declaration
HardNorth Mar 12, 2022
ee6e803
A comment fix
HardNorth Mar 12, 2022
7ba5471
Queue noe declared as PriorityQueue in type annotations
HardNorth Mar 12, 2022
24b2c9e
Reverting redundant changes in helpers
HardNorth Mar 12, 2022
4fcc808
Copyright year fix
HardNorth Mar 12, 2022
554a2f4
Review fix
HardNorth Mar 14, 2022
9bce826
Revert "Review fix"
HardNorth Mar 14, 2022
6bcea12
Review fix
HardNorth Mar 14, 2022
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
41 changes: 23 additions & 18 deletions reportportal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
limitations under the License.
"""
import logging

import requests
from requests.adapters import HTTPAdapter

Expand Down Expand Up @@ -113,7 +114,7 @@ def finish_launch(self,
def finish_test_item(self,
item_id,
end_time,
status,
status=None,
issue=None,
attributes=None,
description=None,
Expand All @@ -125,7 +126,7 @@ def finish_test_item(self,
:param end_time: Test item end time
:param status: Test status. Allowable values: "passed",
"failed", "stopped", "skipped", "interrupted",
"cancelled"
"cancelled" or None
:param attributes: Test item attributes(tags). Pairs of key and value.
Overrides attributes on start
:param description: Test item description. Overrides description
Expand Down Expand Up @@ -276,24 +277,27 @@ def start_test_item(self,
has_stats=True,
code_ref=None,
retry=False,
test_case_id=None,
**kwargs):
"""Start case/step/nested step item.

:param name: Name of the test item
:param start_time: Test item start time
:param item_type: Type of the test item. Allowable values: "suite",
"story", "test", "scenario", "step",
"before_class", "before_groups", "before_method",
"before_suite", "before_test", "after_class",
"after_groups", "after_method", "after_suite",
"after_test"
:param attributes: Test item attributes
:param code_ref: Physical location of the test item
:param description: Test item description
:param has_stats: Set to False if test item is nested step
:param parameters: Set of parameters (for parametrized test items)
:param retry: Used to report retry of the test. Allowable values:
"True" or "False"
:param name: Name of the test item
:param start_time: Test item start time
:param item_type: Type of the test item. Allowable values:
"suite", "story", "test", "scenario", "step",
"before_class", "before_groups",
"before_method", "before_suite",
"before_test", "after_class", "after_groups",
"after_method", "after_suite", "after_test"
:param attributes: Test item attributes
:param code_ref: Physical location of the test item
:param description: Test item description
:param has_stats: Set to False if test item is nested step
:param parameters: Set of parameters (for parametrized test items)
:param parent_item_id: An ID of a parent SUITE / STEP
:param retry: Used to report retry of the test. Allowable
values: "True" or "False"
:param test_case_id: A unique ID of the current step
"""
if parent_item_id:
url = uri_join(self.base_url_v2, 'item', parent_item_id)
Expand All @@ -309,7 +313,8 @@ def start_test_item(self,
description=description,
has_stats=has_stats,
parameters=parameters,
retry=retry
retry=retry,
test_case_id=test_case_id
).payload
response = HttpRequest(self.session.post,
url=url,
Expand Down
20 changes: 8 additions & 12 deletions reportportal_client/core/log_manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""This module contains management functionality for processing logs.

Copyright (c) 2018 http://reportportal.io .
Copyright (c) 2018 https://reportportal.io .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,7 +14,6 @@

import logging
from threading import Lock
from time import sleep

from six.moves import queue

Expand All @@ -26,7 +25,6 @@
)
from reportportal_client.core.worker import APIWorker


logger = logging.getLogger(__name__)


Expand All @@ -51,8 +49,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name,
self._logs_batch = []
self._worker = None
self.api_version = api_version
self.command_queue = queue.Queue()
self.data_queue = queue.PriorityQueue()
self.queue = queue.PriorityQueue()
self.launch_id = launch_id
self.log_batch_size = log_batch_size
self.project_name = project_name
Expand Down Expand Up @@ -81,7 +78,7 @@ def _send_batch(self):
self.session.post, self._log_endpoint, files=batch.payload,
verify_ssl=self.verify_ssl)
batch.http_request = http_request
self._worker.send_request(batch)
self._worker.send(batch)
self._logs_batch.clear()

def log(self, time, message=None, level=None, attachment=None,
Expand All @@ -102,20 +99,19 @@ def log(self, time, message=None, level=None, attachment=None,
def start(self):
"""Create a new instance of the Worker class and start it."""
if not self._worker:
self._worker = APIWorker(self.command_queue, self.data_queue)
self._worker.start()
# the worker might be already created in case of deserialization
self._worker = APIWorker(self.queue)
self._worker.start()

def stop(self):
"""Send last batches to the worker followed by the stop command."""
if self._worker:
with self._lock:
if self._logs_batch:
self._send_batch()
self._worker.stop()
logger.debug('Waiting for worker {0} to complete'
'processing batches.'.format(self._worker))
while self._worker.is_alive():
sleep(0.1)
self._worker.stop()

def stop_force(self):
"""Send stop immediate command to the worker."""
Expand Down
3 changes: 1 addition & 2 deletions reportportal_client/core/log_manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class LogManager:
_logs_batch: List = ...
_worker: Optional[APIWorker] = ...
api_version: Text = ...
command_queue: queue.Queue = ...
data_queue: queue.PriorityQueue = ...
queue: queue.PriorityQueue = ...
launch_id: Text = ...
log_batch_size: int = ...
project_name: Text = ...
Expand Down
2 changes: 1 addition & 1 deletion reportportal_client/core/rp_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self,
def payload(self):
"""Form the correct dictionary for the BTS issue."""
return {
'brsUrl': self.bts_url,
'btsUrl': self.bts_url,
'btsProject': self.bts_project,
'submitDate': self.submit_date,
'ticketId': self.ticket_id,
Expand Down
5 changes: 3 additions & 2 deletions reportportal_client/core/rp_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ def payload(self):
"""Get HTTP payload for the request."""
if self.attributes and isinstance(self.attributes, dict):
self.attributes = dict_to_payload(self.attributes)
if self.issue is None and self.status.lower() == 'skipped' and not \
self.is_skipped_an_issue:
if self.issue is None and (
self.status is not None and self.status.lower() == 'skipped'
) and not self.is_skipped_an_issue:
issue_payload = {'issue_type': 'NOT_ISSUE'}
else:
issue_payload = None
Expand Down
Loading