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

Fixing randomly failing test #3437

Merged
merged 5 commits into from
Dec 5, 2024

Conversation

IlianIliev
Copy link
Contributor

@IlianIliev IlianIliev commented Nov 18, 2024

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

This test fails randomly depending on whether it runs close to the end of the second or not.

For example, if the test runs at 1527800400.999999, then the integer value of the timestamp + timedelta of 1 seconds = 1527800401. This way when we call r.hexpireat with that value, the combination of the time spent in the python code and the network delay adds enough time to cause the expiration timestamp to be in the past when received by the server.
As a result, the result value of the hexpireat is 2 (timestamp in the past) instead of 1.


@IlianIliev IlianIliev marked this pull request as ready for review November 18, 2024 06:43
@IlianIliev
Copy link
Contributor Author

I realized there is similar logic in core.py -> https://github.com/redis/redis-py/blob/master/redis/commands/core.py#L5265-L5266

if isinstance(unix_time_seconds, datetime.datetime):
    unix_time_seconds = int(unix_time_seconds.timestamp())

This causes failures when running test_hexpireat_with_datetime.

One option is to change the test to ensure it always rounds down the microseconds. Another is to change the core.py, which will change the logic and may result in a non-expected behavior for the user.

@vladvildanov
Copy link
Collaborator

@IlianIliev Let's go with option 1 for now

@vladvildanov
Copy link
Collaborator

@IlianIliev As I see pypy 3.10 still failing cause of hexpireat

@IlianIliev IlianIliev force-pushed the fixing-randomly-failing-test branch from dd5edc2 to f27079a Compare November 24, 2024 16:04
@IlianIliev
Copy link
Contributor Author

@vladvildanov, I missed some of the tests during the initial fix. I hope I have covered all of those now.

@vladvildanov vladvildanov merged commit 9d5751d into redis:master Dec 5, 2024
33 checks passed
vladvildanov added a commit that referenced this pull request Dec 6, 2024
* Migrate to clients test image (#3415)

* Migrate to client-testing image

- Use clients-testing image for standalone and cluster
- Remove hardcoded TLS certificates and keys
- Remove stunnel
- Remove Cluster docker and configs

* Fix migration bugs

* Create reusable action to run tests

- Reduce copy paste by using reusable action for running tests
- Gain better control of tests matrix

Add missing actions checkout

More fixes in integration workflow

Another attempt to fix matrix

* Reorg test matrix

* Fix jobs names and execution order

* Execute standalone and cluster test simultaneously

* Streamline test execution

- Automatically map Redis version to Redis Stack version and use it for testing module commands
- Remove Graph commands from execution by default
- Include more Redis versions to the test matrix

* More fixes to integration job

* Move python compatibility tests to a separate task

* Improve run-tests action

* Add missing pytest marks for TS tests

* Fix cluster configuration

* Debug cluster tests

* Fix Cluster TLS port

* Move current redis version to env var

* Fix ssl tests

* Show CLUSTER NODES on fail

* Fix integration workflow bugs

* Add workarounds for IPv6 bug in tests

* Use hostname instead of hardcoded IPv4 loopback

* Fix bug in _get_client

* Fix run-tests action

* Fix imports

* Add missing version guards in search tests

* Add compatibility for Redis < 7

* Add missing version guard in search tests

* Fix run-tests

* Add missing tls-auth-clients option

* Skip module tests when Redis < 7 and RESP3 is enabled

* Fix async test_moved_redirection_on_slave_with_default

The test was broken for a while after migrating to all-in-one container with Cluster

* Cleanup test after debugging

* Use correct profile in install_and_test.sh

* Use matrix to execute hiredis<=3.0.0 tests

* Fix hiredis job

* Fix pytest command in install_and_test.sh

* Use 7.4.1 as default version in docker-compose.yml

* Fix uvloop-tests

* Fixed unsecured tempfile.mktemp() command usage (#3446)

* Fixed unsecured tempfile.mktemp() command usage

* Added proper tuple handling

* Fixed bug with SLOWLOG GET response parsing from Redis Enterprise (#3441)

* Fixed issue with invoking _close() on closed event loop (#3438)

* Fixed issue with invoking _close() on closed event loop

* Removed unused import

* Revert weakref changes

* Codestyle fix

* Added test coverage

* Codestyle fixes

* Codestyle fixes

* Removed failure check that fails in 3.12

* Codestyle fixes

* Codestyle fixes

* Fixing randomly failing test (#3437)

* Fixing randomly failing test

* Always rounding up to avoid randomly failing tests

* Always rounding up to avoid randomly failing tests

---------

Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>

* Updated package version

---------

Co-authored-by: Igor Malinovskiy <u.glide@gmail.com>
Co-authored-by: Ilian Iliev <ilian@ilian.io>
@IlianIliev IlianIliev deleted the fixing-randomly-failing-test branch December 19, 2024 07:25
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.

2 participants