valkey-io / valkey

A new project to resume development on the formerly open-source Redis project. We're calling it Valkey, since it's a twist on the key-value datastore.
https://valkey.io
Other
14.47k stars 510 forks source link

Migrate unit tests to new framework #428

Open madolson opened 1 month ago

madolson commented 1 month ago

The legacy unit tests were a collection of distinct tests stored at the bottom of various files, that required rebuilding the server with a special flag and starting the server. We're moving to a new framework that can always be built and are running on a unified infrastructure. This issue is keeping track of migration from the old to new framework.

To migrate the tests, remove the custom testing code in the testing file lists listed below, create a new test like src/unit/test_*.c, and remove the reference in https://github.com/valkey-io/valkey/blob/5b1fd222ed97430dfeef27a95aeb7e1fb8fd1352/src/server.c#L6890. See the README for more information about writing a new unit test.

SoulPancake commented 1 month ago

Is there a part of this not WIP currently that I can pick up @madolson ?

madolson commented 1 month ago

@SoulPancake The only one not picked up right now is dict.c.

jazelly commented 1 month ago

I have tried porting dict.c under the new framework, but there is an issue with the test (or new test framework, or even dict.c itself). Reproduce steps

  1. copy unit tests in dict.c to unit/test_dict.c
  2. comment out original unit tests
  3. update include in test_dict.c relatively. You will need #include "../dict.c" as there are some private functions used in the test.
  4. you can choose to use the new test_help.h and change the print macro, but optional
  5. make valkey-unit-tests
  6. valkey-unit-tests --single test_dict.c
  7. Observe the 3rd test getting segmentation fault on linux (stack overflow) or infinite loop on macos, caused by rehashidx always being 0

I've checked the new test framework but nothing could cause this inconsistency with original unit tests.