|
6 | 6 | from launchable.app import Application |
7 | 7 | from launchable.commands.helper import find_or_create_session |
8 | 8 | from launchable.commands.test_path_writer import TestPathWriter |
| 9 | +from launchable.testpath import unparse_test_path |
9 | 10 | from launchable.utils.click import ignorable_error |
10 | 11 | from launchable.utils.env_keys import REPORT_ERROR_KEY |
11 | 12 | from launchable.utils.launchable_client import LaunchableClient |
12 | 13 | from launchable.utils.tracking import Tracking, TrackingClient |
13 | 14 |
|
14 | | -from ...utils.commands import Command |
| 15 | +from ..utils.commands import Command |
15 | 16 |
|
16 | 17 |
|
17 | 18 | @click.group(help="Early flake detection") |
|
23 | 24 | required=True |
24 | 25 | ) |
25 | 26 | @click.option( |
26 | | - '--confidence', |
27 | | - help='Confidence level for flake detection', |
| 27 | + '--retry-threshold', |
| 28 | + 'retry_threshold', |
| 29 | + help='Throughness of how "flake" is detected', |
28 | 30 | type=click.Choice(['low', 'medium', 'high'], case_sensitive=False), |
| 31 | + default='medium', |
29 | 32 | required=True, |
30 | 33 | ) |
31 | 34 | @click.pass_context |
32 | | -def flake_detection(ctx, confidence, session): |
33 | | - tracking_client = TrackingClient(Command.FLAKE_DETECTION, app=ctx.obj) |
| 35 | +def detect_flakes(ctx, retry_threshold, session): |
| 36 | + tracking_client = TrackingClient(Command.DETECT_FLAKE, app=ctx.obj) |
34 | 37 | client = LaunchableClient(app=ctx.obj, tracking_client=tracking_client, test_runner=ctx.invoked_subcommand) |
35 | 38 | session_id = None |
36 | 39 | try: |
@@ -64,15 +67,18 @@ def run(self): |
64 | 67 | try: |
65 | 68 | res = client.request( |
66 | 69 | "get", |
67 | | - "retry/flake-detection", |
| 70 | + "detect-flake", |
68 | 71 | params={ |
69 | | - "confidence": confidence.upper(), |
| 72 | + "confidence": retry_threshold.upper(), |
70 | 73 | "session-id": os.path.basename(session_id), |
71 | 74 | "test-runner": ctx.invoked_subcommand}) |
72 | 75 | res.raise_for_status() |
73 | 76 | test_paths = res.json().get("testPaths", []) |
74 | 77 | if test_paths: |
75 | 78 | self.print(test_paths) |
| 79 | + click.echo("Trying to retry the following tests:", err=True) |
| 80 | + for detail in res.json().get("testDetails", []): |
| 81 | + click.echo(f"{detail.get('reason')}: {unparse_test_path(detail.get('fullTestPath'))}", err=True) |
76 | 82 | except Exception as e: |
77 | 83 | tracking_client.send_error_event( |
78 | 84 | event_name=Tracking.ErrorEvent.INTERNAL_CLI_ERROR, |
|
0 commit comments