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

[BUG] - test_generate_constructor_installer[simple_specification] is flaky on CI #799

Closed
peytondmurray opened this issue Mar 25, 2024 · 1 comment

Comments

@peytondmurray
Copy link
Contributor

Describe the bug

A number of the unit tests rely on connections to other servers which can intermittently fail. I think this is an instance of that. See https://github.com/conda-incubator/conda-store/actions/runs/8425949310/job/23073173256?pr=797 for details.

Expected behavior

test_generate_constructor_installer[simple_specification] passes without being flaky.

How to Reproduce the problem?

Run the unit test github workflow.

Output

============================= test session starts ==============================
platform darwin -- Python 3.10.0, pytest-8.1.1, pluggy-1.4.0
rootdir: /Users/runner/work/conda-store/conda-store/conda-store-server
configfile: pyproject.toml
plugins: celery-0.0.0a1, playwright-0.4.4, anyio-3.7.1, base-url-2.1.0, mock-3.14.0
collected 194 items / 6 deselected / 188 selected

tests/test_actions.py .......F........xx..................               [ 19%]
tests/test_app_api.py .....                                              [ 21%]
tests/test_auth.py ..................................................... [ 50%]
......                                                                   [ 53%]
tests/test_db_api.py .......                                             [ 56%]
tests/test_server.py ................................................... [ 84%]
...................                                                      [ 94%]
tests/test_testing.py .                                                  [ 94%]
tests/test_traitlets.py .........                                        [ 99%]
tests/test_usage.py .                                                    [100%]

=================================== FAILURES ===================================
__________ test_generate_constructor_installer[simple_specification] ___________

conda_store = <conda_store_server.app.CondaStore object at 0x11bfb3e80>
specification_name = 'simple_specification'
request = <FixtureRequest for <Function test_generate_constructor_installer[simple_specification]>>
tmp_path = PosixPath('/private/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/pytest-of-runner/pytest-0/test_generate_constructor_inst0')

    @pytest.mark.parametrize(
        "specification_name",
        [
            "simple_specification",
            "simple_specification_with_pip",
        ],
    )
    def test_generate_constructor_installer(
        conda_store, specification_name, request, tmp_path
    ):
        specification = request.getfixturevalue(specification_name)
        installer_dir = tmp_path / "installer_dir"
    
        # Creates the installer
>       context = action.action_generate_constructor_installer(
            conda_command=conda_store.conda_command,
            specification=specification,
            installer_dir=installer_dir,
            version="1",
        )

/Users/runner/work/conda-store/conda-store/conda-store-server/tests/test_actions.py:135: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/Users/runner/work/conda-store/conda-store/conda-store-server/conda_store_server/action/base.py:31: in wrapper
    action_context.result = f(action_context, *args, **kwargs)
/Users/runner/work/conda-store/conda-store/conda-store-server/conda_store_server/action/generate_constructor_installer.py:120: in action_generate_constructor_installer
    logged_command(context, command)
