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

Win32 tests and timeout fix #776

Merged

Conversation

michael-grunder
Copy link
Collaborator

@michael-grunder michael-grunder commented Mar 30, 2020

This PR adds three things:

When running unit tests in Windows I found two places where functionality differed.

  1. In Linux attempting to connect to a non-existent port returns an error, but in Windows it just hangs forever. I believe this is related to a bug in WSAPoll but I really don't know enough about the Windows API to say for sure. It sure seems related though.

  2. Timeouts have slightly different behavior on Windows (example 1, example 2). It seems as if we should honor the same contract in either OS but OTOH people are almost certainly relying on the current behavior. Interested in opinions.

The test detection logic helps with running the unit tests in Windows (e.g. it skips AF_UNIX tests) but also makes it slightly nicer to run tests if your server isn't local (see #762 as mentioned above).

This commit gets our unit tests compiling and running on Windows.  There
are two things of particular interest here:

1.  In Windows, opening a non-existent hangs forever in WSAPoll whereas
    it correctly returns with a "Connection refused" error on Linux.
    For that reason, I simply skip this test in Windows.

    It may be related to this known issue:
    https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/

2.  Hiredis handles timeouts slightly differently in Windows than on
    Linux.  In Linux we intentionally set REDIS_ERR_IO for connection
    timeouts whereas in Windows we set REDIS_ERR_TIMEOUT.  It may be
    prudent to fix this discrepancy although there are almost certainly
    users relying on the current behavior.
As of CMake 3.4.3 there is an option to have it generate the .def file
on Windows dynamically.  This seems better than a .def file which can
get out of date but also that needs to be slightly different when
building in Cygwin vs. MinGW.
@michael-grunder
Copy link
Collaborator Author

@mnunberg There aren't any changes to the core library here, but let me know if you'd like some modifications w/r/t the Windows changes.

I feel like the correct solution would be to provide the same contract on Windows and Linux in terms of the timeout errors, but I'm sure it will break people's code.

* Move our unix socket detection to after argument parsing such that we
  don't only look for the default value of '/tmp/redis.sock'.

* Add an argument to treat any skipped tests as a failure.  This way we
  won't accidentally think tests are passing in Travis when they were
  actually skipped due to test detection.

* Minor Travis tweaks (remove deprecated `root` and switch `matrix` ->
  `jobs`)
@michael-grunder michael-grunder merged commit cc9d032 into redis:master Apr 3, 2020
@michael-grunder michael-grunder deleted the win32-tests-and-timeout-fix branch April 3, 2020 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant