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

Test #964

Closed
wants to merge 6 commits into from
Closed

Test #964

Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ jobs:
# Tell Launchable about the build you are producing and testing
launchable record build --name ${GITHUB_RUN_ID}

launchable record session --build ${GITHUB_RUN_ID} --flavor os=${{ matrix.os }} --flavor python=${{ matrix.python-version }} > session.txt
launchable record session --observation --build ${GITHUB_RUN_ID} --flavor os=${{ matrix.os }} --flavor python=${{ matrix.python-version }} > session.txt

# Find 25% of the relevant tests to run for this change
find tests -name test_*.py | grep -v tests/data | launchable subset --target 25% --session $(cat session.txt) --rest launchable-remainder.txt file > subset.txt
find tests -name test_*.py | grep -v tests/data | launchable subset --non-blocking --target 25% --session $(cat session.txt) --rest launchable-remainder.txt file > subset.txt

function record() {
# Record test results
Expand Down
25 changes: 23 additions & 2 deletions launchable/commands/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import pathlib
import sys
from multiprocessing import Process
from os.path import join
from typing import Any, Callable, Dict, List, Optional, Sequence, TextIO, Tuple, Union

Expand Down Expand Up @@ -131,10 +132,17 @@
help="outputs the exclude test list. Switch the subset and rest.",
is_flag=True,
)
@click.option(
"--non-blocking",
"is_non_blocking",
help="Do not wait for subset requests in observation mode.",
is_flag=True,
hidden=True,
)
@click.option(
"--ignore-flaky-tests-above",
"ignore_flaky_tests_above",
help='Ignore flaky tests above the value set by this option.You can confirm flaky scores in WebApp',
help='Ignore flaky tests above the value set by this option. You can confirm flaky scores in WebApp',
type=click.FloatRange(min=0, max=1.0),
)
@click.option(
Expand Down Expand Up @@ -198,6 +206,7 @@ def subset(
is_observation: bool,
is_get_tests_from_previous_sessions: bool,
is_output_exclusion_rules: bool,
is_non_blocking: bool,
ignore_flaky_tests_above: Optional[float],
links: Sequence[Tuple[str, str]] = (),
is_no_build: bool = False,
Expand Down Expand Up @@ -493,7 +502,15 @@ def run(self):
timeout = (5, 300)
payload = self.get_payload(session_id, target, duration, test_runner)

res = client.request("post", "subset", timeout=timeout, payload=payload, compress=True)
if is_non_blocking:
# Create a new process for requesting a subset.
process = Process(target=subset_request, args=(client, timeout, payload))
process.start()
click.echo("The subset was requested in non-blocking mode.", err=True)
self.output_handler(self.test_paths, [])
return

res = subset_request(client=client, timeout=timeout, payload=payload)

# The status code 422 is returned when validation error of the test mapping file occurs.
if res.status_code == 422:
Expand Down Expand Up @@ -600,3 +617,7 @@ def run(self):
err=True)

context.obj = Optimize(app=context.obj)


def subset_request(client: LaunchableClient, timeout: Tuple[int, int], payload: Dict[str, Any]):
return client.request("post", "subset", timeout=timeout, payload=payload, compress=True)