Skip to content

Commit

Permalink
benchmark getRedisConfig exit only when meet NOAUTH error (redis#11096)
Browse files Browse the repository at this point in the history
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 f0005b5)
  • Loading branch information
soloestoy authored and oranagra committed Dec 6, 2022
1 parent 9f1d5ac commit 4272efe
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/redis-benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 4272efe

Please sign in to comment.