/Users/runner/work/conda-store/conda-store/conda-store-server/conda_store_server/action/utils.py:7: in logged_command
    subprocess.check_output(
/Users/runner/miniconda3/envs/test/lib/python3.10/subprocess.py:420: in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

popenargs = (['constructor', '-v', '--cache-dir', '/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/tmpgxxzyro4/pkgs', '--platform', 'osx-64', ...],)
kwargs = {'encoding': 'utf-8', 'stderr': -2, 'stdout': -1}, input = None
timeout = None, check = True
process = <Popen: returncode: 1 args: ['constructor', '-v', '--cache-dir', '/var/folde...>
stdout = "INFO:constructor.main:Got the following cli arguments: 'Namespace(debug=False, output_dir='/private/var/folders/h1/8h...hen trying to retrieve this URL.\nHTTP errors are often intermittent, and a simple retry will get you on your way.\n\n"
stderr = None, retcode = 1

    def run(*popenargs, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
        There is an optional argument "input", allowing you to
        pass a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
        The other arguments are the same as for the Popen constructor.
        If universal_newlines=True is passed, the "input" argument must be a
        string and stdout/stderr in the returned object will be strings rather than
        bytes.
        """
        input = kwargs.pop("input", None)
        timeout = kwargs.pop("timeout", None)
        check = kwargs.pop("check", False)
        if input is not None:
            if "stdin" in kwargs:
                raise ValueError("stdin and input arguments may not both be used.")
            kwargs["stdin"] = PIPE
    
        process = Popen(*popenargs, **kwargs)
        try:
            process.__enter__()  # No-Op really... illustrate "with in 2.4"
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired:
                process.kill()
                stdout, stderr = process.communicate()
                raise TimeoutExpired(
                    process.args, timeout, output=stdout, stderr=stderr
                )
            except:
                process.kill()
                process.wait()
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(
                    retcode, process.args, output=stdout, stderr=stderr
                )
E               conda_lock._vendor.poetry.utils._compat.CalledProcessError: Command '['constructor', '-v', '--cache-dir', '/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/tmpgxxzyro4/pkgs', '--platform', 'osx-64', '/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/tmpgxxzyro4/build']' returned non-zero exit status 1.

/Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/conda_lock/_vendor/poetry/utils/_compat.py:217: CalledProcessError
---------------------------- Captured stderr setup -----------------------------
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 48be4072fe58, initial schema
INFO  [alembic.runtime.migration] Running upgrade 48be4072fe58 -> 8d63a091aff8, Add Environment.description
INFO  [alembic.runtime.migration] Running upgrade 8d63a091aff8 -> 5ad723de2abd, Adding CONTAINER_REGISTRY value to enum
INFO  [alembic.runtime.migration] Running upgrade 5ad723de2abd -> 16f65805dc8f, split conda_package into conda_package and conda_package_build
INFO  [alembic.runtime.migration] Running upgrade 16f65805dc8f -> abd7248d5327, adding a settings table
INFO  [alembic.runtime.migration] Running upgrade abd7248d5327 -> b387747ca9b7, role mapping
INFO  [alembic.runtime.migration] Running upgrade b387747ca9b7 -> d78e9889566a, add status_info
INFO  [alembic.runtime.migration] Running upgrade d78e9889566a -> 30b37e725c32, add build_key_version
INFO  [alembic.runtime.migration] Running upgrade 30b37e725c32 -> 771180018e1b, add v2 role mappings
INFO  [alembic.runtime.migration] Running upgrade 771180018e1b -> 0f7e23ff24ee, add worker
INFO  [alembic.runtime.migration] Running upgrade 0f7e23ff24ee -> 57cd11b949d5, add installer
INFO  [alembic.runtime.migration] Running upgrade 57cd11b949d5 -> 03c839888c82, add canceled status
=============================== warnings summary ===============================
../../../../miniconda3/envs/test/lib/python3.10/site-packages/conda_pack/core.py:15
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/conda_pack/core.py:15: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../../../../miniconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832
../../../../miniconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832
../../../../miniconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832
../../../../miniconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

conda_store_server/action/generate_constructor_installer.py:87
  /Users/runner/work/conda-store/conda-store/conda-store-server/conda_store_server/action/generate_constructor_installer.py:87: DeprecationWarning: invalid escape sequence '\S'
    post_install = """\

../../../../miniconda3/envs/test/lib/python3.10/site-packages/traitlets/traitlets.py:3615
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/traitlets/traitlets.py:3615: DeprecationWarning: metadata {'description': 'Conda platforms to solve environments for via conda-lock. Must include current platform.'} was set from the constructor. With traitlets 4.1, metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
    super().__init__(trait=trait, default_value=default_value, **kwargs)

tests/test_server.py:419
  /Users/runner/work/conda-store/conda-store/conda-store-server/tests/test_server.py:419: PytestUnknownMarkWarning: Unknown pytest.mark.extended_prefix - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.extended_prefix

tests/test_actions.py::test_solve_lockfile[simple_specification]
  /Users/runner/work/conda-store/conda-store/conda-store-server/conda_store_server/build.py:110: DeprecationWarning: invalid escape sequence '\d'
    match = re.fullmatch("build-(\d+)-(.*)", str(task["id"]))

tests/test_actions.py::test_add_conda_prefix_packages[conda_prefix0]
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/kombu/transport/sqlalchemy/models.py:63: RemovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.  Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    self.queue = queue

tests/test_app_api.py: 1 warning
tests/test_server.py: 10 warnings
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/celery/worker/consumer/consumer.py:507: CPendingDeprecationWarning: The broker_connection_retry configuration setting will no longer determine
  whether broker connection retries are made during startup in Celery 6.0 and above.
  If you wish to retain the existing behavior for retrying connections on startup,
  you should set broker_connection_retry_on_startup to True.
    warnings.warn(

tests/test_auth.py: 16 warnings
tests/test_server.py: 70 warnings
tests/test_traitlets.py: 13 warnings
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/httpx/_client.py:680: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=WSGITransport(app=...)' instead.
    warnings.warn(message, DeprecationWarning)

tests/test_traitlets.py::test_conda_store_server_enable_ui
tests/test_traitlets.py::test_conda_store_server_url_prefix
tests/test_traitlets.py::test_conda_store_server_url_prefix
tests/test_traitlets.py::test_conda_store_server_templates
  /Users/runner/miniconda3/envs/test/lib/python3.10/site-packages/starlette/templating.py:178: DeprecationWarning: The `name` is not the first parameter anymore. The first parameter should be the `Request` instance.
  Replace `TemplateResponse(name, {"request": request})` by `TemplateResponse(request, name)`.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_actions.py::test_generate_constructor_installer[simple_specification] - conda_lock._vendor.poetry.utils._compat.CalledProcessError: Command '['constructor', '-v', '--cache-dir', '/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/tmpgxxzyro4/pkgs', '--platform', 'osx-64', '/var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/tmpgxxzyro4/build']' returned non-zero exit status 1.
= 1 failed, 185 passed, 6 deselected, 2 xfailed, 124 warnings in 806.01s (0:13:26) =
Error: Process completed with exit code 1.

Versions and dependencies used.

No response

Anything else?

No response

@peytondmurray
Copy link
Contributor Author

Not sure why this was failing originally, but in any case these calls to constructor have been mocked out in #833.

@github-project-automation github-project-automation bot moved this from New 🚦 to Done 💪🏾 in conda-store 🐍 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant