dragonfly/tests/fakeredis
Roman Gershman 6d1c22b64c
chore: GlobMatcher uses now reflex::Matcher regex engine (#4528)
Also consolidate benchmarking low level routines undeer dfly_core_test

```
BM_ParseFastFloat                   707 ns          707 ns      4005656
BM_ParseDoubleAbsl                 1460 ns         1460 ns      1927158
BM_MatchGlob/1000                   121 ns          121 ns     23701780
BM_MatchGlob/10000                  512 ns          512 ns      5481405
BM_MatchFindSubstr/1000             123 ns          123 ns     31114255
BM_MatchFindSubstr/10000           1126 ns         1126 ns      2522019
BM_MatchReflexFind/1000             118 ns          118 ns     22442417
BM_MatchReflexFind/10000            512 ns          512 ns      5414329
BM_MatchReflexFindStar/1000         106 ns          106 ns     26276727
BM_MatchReflexFindStar/10000        717 ns          717 ns      3719605
BM_MatchStd/1000                  19782 ns        19779 ns       128020
BM_MatchStd/10000                199809 ns       199781 ns        13837
BM_MatchRedisGlob/1000             1601 ns         1601 ns      1754635
BM_MatchRedisGlob/10000           16494 ns        16493 ns       171585
BM_MatchRe2/1000                   1039 ns         1039 ns      2709486
BM_MatchRe2/10000                 10041 ns        10040 ns       281296
```

What's curious is that now matching `*foobar*` on string is faster than
searching for 'foobar` using string::find() (BM_MatchGlob vs BM_MatchFindSubstr)

Improvement vs Redis is 10-30 times faster (BM_MatchRedisGlob vs BM_MatchGlob).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-02-05 10:29:51 +02:00
..
test chore: GlobMatcher uses now reflex::Matcher regex engine (#4528) 2025-02-05 10:29:51 +02:00
poetry.lock Fix test hypothesis (#4380) 2025-01-17 07:59:44 +02:00
pyproject.toml chore:update fakeredis, remove irrelevant tests (#4014) 2024-11-17 20:24:46 +02:00
README.md docs: Fakeredis tests README (#3552) 2024-08-24 08:51:38 +03:00

Running FakeRedis tests on Dragonfly

FakeRedis is a Python library that provides a full implementation of the Redis protocol. It is useful for testing Redis clients and for running Redis commands in Python code without having a running Redis server.

The tests in this directory are running against FakeRedis and against a dragonfly instance. The results are then compared to ensure that the two implementations are consistent.

Prerequisites

  • Python 3.10 or above is required to run the tests.
  • Poetry is required to install the dependencies.
  • A dragonfly instance running on port 6380.

Setup environment

  1. Install Poetry by following the instructions at https://python-poetry.org/docs/#installation.
  2. From the root directory of the tests (dragonfly/tests/fakeredis) run poetry env use python3.10 (or higher) to create a virtual environment for Python 3.10.
  3. Run poetry install to install the dependencies.
  4. Run poetry run pytest -v to run all the tests.
  5. Or alternatively, run poetry run pytest -v test/{test-name} to run a specific set of tests.

Tests

  • test_connection.py: Tests for the connection parameters to the Dragonfly server.
  • test_zadd.py: Considering the various options for the ZADD command, it has its own set of tests.
  • test_json/*.py: Tests for the JSON commands.
  • test_stack/*.py: Tests for the stack commands, bloom filter, cuckoo filter, CMS, TDigest, time-series, top-k.
  • test_mixins/*.py: Tests for various generic commands: bitmap, geospacial, hash, list, pubsub, scripting, streams, string, etc.
  • test_hypothesis.py: Hypothesis tests for the mixins commands. These tests are using hypothesis and generate random tests with edge cases. Note these tests take significantly more time to run.

General info

  • @pytest.mark.unsupported_server_types("dragonfly") decorator indicates to pytest that the test should not run on dragonfly.
    • Some tests are skipped the commands are CURRENTLY not supported (e.g., GEORARIUS).
    • Others are skipped because they cause an expected behavior, and usually marked with TODO comment as well.