Commit fba49b10 authored by zhaozhao.zz's avatar zhaozhao.zz Committed by Oran Agra
Browse files

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 f0005b53)
parent 3d206f0f
...@@ -330,6 +330,7 @@ static redisConfig *getRedisConfig(const char *ip, int port, ...@@ -330,6 +330,7 @@ static redisConfig *getRedisConfig(const char *ip, int port,
} }
redisAppendCommand(c, "CONFIG GET %s", "save"); redisAppendCommand(c, "CONFIG GET %s", "save");
redisAppendCommand(c, "CONFIG GET %s", "appendonly"); redisAppendCommand(c, "CONFIG GET %s", "appendonly");
int abort_test = 0;
int i = 0; int i = 0;
void *r = NULL; void *r = NULL;
for (; i < 2; i++) { for (; i < 2; i++) {
...@@ -338,7 +339,6 @@ static redisConfig *getRedisConfig(const char *ip, int port, ...@@ -338,7 +339,6 @@ static redisConfig *getRedisConfig(const char *ip, int port,
reply = res == REDIS_OK ? ((redisReply *) r) : NULL; reply = res == REDIS_OK ? ((redisReply *) r) : NULL;
if (res != REDIS_OK || !r) goto fail; if (res != REDIS_OK || !r) goto fail;
if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
fprintf(stderr, "ERROR: %s\n", reply->str);
goto fail; goto fail;
} }
if (reply->type != REDIS_REPLY_ARRAY || reply->elements < 2) 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, ...@@ -354,15 +354,14 @@ static redisConfig *getRedisConfig(const char *ip, int port,
redisFree(c); redisFree(c);
return cfg; return cfg;
fail: 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 && if (reply && reply->type == REDIS_REPLY_ERROR &&
(!strncmp(reply->str,"NOAUTH",6) || !strncmp(reply->str,"NOAUTH",6)) {
!strncmp(reply->str,"WRONGPASS",9) || if (hostsocket == NULL)
!strncmp(reply->str,"NOPERM",6))) 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; abort_test = 1;
}
freeReplyObject(reply); freeReplyObject(reply);
redisFree(c); redisFree(c);
freeRedisConfig(cfg); freeRedisConfig(cfg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment