-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QE-10885 Refactor multiprocessing pool (#318)
The way cucu does multiprocessing has bugs. This PR refactored the logic related to multiprocessing. It also adds a unit test and a functional test to verily the change.
- Loading branch information
Showing
7 changed files
with
380 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "cucu" | ||
version = "0.122.0" | ||
version = "0.123.0" | ||
license = "MIT" | ||
description = "" | ||
authors = ["Rodney Gomes <[email protected]>"] | ||
|
@@ -32,15 +32,15 @@ beautifulsoup4 = "^4.11.1" | |
ansi2html = "^1.7.0" | ||
jellyfish = "^0.9.0" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^5.4.3" | ||
[tool.poetry.scripts] | ||
cucu = "cucu.cli:main" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.2.2" | ||
nox = "^2020.5.24" | ||
flake8 = "^4.0.1" | ||
ipdb = "^0.13.9" | ||
|
||
[tool.poetry.scripts] | ||
cucu = "cucu.cli:main" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.3.2"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import time | ||
|
||
from click.testing import CliRunner | ||
from cucu.cli import core | ||
from multiprocessing import Process | ||
from unittest import mock | ||
|
||
|
||
RUNTIME_TIMEOUT = 10 | ||
|
||
|
||
def process_func_to_run_cucu(workers, runtime_timeout): | ||
isdir_mock = mock.MagicMock(return_value=False) | ||
with mock.patch("os.path.isdir", isdir_mock): | ||
behave_mock = mock.MagicMock(side_effect=RuntimeError("something bad")) | ||
with mock.patch("cucu.cli.core.behave", behave_mock): | ||
runner = CliRunner() | ||
runner.invoke( | ||
core.run, | ||
f"--runtime-timeout {runtime_timeout} --workers={workers} abc", | ||
) | ||
|
||
|
||
def test_timeout_with_behave_exception_in_workers(): | ||
start = time.time() | ||
p = Process(target=process_func_to_run_cucu, args=(2, RUNTIME_TIMEOUT)) | ||
p.start() | ||
p.join() | ||
elapsed_time = time.time() - start | ||
assert elapsed_time < 5 |