diff options
author | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2022-11-28 20:51:25 +0800 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2022-12-12 17:36:34 +0200 |
commit | fba49b107d03f6ee2e4d7a4a550fcaa9ade59073 (patch) | |
tree | df0e9477c1c65c249443ffe3871557ca9165c4a2 | |
parent | 3d206f0fcfda546d30ac2cc08e0b4187ec0650d9 (diff) | |
download | redis-fba49b107d03f6ee2e4d7a4a550fcaa9ade59073.tar.gz |
benchmark getRedisConfig exit only when meet NOAUTH error (#11096)
redis-benchmark: when trying to get the CONFIG before benchmark,
avoid printing any warning on most errors (e.g. NOPERM error).
avoid aborting the benchmark on NOPERM.
keep the warning only when we abort the benchmark on a NOAUTH error
(cherry picked from commit f0005b53282c172c2833f6e36ad0287771ab2194)
-rw-r--r-- | src/redis-benchmark.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 2e0362b07..4d5f58511 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -330,6 +330,7 @@ static redisConfig *getRedisConfig(const char *ip, int port, } redisAppendCommand(c, "CONFIG GET %s", "save"); redisAppendCommand(c, "CONFIG GET %s", "appendonly"); + int abort_test = 0; int i = 0; void *r = NULL; for (; i < 2; i++) { @@ -338,7 +339,6 @@ static redisConfig *getRedisConfig(const char *ip, int port, reply = res == REDIS_OK ? ((redisReply *) r) : NULL; if (res != REDIS_OK || !r) goto fail; if (reply->type == REDIS_REPLY_ERROR) { - fprintf(stderr, "ERROR: %s\n", reply->str); goto fail; } if (reply->type != REDIS_REPLY_ARRAY || reply->elements < 2) goto fail; @@ -354,15 +354,14 @@ static redisConfig *getRedisConfig(const char *ip, int port, redisFree(c); return cfg; fail: - fprintf(stderr, "ERROR: failed to fetch CONFIG from "); - if (hostsocket == NULL) fprintf(stderr, "%s:%d\n", ip, port); - else fprintf(stderr, "%s\n", hostsocket); - int abort_test = 0; if (reply && reply->type == REDIS_REPLY_ERROR && - (!strncmp(reply->str,"NOAUTH",6) || - !strncmp(reply->str,"WRONGPASS",9) || - !strncmp(reply->str,"NOPERM",6))) + !strncmp(reply->str,"NOAUTH",6)) { + if (hostsocket == NULL) + fprintf(stderr, "Node %s:%d replied with error:\n%s\n", ip, port, reply->str); + else + fprintf(stderr, "Node %s replied with error:\n%s\n", hostsocket, reply->str); abort_test = 1; + } freeReplyObject(reply); redisFree(c); freeRedisConfig(cfg); |