summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIgor Malinovskiy <u.glide@gmail.com>2023-03-22 07:17:20 +0100
committerGitHub <noreply@github.com>2023-03-22 08:17:20 +0200
commitc3b9f2fbd9085f4c9ea3151cc88d3b31c0d30b91 (patch)
tree68c2a78c10cd59274aa7d0a24d9ea137805d0415 /tests
parent6948dacaf63415c6cabce207cd7d23dcb37dd5e1 (diff)
downloadredis-c3b9f2fbd9085f4c9ea3151cc88d3b31c0d30b91.tar.gz
Allow clients to report name and version (#11758)
This PR allows clients to send information about the client library to redis to be displayed in CLIENT LIST and CLIENT INFO. Currently supports: `CLIENT [lib-name | lib-ver] <value>` Client libraries are expected to pipeline these right after AUTH, and ignore the failure in case they're talking to an older version of redis. These will be shown in CLIENT LIST and CLIENT INFO as: * `lib-name` - meant to hold the client library name. * `lib-ver` - meant to hold the client library version. The values cannot contain spaces, newlines and any wild ASCII characters, but all other normal chars are accepted, e.g `.`, `=` etc (same as CLIENT NAME). The RESET command does NOT clear these, but they can be cleared to the default by sending a command with a blank string. Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/introspection.tcl25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl
index 10d3a15e9..c8bc3eb89 100644
--- a/tests/unit/introspection.tcl
+++ b/tests/unit/introspection.tcl
@@ -325,6 +325,31 @@ start_server {tags {"introspection"}} {
}
}
+ test {CLIENT SETINFO can set a library name to this connection} {
+ r CLIENT SETINFO lib-name redis.py
+ r CLIENT SETINFO lib-ver 1.2.3
+ r client info
+ } {*lib-name=redis.py lib-ver=1.2.3*}
+
+ test {CLIENT SETINFO invalid args} {
+ assert_error {*wrong number of arguments*} {r CLIENT SETINFO lib-name}
+ assert_match {*cannot contain spaces*} [r CLIENT SETINFO lib-name "redis py"]
+ assert_match {*newlines*} [r CLIENT SETINFO lib-name "redis.py\n"]
+ assert_match {*Unrecognized*} [r CLIENT SETINFO badger hamster]
+ # test that all of these didn't affect the previously set values
+ r client info
+ } {*lib-name=redis.py lib-ver=1.2.3*}
+
+ test {RESET doesn NOT clean library name} {
+ r reset
+ r client info
+ } {*lib-name=redis.py*}
+
+ test {CLIENT SETINFO can clear library name} {
+ r CLIENT SETINFO lib-name ""
+ r client info
+ } {*lib-name= *}
+
test {CONFIG save params special case handled properly} {
# No "save" keyword - defaults should apply
start_server {config "minimal.conf"} {