From f0005b53282c172c2833f6e36ad0287771ab2194 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Mon, 28 Nov 2022 20:51:25 +0800 Subject: 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 --- src/redis-benchmark.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index f66e82ae8..c5dd187b8 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -324,6 +324,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++) { @@ -332,7 +333,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; @@ -348,15 +348,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); -- cgit v1.2.1