diff options
author | CharSyam <charsyam@gmail.com> | 2013-05-09 14:30:20 +0000 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-08-25 10:17:33 +0200 |
commit | b34a8c3b754c97083e93f225e4dc6b262ff0a0de (patch) | |
tree | 726c5d9341b6cd3b018d94649cb87b0ecaaaeb47 /src/redis-benchmark.c | |
parent | 7e63dd23f3faae7a399617128ffef224e0f21754 (diff) | |
download | redis-b34a8c3b754c97083e93f225e4dc6b262ff0a0de.tar.gz |
redis-benchmark: add auth option
Closes #1097
Diffstat (limited to 'src/redis-benchmark.c')
-rw-r--r-- | src/redis-benchmark.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index e6d6f5738..d8b49a710 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -77,6 +77,7 @@ static struct config { int dbnum; sds dbnumstr; char *tests; + char *auth; } config; typedef struct _client { @@ -325,6 +326,13 @@ static client createClient(char *cmd, size_t len, client from) { * the example client buffer. */ c->obuf = sdsempty(); + if (config.auth) { + char *buf = NULL; + int len = redisFormatCommand(&buf, "AUTH %s", config.auth); + c->obuf = sdscatlen(c->obuf, buf, len); + free(buf); + } + /* If a DB number different than zero is selected, prefix our request * buffer with the SELECT command, that will be discarded the first * time the replies are received, so if the client is reused the @@ -346,6 +354,7 @@ static client createClient(char *cmd, size_t len, client from) { for (j = 0; j < config.pipeline; j++) c->obuf = sdscatlen(c->obuf,cmd,len); } + c->written = 0; c->pending = config.pipeline; c->randptr = NULL; @@ -489,6 +498,9 @@ int parseOptions(int argc, const char **argv) { } else if (!strcmp(argv[i],"-s")) { if (lastarg) goto invalid; config.hostsocket = strdup(argv[++i]); + } else if (!strcmp(argv[i],"-a") ) { + if (lastarg) goto invalid; + config.auth = strdup(argv[++i]); } else if (!strcmp(argv[i],"-d")) { if (lastarg) goto invalid; config.datasize = atoi(argv[++i]); @@ -550,6 +562,7 @@ usage: " -h <hostname> Server hostname (default 127.0.0.1)\n" " -p <port> Server port (default 6379)\n" " -s <socket> Server socket (overrides host and port)\n" +" -a <password> Password for Redis Auth\n" " -c <clients> Number of parallel connections (default 50)\n" " -n <requests> Total number of requests (default 10000)\n" " -d <size> Data size of SET/GET value in bytes (default 2)\n" @@ -651,6 +664,7 @@ int main(int argc, const char **argv) { config.hostsocket = NULL; config.tests = NULL; config.dbnum = 0; + config.auth = NULL; i = parseOptions(argc,argv); argc -= i; |