summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2022-11-28 20:51:25 +0800
committerGitHub <noreply@github.com>2022-11-28 20:51:25 +0800
commitf0005b53282c172c2833f6e36ad0287771ab2194 (patch)
tree48bf48aa73ee8a57c7c2fd4ba29b0860f61ed8d9
parent06b577aad01d132b0792581a3f1235bc84a32026 (diff)
downloadredis-f0005b53282c172c2833f6e36ad0287771ab2194.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
-rw-r--r--src/redis-benchmark.c15
1 files 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);