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

Shorten too long test UNIX socket path #3832

Merged
merged 14 commits into from
Jun 11, 2019
Merged

Conversation

webknjaz
Copy link
Member

@webknjaz webknjaz commented Jun 9, 2019

What do these changes do?

Make tmp unix sock path fit the kernel limits

Are there changes in behavior for the user?

Related issue number

Fixes #3572

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@webknjaz webknjaz force-pushed the bugfix/unix-sock-path-too-long branch from 0306e04 to 52db4a1 Compare June 9, 2019 13:20
@webknjaz
Copy link
Member Author

webknjaz commented Jun 9, 2019

@asvetlov should be good to go now. Plz test on your machine as well :)

@webknjaz webknjaz changed the title [WIP] Fix UNIX sock path too long in tests Fix UNIX sock path too long in tests Jun 9, 2019
@webknjaz webknjaz marked this pull request as ready for review June 9, 2019 13:20

root_tmp_dir = Path('/tmp').resolve()
os_tmp_dir = Path(os.getenv('TMPDIR', '/tmp')).resolve()
original_base_tmp_path = Path(tmp_path_factory.getbasetemp())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Path() convertion required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just nice for the unified API and paths comparison.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole PR can be replaced with PYTEST_DEBUG_TEMPROOT=/tmp in CI config, isn't it?

@webknjaz
Copy link
Member Author

webknjaz commented Jun 9, 2019

@asvetlov I wanted something more generic and detached from CI.


root_tmp_dir = Path('/tmp').resolve()
os_tmp_dir = Path(os.getenv('TMPDIR', '/tmp')).resolve()
original_base_tmp_path = Path(str(tmp_path_factory.getbasetemp()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for Path -> str -> Path conversion?
If there is something please describe it in a comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do the comparison in a few places below. So I need a few Path() objects.
And str() in this line is only needed for Python 3.5 support which apparently cannot do this by its own.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider the alternative:

  1. Keep unix_sockname fixture. Drop all the rest: need_unix marker, IS_ constants etc.
  2. In unix_sockname always create a socket path as /tmp/{uuid}.sock on systems with AF_UNIX, otherwise call pytest.skip(). The code should be about 5 lines long.

What do you think?

@webknjaz
Copy link
Member Author

I think that the pytest's default place for the socket creation is better because it's better scoped. /tmp should be used as a fallback because it's harder to track the location when searching for stuff in the file system, during debugging, for example. So I'd like to keep a better-designed layout while having a fallback for corner cases.

@webknjaz
Copy link
Member Author

P.S. In general, I like the marker more as it's cleaner.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, please merge when green.

I don't care too much honestly but can live with the PR if you did all work already :)

@webknjaz webknjaz force-pushed the bugfix/unix-sock-path-too-long branch from 491924d to 5825337 Compare June 10, 2019 14:19
@codecov-io

This comment has been minimized.

1 similar comment
@codecov-io

This comment has been minimized.

@webknjaz webknjaz changed the title Fix UNIX sock path too long in tests Shorten too long test UNIX socket path Jun 11, 2019
@webknjaz webknjaz merged commit 8e9e39b into master Jun 11, 2019
@asvetlov asvetlov deleted the bugfix/unix-sock-path-too-long branch June 11, 2019 13:38
@patchback
Copy link
Contributor

patchback bot commented Sep 6, 2022

Backport to 3.8: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 8e9e39b on top of patchback/backports/3.8/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832

Backporting merged PR #3832 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.8/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832 upstream/3.8
  4. Now, cherry-pick PR Shorten too long test UNIX socket path #3832 contents into that branch:
    $ git cherry-pick -x 8e9e39b61e118f00029a1d9300323fdcd7f0ff67
    If it'll yell at you with something like fatal: Commit 8e9e39b61e118f00029a1d9300323fdcd7f0ff67 is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x 8e9e39b61e118f00029a1d9300323fdcd7f0ff67
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Shorten too long test UNIX socket path #3832 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.8/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link
Contributor

patchback bot commented Sep 6, 2022

Backport to 3.9: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 8e9e39b on top of patchback/backports/3.9/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832

Backporting merged PR #3832 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.9/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832 upstream/3.9
  4. Now, cherry-pick PR Shorten too long test UNIX socket path #3832 contents into that branch:
    $ git cherry-pick -x 8e9e39b61e118f00029a1d9300323fdcd7f0ff67
    If it'll yell at you with something like fatal: Commit 8e9e39b61e118f00029a1d9300323fdcd7f0ff67 is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x 8e9e39b61e118f00029a1d9300323fdcd7f0ff67
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Shorten too long test UNIX socket path #3832 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.9/8e9e39b61e118f00029a1d9300323fdcd7f0ff67/pr-3832
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSError: AF_UNIX path too long under MacOS
3 participants