Skip to content

Commit ae94f52

Browse files
authored
CPU consumption fix, missed Test Case ID bypass fix
1 parent 0bf36d7 commit ae94f52

File tree

9 files changed

+142
-115
lines changed

9 files changed

+142
-115
lines changed

reportportal_client/client.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
limitations under the License.
1616
"""
1717
import logging
18+
1819
import requests
1920
from requests.adapters import HTTPAdapter
2021

@@ -113,7 +114,7 @@ def finish_launch(self,
113114
def finish_test_item(self,
114115
item_id,
115116
end_time,
116-
status,
117+
status=None,
117118
issue=None,
118119
attributes=None,
119120
description=None,
@@ -125,7 +126,7 @@ def finish_test_item(self,
125126
:param end_time: Test item end time
126127
:param status: Test status. Allowable values: "passed",
127128
"failed", "stopped", "skipped", "interrupted",
128-
"cancelled"
129+
"cancelled" or None
129130
:param attributes: Test item attributes(tags). Pairs of key and value.
130131
Overrides attributes on start
131132
:param description: Test item description. Overrides description
@@ -276,24 +277,27 @@ def start_test_item(self,
276277
has_stats=True,
277278
code_ref=None,
278279
retry=False,
280+
test_case_id=None,
279281
**kwargs):
280282
"""Start case/step/nested step item.
281283
282-
:param name: Name of the test item
283-
:param start_time: Test item start time
284-
:param item_type: Type of the test item. Allowable values: "suite",
285-
"story", "test", "scenario", "step",
286-
"before_class", "before_groups", "before_method",
287-
"before_suite", "before_test", "after_class",
288-
"after_groups", "after_method", "after_suite",
289-
"after_test"
290-
:param attributes: Test item attributes
291-
:param code_ref: Physical location of the test item
292-
:param description: Test item description
293-
:param has_stats: Set to False if test item is nested step
294-
:param parameters: Set of parameters (for parametrized test items)
295-
:param retry: Used to report retry of the test. Allowable values:
296-
"True" or "False"
284+
:param name: Name of the test item
285+
:param start_time: Test item start time
286+
:param item_type: Type of the test item. Allowable values:
287+
"suite", "story", "test", "scenario", "step",
288+
"before_class", "before_groups",
289+
"before_method", "before_suite",
290+
"before_test", "after_class", "after_groups",
291+
"after_method", "after_suite", "after_test"
292+
:param attributes: Test item attributes
293+
:param code_ref: Physical location of the test item
294+
:param description: Test item description
295+
:param has_stats: Set to False if test item is nested step
296+
:param parameters: Set of parameters (for parametrized test items)
297+
:param parent_item_id: An ID of a parent SUITE / STEP
298+
:param retry: Used to report retry of the test. Allowable
299+
values: "True" or "False"
300+
:param test_case_id: A unique ID of the current step
297301
"""
298302
if parent_item_id:
299303
url = uri_join(self.base_url_v2, 'item', parent_item_id)
@@ -309,7 +313,8 @@ def start_test_item(self,
309313
description=description,
310314
has_stats=has_stats,
311315
parameters=parameters,
312-
retry=retry
316+
retry=retry,
317+
test_case_id=test_case_id
313318
).payload
314319
response = HttpRequest(self.session.post,
315320
url=url,

reportportal_client/core/log_manager.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""This module contains management functionality for processing logs.
22
3-
Copyright (c) 2018 http://reportportal.io .
3+
Copyright (c) 2018 https://reportportal.io .
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
7-
http://www.apache.org/licenses/LICENSE-2.0
7+
https://www.apache.org/licenses/LICENSE-2.0
88
Unless required by applicable law or agreed to in writing, software
99
distributed under the License is distributed on an "AS IS" BASIS,
1010
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,7 +14,6 @@
1414

1515
import logging
1616
from threading import Lock
17-
from time import sleep
1817

1918
from six.moves import queue
2019

@@ -26,7 +25,6 @@
2625
)
2726
from reportportal_client.core.worker import APIWorker
2827

29-
3028
logger = logging.getLogger(__name__)
3129

3230

@@ -51,8 +49,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name,
5149
self._logs_batch = []
5250
self._worker = None
5351
self.api_version = api_version
54-
self.command_queue = queue.Queue()
55-
self.data_queue = queue.PriorityQueue()
52+
self.queue = queue.PriorityQueue()
5653
self.launch_id = launch_id
5754
self.log_batch_size = log_batch_size
5855
self.project_name = project_name
@@ -81,7 +78,7 @@ def _send_batch(self):
8178
self.session.post, self._log_endpoint, files=batch.payload,
8279
verify_ssl=self.verify_ssl)
8380
batch.http_request = http_request
84-
self._worker.send_request(batch)
81+
self._worker.send(batch)
8582
self._logs_batch.clear()
8683

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

108106
def stop(self):
109107
"""Send last batches to the worker followed by the stop command."""
110108
if self._worker:
111109
with self._lock:
112110
if self._logs_batch:
113111
self._send_batch()
114-
self._worker.stop()
115112
logger.debug('Waiting for worker {0} to complete'
116113
'processing batches.'.format(self._worker))
117-
while self._worker.is_alive():
118-
sleep(0.1)
114+
self._worker.stop()
119115

120116
def stop_force(self):
121117
"""Send stop immediate command to the worker."""

reportportal_client/core/log_manager.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class LogManager:
2121
_logs_batch: List = ...
2222
_worker: Optional[APIWorker] = ...
2323
api_version: Text = ...
24-
command_queue: queue.Queue = ...
25-
data_queue: queue.PriorityQueue = ...
24+
queue: queue.PriorityQueue = ...
2625
launch_id: Text = ...
2726
log_batch_size: int = ...
2827
project_name: Text = ...

reportportal_client/core/rp_issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(self,
109109
def payload(self):
110110
"""Form the correct dictionary for the BTS issue."""
111111
return {
112-
'brsUrl': self.bts_url,
112+
'btsUrl': self.bts_url,
113113
'btsProject': self.bts_project,
114114
'submitDate': self.submit_date,
115115
'ticketId': self.ticket_id,

reportportal_client/core/rp_requests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,9 @@ def payload(self):
340340
"""Get HTTP payload for the request."""
341341
if self.attributes and isinstance(self.attributes, dict):
342342
self.attributes = dict_to_payload(self.attributes)
343-
if self.issue is None and self.status.lower() == 'skipped' and not \
344-
self.is_skipped_an_issue:
343+
if self.issue is None and (
344+
self.status is not None and self.status.lower() == 'skipped'
345+
) and not self.is_skipped_an_issue:
345346
issue_payload = {'issue_type': 'NOT_ISSUE'}
346347
else:
347348
issue_payload = None

0 commit comments

Comments
 (0)