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

Generated socket files are to long #310

Closed
koffie opened this issue May 23, 2021 · 6 comments
Closed

Generated socket files are to long #310

koffie opened this issue May 23, 2021 · 6 comments

Comments

@koffie
Copy link

koffie commented May 23, 2021

What action do you want to perform

I want to use pytest-redis on OS X . I made a simplified test function based on the documentation

def test_my_redis(redisdb):
        """Check that it's actually working on redis database."""
        redisdb.set('test1', 'test')
        redisdb.set('test2', 'test')
    
    
        assert redisdb.get("test1") == 1

What are the results

The following error is raised:
redis.exceptions.ConnectionError: Error connecting to unix socket: /private/var/folders/s9/fpx7c2mj6cj4y80p28bt7c3m0000gn/T/pytest-of-maartenderickx/pytest-3/pytest-redis-redis_proc0/redis.29482.sock. AF_UNIX path too long.

What are the expected results

a succesfully run testcase where no error is raised but instead the test has failed because 'test' is not equal to 1

@koffie
Copy link
Author

koffie commented May 23, 2021

Possibly relevant pytest-dev/pytest#5802

@fizyk fizyk added the macos label May 24, 2021
@fizyk
Copy link
Member

fizyk commented May 24, 2021

@koffie does setting TMPDIR helps overcoming this issue?

If I read the internet correctly, the limit on socket paths is around 100 characters (104 on Macos, BSD, 107 on linux)

@koffie
Copy link
Author

koffie commented May 24, 2021

Yes this helps, the way I solved it is by adding:

[tool:pytest]
addopts = --basetemp=/tmp/pytest

to setup.cfg . But I guess setting TMPDIR might also work (I didn't test the TMPDIR solution since our project uses setup.cfg for configuration).

It might be good for the adaption of pytest-redis by others to replace the

redis.exceptions.ConnectionError: Error connecting to unix socket: /private/var/folders/s9/fpx7c2mj6cj4y80p28bt7c3m0000gn/T/pytest-of-maartenderickx/pytest-3/pytest-redis-redis_proc0/redis.29482.sock. AF_UNIX path too long.

warning by an explanation of the adopts and TMPDIR fixes. Since on OS X it is literally the first error you encounter when trying to give this project a spin (i.e. before even writing any serious tests just to see if the project actually does what I want it to do).

@koffie
Copy link
Author

koffie commented May 24, 2021

p.s after the above fix this project does indeed do what I expect it to do. So thanks for that!

@fizyk
Copy link
Member

fizyk commented May 24, 2021

@koffie Yes, I think that we can calculate the length of a socket path and produce a meaningful warning with explanation. + Paragraph for README

@fizyk fizyk closed this as completed in 27d44a9 May 25, 2021
fizyk added a commit that referenced this issue May 25, 2021
Raise more informative error if the unixsocket is too long - closes #310
@fizyk
Copy link
Member

fizyk commented May 25, 2021

@koffie no readme paragraph, But I think that the error itself should be informative enough 🤔

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

No branches or pull requests

2 participants