Skip to content

Commit a5244af

Browse files
committed
[add] Added option to run with password (-a)
1 parent 21d74c0 commit a5244af

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ require (
77
github.com/RedisGraph/redisgraph-go v1.0.1-0.20210122150500-aa0feaa960ce
88
github.com/golangci/golangci-lint v1.35.2 // indirect
99
github.com/gomodule/redigo v2.0.0+incompatible
10+
github.com/mitchellh/gox v1.0.1 // indirect
11+
github.com/tcnksm/ghr v0.13.0 // indirect
1012
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
1113
)

redisgraph-bechmark-go.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func main() {
102102
host := flag.String("h", "127.0.0.1", "Server hostname.")
103103
port := flag.Int("p", 6379, "Server port.")
104104
rps := flag.Int64("rps", 0, "Max rps. If 0 no limit is applied and the DB is stressed up to maximum.")
105-
//password := flag.String("a", "", "Password for Redis Auth.")
105+
password := flag.String("a", "", "Password for Redis Auth.")
106106
clients := flag.Uint64("c", 50, "number of clients.")
107107
numberRequests := flag.Uint64("n", 1000000, "Total number of requests")
108108
debug := flag.Int("debug", 0, "Client debug level.")
@@ -148,7 +148,7 @@ func main() {
148148
wg.Add(1)
149149
cmd := make([]string, len(args))
150150
copy(cmd, args)
151-
rgs[client_id], conns[client_id] = getStandaloneConn(*graphKey, "tcp", connectionStr)
151+
rgs[client_id], conns[client_id] = getStandaloneConn(*graphKey, "tcp", connectionStr, *password)
152152
go ingestionRoutine(&rgs[client_id], true, query, samplesPerClient, *loop, *debug, &wg, useRateLimiter, rateLimiter)
153153
}
154154

standalone_conn.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ import (
66
"log"
77
)
88

9-
func getStandaloneConn(graphName, network, addr string) (rg.Graph, redis.Conn) {
10-
conn, err := redis.Dial(network, addr)
9+
func getStandaloneConn(graphName, network, addr string, password string) (graph rg.Graph, conn redis.Conn) {
10+
var err error = nil
11+
if password != "" {
12+
conn, err = redis.Dial(network, addr, redis.DialPassword(password))
13+
} else {
14+
conn, err = redis.Dial(network, addr)
15+
}
1116
if err != nil {
1217
log.Fatalf("Error preparing for benchmark, while creating new connection. error = %v", err)
1318
}
14-
graph := rg.GraphNew(graphName, conn)
19+
graph = rg.GraphNew(graphName, conn)
1520
return graph, conn
1621
}

0 commit comments

Comments
 (0)