Skip to content

Commit fed24cd

Browse files
author
Peter Wilhelmsson
committed
tests: Duration as command line param to stress tool
1 parent 9dda4e6 commit fed24cd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test-stress/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ import (
3030
)
3131

3232
const (
33-
TestDuration = 15 * time.Second
3433
TestNumberOfGoRoutines = 20
3534
)
3635

37-
func stressTest(ctx *TestContext, successfulExecutors []func(*TestContext), failingExecutors []func(*TestContext)) {
36+
func stressTest(
37+
ctx *TestContext,
38+
successfulExecutors []func(*TestContext),
39+
failingExecutors []func(*TestContext),
40+
duration time.Duration) {
41+
3842
successfulExecutorsLen := len(successfulExecutors)
3943
failingExecutorsLen := len(failingExecutors)
4044

@@ -59,7 +63,7 @@ func stressTest(ctx *TestContext, successfulExecutors []func(*TestContext), fail
5963
}()
6064
}
6165

62-
time.Sleep(TestDuration)
66+
time.Sleep(duration)
6367
ctx.Stop()
6468
waiter.Wait()
6569
}
@@ -70,12 +74,14 @@ func main() {
7074
user string
7175
password string
7276
causalClustering bool
77+
duration int
7378
)
7479

7580
flag.StringVar(&uri, "uri", "bolt://localhost:7687", "Database URI")
7681
flag.StringVar(&user, "user", "neo4j", "User name")
7782
flag.StringVar(&password, "password", "pass", "Password")
7883
flag.BoolVar(&causalClustering, "cluster", false, "Causal clustering")
84+
flag.IntVar(&duration, "duration", 30, "Duration in seconds")
7985
flag.Parse()
8086

8187
auth := neo4j.BasicAuth(user, password, "")
@@ -135,6 +141,8 @@ func main() {
135141
)
136142
}
137143

138-
stressTest(ctx, successfulQueryExecutors, failingQueryExecutors)
144+
stressTest(
145+
ctx, successfulQueryExecutors, failingQueryExecutors,
146+
time.Duration(duration)*time.Second)
139147
ctx.PrintStats()
140148
}

0 commit comments

Comments
 (0)