aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/tests/helpers
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:52:54 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:52:54 +0100
commitdcacc00e3750300617ba6e16eb346713f91a783a (patch)
tree38e2d4fb5ed9d119711d4295c6eda4b014af73fd /examples/redis-unstable/tests/helpers
parent58dac10aeb8f5a041c46bddbeaf4c7966a99b998 (diff)
downloadcrep-dcacc00e3750300617ba6e16eb346713f91a783a.tar.gz
Remove testing data
Diffstat (limited to 'examples/redis-unstable/tests/helpers')
-rw-r--r--examples/redis-unstable/tests/helpers/bg_block_op.tcl55
-rw-r--r--examples/redis-unstable/tests/helpers/bg_complex_data.tcl13
-rw-r--r--examples/redis-unstable/tests/helpers/fake_redis_node.tcl60
-rw-r--r--examples/redis-unstable/tests/helpers/gen_write_load.tcl51
4 files changed, 0 insertions, 179 deletions
diff --git a/examples/redis-unstable/tests/helpers/bg_block_op.tcl b/examples/redis-unstable/tests/helpers/bg_block_op.tcl
deleted file mode 100644
index dc4e1a9..0000000
--- a/examples/redis-unstable/tests/helpers/bg_block_op.tcl
+++ /dev/null
@@ -1,55 +0,0 @@
1source tests/support/redis.tcl
2source tests/support/util.tcl
3
4set ::tlsdir "tests/tls"
5
6# This function sometimes writes sometimes blocking-reads from lists/sorted
7# sets. There are multiple processes like this executing at the same time
8# so that we have some chance to trap some corner condition if there is
9# a regression. For this to happen it is important that we narrow the key
10# space to just a few elements, and balance the operations so that it is
11# unlikely that lists and zsets just get more data without ever causing
12# blocking.
13proc bg_block_op {host port db ops tls} {
14 set r [redis $host $port 0 $tls]
15 $r client setname LOAD_HANDLER
16 $r select $db
17
18 for {set j 0} {$j < $ops} {incr j} {
19
20 # List side
21 set k list_[randomInt 10]
22 set k2 list_[randomInt 10]
23 set v [randomValue]
24
25 randpath {
26 randpath {
27 $r rpush $k $v
28 } {
29 $r lpush $k $v
30 }
31 } {
32 $r blpop $k 2
33 } {
34 $r blpop $k $k2 2
35 }
36
37 # Zset side
38 set k zset_[randomInt 10]
39 set k2 zset_[randomInt 10]
40 set v1 [randomValue]
41 set v2 [randomValue]
42
43 randpath {
44 $r zadd $k [randomInt 10000] $v
45 } {
46 $r zadd $k [randomInt 10000] $v [randomInt 10000] $v2
47 } {
48 $r bzpopmin $k 2
49 } {
50 $r bzpopmax $k 2
51 }
52 }
53}
54
55bg_block_op [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4]
diff --git a/examples/redis-unstable/tests/helpers/bg_complex_data.tcl b/examples/redis-unstable/tests/helpers/bg_complex_data.tcl
deleted file mode 100644
index 9c0044e..0000000
--- a/examples/redis-unstable/tests/helpers/bg_complex_data.tcl
+++ /dev/null
@@ -1,13 +0,0 @@
1source tests/support/redis.tcl
2source tests/support/util.tcl
3
4set ::tlsdir "tests/tls"
5
6proc bg_complex_data {host port db ops tls} {
7 set r [redis $host $port 0 $tls]
8 $r client setname LOAD_HANDLER
9 $r select $db
10 createComplexDataset $r $ops
11}
12
13bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4]
diff --git a/examples/redis-unstable/tests/helpers/fake_redis_node.tcl b/examples/redis-unstable/tests/helpers/fake_redis_node.tcl
deleted file mode 100644
index 0f69d0a..0000000
--- a/examples/redis-unstable/tests/helpers/fake_redis_node.tcl
+++ /dev/null
@@ -1,60 +0,0 @@
1# A fake Redis node for replaying predefined/expected traffic with a client.
2#
3# Usage: tclsh fake_redis_node.tcl PORT COMMAND REPLY [ COMMAND REPLY [ ... ] ]
4#
5# Commands are given as space-separated strings, e.g. "GET foo", and replies as
6# RESP-encoded replies minus the trailing \r\n, e.g. "+OK".
7
8set port [lindex $argv 0];
9set expected_traffic [lrange $argv 1 end];
10
11# Reads and parses a command from a socket and returns it as a space-separated
12# string, e.g. "set foo bar".
13proc read_command {sock} {
14 set char [read $sock 1]
15 switch $char {
16 * {
17 set numargs [gets $sock]
18 set result {}
19 for {set i 0} {$i<$numargs} {incr i} {
20 read $sock 1; # dollar sign
21 set len [gets $sock]
22 set str [read $sock $len]
23 gets $sock; # trailing \r\n
24 lappend result $str
25 }
26 return $result
27 }
28 {} {
29 # EOF
30 return {}
31 }
32 default {
33 # Non-RESP command
34 set rest [gets $sock]
35 return "$char$rest"
36 }
37 }
38}
39
40proc accept {sock host port} {
41 global expected_traffic
42 foreach {expect_cmd reply} $expected_traffic {
43 if {[eof $sock]} {break}
44 set cmd [read_command $sock]
45 if {[string equal -nocase $cmd $expect_cmd]} {
46 puts $sock $reply
47 flush $sock
48 } else {
49 puts $sock "-ERR unexpected command $cmd"
50 break
51 }
52 }
53 close $sock
54}
55
56set sockfd [socket -server accept -myaddr 127.0.0.1 $port]
57after 5000 set done timeout
58vwait done
59close $sockfd
60
diff --git a/examples/redis-unstable/tests/helpers/gen_write_load.tcl b/examples/redis-unstable/tests/helpers/gen_write_load.tcl
deleted file mode 100644
index 7b4975c..0000000
--- a/examples/redis-unstable/tests/helpers/gen_write_load.tcl
+++ /dev/null
@@ -1,51 +0,0 @@
1#
2# Copyright (c) 2009-Present, Redis Ltd.
3# All rights reserved.
4#
5# Copyright (c) 2024-present, Valkey contributors.
6# All rights reserved.
7#
8# Licensed under your choice of (a) the Redis Source Available License 2.0
9# (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
10# GNU Affero General Public License v3 (AGPLv3).
11#
12# Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
13#
14
15source tests/support/redis.tcl
16
17set ::tlsdir "tests/tls"
18
19# Continuously sends SET commands to the server. If key is omitted, a random key
20# is used for every SET command. The value is always random.
21proc gen_write_load {host port seconds tls {key ""} {size 0} {sleep 0}} {
22 set start_time [clock seconds]
23 set r [redis $host $port 1 $tls]
24 $r client setname LOAD_HANDLER
25 catch {$r select 9} ;# select 9 will fail in cluster mode
26
27 # fixed size value
28 if {$size != 0} {
29 set value [string repeat "x" $size]
30 }
31
32 while 1 {
33 if {$size == 0} {
34 set value [expr rand()]
35 }
36
37 if {$key == ""} {
38 $r set [expr rand()] $value
39 } else {
40 $r set $key $value
41 }
42 if {[clock seconds]-$start_time > $seconds} {
43 exit 0
44 }
45 if {$sleep ne 0} {
46 after $sleep
47 }
48 }
49}
50
51gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] [lindex $argv 5] [lindex $argv 6]