Skip to content

Commit c419a22

Browse files
committed
Fixed Plugin Exception in case of Launch creation timed out
1 parent fc85938 commit c419a22

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

CHANGELOG.md

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

33
## [Unreleased]
4+
### Fixed
5+
- Plugin Exception in case of Launch creation timed out, by @HardNorth
46
### Changed
57
- Client version updated on [5.3.1](https://github.com/reportportal/client-Python/releases/tag/5.3.1), by @HardNorth
68

pytest_reportportal/plugin.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
"""This module contains changed pytest for report-portal."""
22

3+
# Copyright (c) 2023 https://reportportal.io .
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
316
import logging
4-
# This program is free software: you can redistribute it
5-
# and/or modify it under the terms of the GPL licence
617
import os.path
718
import time
819

@@ -59,8 +70,9 @@ def wait_launch(rp_client):
5970
timeout = time.time() + LAUNCH_WAIT_TIMEOUT
6071
while not rp_client.launch_id:
6172
if time.time() > timeout:
62-
raise Exception("Launch has not started.")
73+
return False
6374
time.sleep(1)
75+
return True
6476

6577

6678
# noinspection PyProtectedMember
@@ -90,7 +102,12 @@ def pytest_sessionstart(session):
90102
config.py_test_service.start_launch()
91103
if config.pluginmanager.hasplugin('xdist') \
92104
or config.pluginmanager.hasplugin('pytest-parallel'):
93-
wait_launch(session.config.py_test_service.rp)
105+
if not wait_launch(session.config.py_test_service.rp):
106+
log.error('Failed to initialize reportportal-client service. '
107+
'Waiting for Launch start timed out. '
108+
'Reporting is disabled.')
109+
config.py_test_service.rp = None
110+
config._rp_enabled = False
94111

95112

96113
def pytest_collection_finish(session):

pytest_reportportal/plugin.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MANDATORY_PARAMETER_MISSED_PATTERN: Text
1515

1616
def check_connection(agent_config: AgentConfig) -> bool: ...
1717
def is_control(config: Config) -> bool: ...
18-
def wait_launch(rp_client: RPClient) -> None: ...
18+
def wait_launch(rp_client: RPClient) -> bool: ...
1919
def pytest_configure_node(node: WorkerController) -> None: ...
2020
def pytest_sessionstart(session: Session) -> None: ...
2121
def pytest_collection_finish(session: Session) -> None: ...

0 commit comments

Comments
 (0)