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

Make integration tests more responsive #4329

Merged
merged 2 commits into from
Feb 24, 2023
Merged
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
23 changes: 20 additions & 3 deletions openbb_terminal/core/integration_tests/integration_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from multiprocessing.pool import Pool
from pathlib import Path
from traceback import FrameSummary, extract_tb, format_list
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple

from openbb_terminal.core.config.paths import (
MISCELLANEOUS_DIRECTORY,
Expand Down Expand Up @@ -353,6 +353,7 @@ def run_test_files(
verbose: bool = False,
special_arguments: Optional[Dict[str, str]] = None,
subprocesses: Optional[int] = None,
ordered: bool = False,
) -> Tuple[int, int, Dict[str, Dict[str, Any]], float]:
"""Runs the test scripts and returns the fails dictionary

Expand All @@ -366,6 +367,8 @@ def run_test_files(
The special arguments to use in the scripts
subprocesses: Optional[int]
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order

Returns
-------
Expand Down Expand Up @@ -410,8 +413,10 @@ def run_test_files(
if extra:
chunksize += 1

runner: Callable = pool.imap if ordered else pool.imap_unordered

for i, result in enumerate(
pool.imap(
runner(
partial(
run_test,
verbose=verbose,
Expand Down Expand Up @@ -531,6 +536,7 @@ def run_test_session(
special_arguments: Optional[Dict[str, str]] = None,
verbose: bool = False,
subprocesses: Optional[int] = None,
ordered: bool = False,
):
"""Run the integration test session

Expand All @@ -552,11 +558,13 @@ def run_test_session(
Whether or not to print the output of the scripts
subprocesses
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order.
"""
console.print(to_section_title("integration test session starts"), style="bold")
test_files = collect_test_files(path_list, skip_list)
n_successes, n_failures, fails, seconds = run_test_files(
test_files, verbose, special_arguments, subprocesses
test_files, verbose, special_arguments, subprocesses, ordered
)
display_failures(fails)
display_summary(fails, n_successes, n_failures, seconds)
Expand Down Expand Up @@ -645,6 +653,14 @@ def parse_args_and_run():
action="store_true",
default=False,
)
parser.add_argument(
"-o",
"--ordered",
help="Multiprocessing is not ordered by default. Use this flag to run the tests in order.",
dest="ordered",
action="store_true",
default=False,
)
for arg in special_arguments_values:
parser.add_argument(
f"--{arg}",
Expand Down Expand Up @@ -680,6 +696,7 @@ def parse_args_and_run():
special_arguments=special_args_dict,
verbose=ns_parser.verbose,
subprocesses=ns_parser.subprocesses,
ordered=ns_parser.ordered,
)


Expand Down