valkey icon indicating copy to clipboard operation
valkey copied to clipboard

Migrate unit tests to new framework

Open madolson opened this issue 1 year ago • 4 comments

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.

  • [x] : Zipmap.c https://github.com/valkey-io/valkey/pull/474
  • [X] : util.c https://github.com/valkey-io/valkey/pull/448
  • [x] : kvstore.c https://github.com/valkey-io/valkey/pull/446
  • [ ] : dict.chttps://github.com/valkey-io/valkey/pull/673
  • [X] : endianconv.c https://github.com/valkey-io/valkey/pull/458
  • [ ] : quicklist.c https://github.com/valkey-io/valkey/pull/515
  • [X] : sds.c https://github.com/valkey-io/valkey/pull/478
  • [x] : sha1.c (https://github.com/valkey-io/valkey/pull/470)
  • [x] : ziplist.c https://github.com/valkey-io/valkey/pull/486
  • [x] : zmalloc.c https://github.com/valkey-io/valkey/pull/493
  • [ ] : listpack.c (https://github.com/valkey-io/valkey/pull/484)
  • [ ] : Cleanup remaining references of SERVER_TEST

madolson avatar May 03 '24 04:05 madolson

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

SoulPancake avatar May 19 '24 06:05 SoulPancake

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

madolson avatar May 19 '24 19:05 madolson

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.

jazelly avatar May 21 '24 10:05 jazelly

Hi, @jazelly @madolson I am new to this org and I want to contribute. Could you please assign me a subtask in this issue?

rishidyno avatar Jul 03 '24 19:07 rishidyno