From 5a3534f9b5f4e49c7e59f168250e78d0ea6abfa6 Mon Sep 17 00:00:00 2001 From: jonghoonpark Date: Thu, 30 May 2024 20:09:26 +0900 Subject: [PATCH] dynamically list test files (#13220) **Related issue** https://github.com/redis/redis/issues/13219 **Motivation** Currently we have to manually update the all_tests variable when introducing new test files. **Modification** I have modified it to list test files dynamically, but instead of modifying it to add all test files, I have modified it to only add only test files from the following 4 paths - unit - unit/type - unit/cluster - integration so that it doesn't deviate too much from what we already do **Result** - dynamically list test files to all_tests variable - close issue https://github.com/redis/redis/issues/13219 **Additional information** - removed `list-common.tcl` file and added `generate_largevalue_test_array` proc in `util.tcl`. because `list-common.tcl` is not a test file - There is an order dependency. So I added a code to the "Is a ziplist encoded Hash promoted on big payload?" test that resets hash-max-listpack-value to the default (64). --------- Signed-off-by: jonghoonpark Co-authored-by: debing.sun --- tests/support/util.tcl | 7 ++ tests/test_helper.tcl | 110 +++++--------------------------- tests/unit/keyspace.tcl | 3 +- tests/unit/type/hash.tcl | 3 + tests/unit/type/list-2.tcl | 2 +- tests/unit/type/list-common.tcl | 4 -- tests/unit/type/list.tcl | 2 +- 7 files changed, 30 insertions(+), 101 deletions(-) delete mode 100644 tests/unit/type/list-common.tcl diff --git a/tests/support/util.tcl b/tests/support/util.tcl index fcdac8c94..09e5b1e3b 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -1163,3 +1163,10 @@ proc system_backtrace_supported {} { } return 0 } + +proc generate_largevalue_test_array {} { + array set largevalue {} + set largevalue(listpack) "hello" + set largevalue(quicklist) [string repeat "x" 8192] + return [array get largevalue] +} diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 8901e2f8a..32b0184b9 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -17,100 +17,22 @@ source tests/support/tmpfile.tcl source tests/support/test.tcl source tests/support/util.tcl -set ::all_tests { - unit/printver - unit/dump - unit/auth - unit/protocol - unit/keyspace - unit/scan - unit/info - unit/info-command - unit/type/string - unit/type/incr - unit/type/list - unit/type/list-2 - unit/type/list-3 - unit/type/set - unit/type/zset - unit/type/hash - unit/type/hash-field-expire - unit/type/stream - unit/type/stream-cgroups - unit/sort - unit/expire - unit/other - unit/multi - unit/quit - unit/aofrw - unit/acl - unit/acl-v2 - unit/latency-monitor - integration/block-repl - integration/replication - integration/replication-2 - integration/replication-3 - integration/replication-4 - integration/replication-psync - integration/replication-buffer - integration/shutdown - integration/aof - integration/aof-race - integration/aof-multi-part - integration/rdb - integration/corrupt-dump - integration/corrupt-dump-fuzzer - integration/convert-zipmap-hash-on-load - integration/convert-ziplist-hash-on-load - integration/convert-ziplist-zset-on-load - integration/logging - integration/psync2 - integration/psync2-reg - integration/psync2-pingoff - integration/psync2-master-restart - integration/failover - integration/redis-cli - integration/redis-benchmark - integration/dismiss-mem - unit/pubsub - unit/pubsubshard - unit/slowlog - unit/scripting - unit/functions - unit/maxmemory - unit/introspection - unit/introspection-2 - unit/limits - unit/obuf-limits - unit/bitops - unit/bitfield - unit/geo - unit/memefficiency - unit/hyperloglog - unit/lazyfree - unit/wait - unit/pause - unit/querybuf - unit/tls - unit/tracking - unit/oom-score-adj - unit/shutdown - unit/networking - unit/client-eviction - unit/violations - unit/replybufsize - unit/cluster/announced-endpoints - unit/cluster/misc - unit/cluster/cli - unit/cluster/scripting - unit/cluster/hostnames - unit/cluster/human-announced-nodename - unit/cluster/multi-slot-operations - unit/cluster/slot-ownership - unit/cluster/links - unit/cluster/cluster-response-tls - unit/cluster/failure-marking - unit/cluster/sharded-pubsub +set dir [pwd] +set ::all_tests [] + +set test_dirs { + unit + unit/type + unit/cluster + integration +} + +foreach test_dir $test_dirs { + set files [glob -nocomplain $dir/tests/$test_dir/*.tcl] + + foreach file $files { + lappend ::all_tests $test_dir/[file root [file tail $file]] + } } # Index to the next test to run in the ::all_tests list. set ::next_test 0 diff --git a/tests/unit/keyspace.tcl b/tests/unit/keyspace.tcl index 31130e4c6..d11cf8365 100644 --- a/tests/unit/keyspace.tcl +++ b/tests/unit/keyspace.tcl @@ -252,7 +252,7 @@ start_server {tags {"keyspace"}} { assert {[r get mynewkey{t}] eq "foobar"} } -source "tests/unit/type/list-common.tcl" +array set largevalue [generate_largevalue_test_array] foreach {type large} [array get largevalue] { set origin_config [config_get_set list-max-listpack-size -1] test "COPY basic usage for list - $type" { @@ -326,6 +326,7 @@ foreach {type large} [array get largevalue] { } test {COPY basic usage for listpack hash} { + r config set hash-max-listpack-entries 512 r del hash1{t} newhash1{t} r hset hash1{t} tmp 17179869184 assert_encoding listpack hash1{t} diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 84e9a5ba5..1cb422455 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -1,4 +1,7 @@ start_server {tags {"hash"}} { + r config set hash-max-listpack-value 64 + r config set hash-max-listpack-entries 512 + test {HSET/HLEN - Small hash creation} { array set smallhash {} for {set i 0} {$i < 8} {incr i} { diff --git a/tests/unit/type/list-2.tcl b/tests/unit/type/list-2.tcl index 5874a9028..ac3bec804 100644 --- a/tests/unit/type/list-2.tcl +++ b/tests/unit/type/list-2.tcl @@ -4,7 +4,7 @@ start_server { "list-max-ziplist-size" 4 } } { - source "tests/unit/type/list-common.tcl" + array set largevalue [generate_largevalue_test_array] foreach {type large} [array get largevalue] { tags {"slow"} { diff --git a/tests/unit/type/list-common.tcl b/tests/unit/type/list-common.tcl deleted file mode 100644 index b393737c9..000000000 --- a/tests/unit/type/list-common.tcl +++ /dev/null @@ -1,4 +0,0 @@ -# We need a value to make sure the list has the right encoding when it is inserted. -array set largevalue {} -set largevalue(listpack) "hello" -set largevalue(quicklist) [string repeat "x" 8192] diff --git a/tests/unit/type/list.tcl b/tests/unit/type/list.tcl index 5ea62cb91..9f46a8beb 100644 --- a/tests/unit/type/list.tcl +++ b/tests/unit/type/list.tcl @@ -448,7 +448,7 @@ start_server { "list-max-ziplist-size" -1 } } { - source "tests/unit/type/list-common.tcl" + array set largevalue [generate_largevalue_test_array] # A helper function to execute either B*POP or BLMPOP* with one input key. proc bpop_command {rd pop key timeout} {