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

Flaky tests: tests/cli/test_server.py #11123

Closed
4 tasks done
zangell44 opened this issue Nov 8, 2023 · 1 comment
Closed
4 tasks done

Flaky tests: tests/cli/test_server.py #11123

zangell44 opened this issue Nov 8, 2023 · 1 comment
Assignees
Labels
development Tech debt, refactors, CI, tests, and other related work.

Comments

@zangell44
Copy link
Collaborator

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

The following tests are flaky, 2 runs was not enough for them to pass reliably.

@pytest.mark.parametrize("command_group", ["server"])
def test_start_no_options(mock_run_process: AsyncMock, command_group: str):
    invoke_and_assert(
        [command_group, "start"],
        expected_output_contains=[
            "prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api",
            "View the API reference documentation at http://127.0.0.1:4200/docs",
        ],
    )
    mock_run_process.assert_awaited_once_with(
        command=[
            sys.executable,
            "-m",
            "uvicorn",
            "--app-dir",
            f'"{prefect.__module_path__.parent}"',  # note, wrapped in double quotes
            "--factory",
            "prefect.server.api.server:create_app",
            "--host",
            "127.0.0.1",
            "--port",
            "4200",
            "--timeout-keep-alive",
            "5",
        ],
        env=ANY,
        stream_output=True,
        task_status=ANY,
    )


def test_start_with_keep_alive_from_setting(mock_run_process: AsyncMock):
    with temporary_settings({PREFECT_SERVER_API_KEEPALIVE_TIMEOUT: 100}):
        invoke_and_assert(["server", "start"])

    mock_run_process.assert_awaited_once()
    command: List[str] = mock_run_process.call_args[1]["command"]
    assert "--timeout-keep-alive" in command
    assert command[command.index("--timeout-keep-alive") + 1] == "100"


def test_start_from_cli_with_keep_alive(mock_run_process: AsyncMock):
    invoke_and_assert(
        ["server", "start", "--keep-alive-timeout", "100"],
        expected_output_contains=[
            "prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api",
            "View the API reference documentation at http://127.0.0.1:4200/docs",
        ],
    )

    mock_run_process.assert_awaited_once()
    command: List[str] = mock_run_process.call_args[1]["command"]
    assert "--timeout-keep-alive" in command
    assert command[command.index("--timeout-keep-alive") + 1] == "100"

Reproduction

`pytest tests/test_server.py`

Error

FAILED tests/cli/test_server.py::test_start_no_options[server] - ValueError: signal only works in main thread
FAILED tests/cli/test_server.py::test_start_with_keep_alive_from_setting - ValueError: signal only works in main thread
FAILED tests/cli/test_server.py::test_start_from_cli_with_keep_alive - ValueError: signal only works in main thread

Versions

`main`

Additional context

No response

@zangell44 zangell44 added bug Something isn't working needs:triage labels Nov 8, 2023
@zangell44 zangell44 mentioned this issue Nov 8, 2023
4 tasks
@serinamarie serinamarie added development Tech debt, refactors, CI, tests, and other related work. and removed bug Something isn't working needs:triage labels Nov 9, 2023
@serinamarie serinamarie assigned serinamarie and unassigned abrookins Feb 5, 2024
@serinamarie
Copy link
Contributor

Closed by #11552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work.
Projects
None yet
Development

No branches or pull requests

3 participants