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

Docker-based integration tests #6712

Open
chrahunt opened this issue Jul 14, 2019 · 2 comments
Open

Docker-based integration tests #6712

chrahunt opened this issue Jul 14, 2019 · 2 comments
Labels
C: tests Testing and related things state: needs discussion This needs some more discussion type: maintenance Related to Development and Maintenance Processes

Comments

@chrahunt
Copy link
Member

chrahunt commented Jul 14, 2019

What's the problem this feature will solve?

When writing automated tests for issues that depend on system setup or environment, stubbing out or mocking the related interfaces can be difficult or less robust than full integration tests:

  1. changing the configuration, for example to use a specific configuration file, changes the actual code paths taken
  2. mocking system-related functions (e.g. os.* or ssl.*) creates a maintenance overhead if we change the implementation later
  3. the isolation may be incomplete (see Isolation issues in tests/functional/test_help.py #5957)

Describe the solution you'd like

Use Docker to execute integration tests that can be invoked locally (opt-in) and in CI.

This should not impact existing functional and unit tests, but enable new test strategies for scenarios that require more isolation or prerequisites that depend on global state in the OS, filesystem, or network.

Examples that could benefit:

  1. Installing wheel with different users  #2125
  2. Isolation issues in tests/functional/test_help.py #5957
  3. virtualenv with --system-site-packages breaks pip's build isolation #6264
  4. noexec /tmp causes pip install to miss chmod +x on scripts included in wheel file #6364
  5. Test failures occur when running from inside a linked worktree #6707

The specific tasks required to close this issue would probably be:

  1. Basic interface for interacting with and executing commands in a running container - similar functionality to tests.lib.PipTestEnvironment.
  2. At least one test showing usage of the above, e.g. demonstrating pip behavior which requires reading edited global pip.conf
  3. Integration with CI

Alternative Solutions

  1. Continue using strictly in-process/environment-based isolation and redirection for tests.
  2. Using Docker-based integration tests, but running the tests from inside the container. This may be slower and depending on the specific test case we may need to opt-out of currently global behavior (e.g. any fixture with autouse=True). This would also need some higher-level orchestration or commands to actually execute and accumulate the test output.
  3. Keeping integration tests in a separate repository.

Additional context

Azure pipelines support Docker for Linux (via ubuntu-16.04) and Windows (via win1803) per this page.

There is not a clear winner with regards to pytest plugins, but having a simple helper that executes commands in a container spawned from a pre-defined image (or one of a set created for the test) should not be too much.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jul 14, 2019
@chrahunt chrahunt added C: tests Testing and related things type: maintenance Related to Development and Maintenance Processes labels Jul 14, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Jul 14, 2019
@chrahunt chrahunt added the state: needs discussion This needs some more discussion label Jul 14, 2019
@pfmoore
Copy link
Member

pfmoore commented Jul 14, 2019

How would this impact people running the tests locally? Would we then require docker? (A non-trivial requirement on Windows, at least)

@chrahunt
Copy link
Member Author

chrahunt commented Jul 14, 2019

If this is opt-in as proposed then it should have no impact unless explicitly requested (e.g. tox -e docker).

In terms of requirements on contributors in general, I think it's OK to let CI handle testing that is not possible locally, though the feedback loop will be longer than if running locally. We can address this in developer documentation or a dedicated issue label for issues related to pain points in development environment setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: tests Testing and related things state: needs discussion This needs some more discussion type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

No branches or pull requests

2 participants