Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 2b4e5af

Browse files
committed
Add timeouts for load test
1 parent a5cff90 commit 2b4e5af

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,6 @@ run-load-testing-auto-start: set-auto-start run-load-testing
309309

310310
set-auto-start:
311311
# Args passed to locust must be in CSV format as passed in "command" section of yaml doc
312-
$(eval LOCUST_ARGS=,'--no-web', '-c', '25', '-r', '0.08')
312+
$(eval LOCUST_ARGS=,'--no-web', '-c', '25', '-r', '0.08', '--run-time', '7m')
313313

314314
test-local: test-locust test-mock-api run-load-testing-auto-start

hack/verify_load_tests/main.go

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,44 @@ import (
1010

1111
func main() {
1212
client, _ := prometheus.NewClient("http://localhost:9091")
13-
userCount := getQueryResult(client, "locust_user_count")
14-
15-
for userCount < 25 {
16-
fmt.Printf("User count: %v\n", userCount)
17-
failRatio := getQueryResult(client, "sum(locust_fail_ratio)")
18-
fmt.Printf("Locust failure ratio: %v\n", failRatio)
19-
if failRatio > 0 {
20-
onFailure("locust_fail_ratio is higher than 0")
21-
}
13+
timeout := time.After(7 * time.Minute)
14+
tick := time.Tick(10 * time.Second)
2215

23-
numOfFailures := getQueryResult(client, "locust_requests_num_failures{path=\"poll_run_await_completion\"}")
24-
fmt.Printf("Number of failed locust requests: %v\n", numOfFailures)
25-
if numOfFailures > 0 {
26-
onFailure("locust_requests_num_failures is higher than 0")
27-
}
16+
// Keep trying until we're timed out, got a result or got an error
17+
for {
18+
select {
19+
// Got a timeout! fail with a timeout error
20+
case <-timeout:
21+
onFailure("Load test timed out")
22+
// Got a tick, we should check on doSomething()
23+
case <-tick:
24+
userCount := getQueryResult(client, "locust_user_count")
25+
if userCount >= 25 {
26+
fmt.Printf("Load test finished with user count: %v\n", userCount)
27+
return
28+
}
2829

29-
databricksFailures := getQueryResult(client, "sum(databricks_request_duration_seconds_count{object_type=\"runs\", outcome=\"failure\"})")
30-
fmt.Printf("Number of failed databricks requests: %v\n", databricksFailures)
31-
if databricksFailures > 0 {
32-
onFailure("databricks_request_duration_seconds_count failure count is higher than 0")
33-
}
30+
fmt.Printf("User count: %v\n", userCount)
31+
failRatio := getQueryResult(client, "sum(locust_fail_ratio)")
32+
fmt.Printf("Locust failure ratio: %v\n", failRatio)
33+
if failRatio > 0 {
34+
onFailure("locust_fail_ratio is higher than 0")
35+
}
3436

35-
time.Sleep(10 * time.Second)
36-
userCount = getQueryResult(client, "locust_user_count")
37+
numOfFailures := getQueryResult(client, "locust_requests_num_failures{path=\"poll_run_await_completion\"}")
38+
fmt.Printf("Number of failed locust requests: %v\n", numOfFailures)
39+
if numOfFailures > 0 {
40+
onFailure("locust_requests_num_failures is higher than 0")
41+
}
42+
43+
databricksFailures := getQueryResult(client, "sum(databricks_request_duration_seconds_count{object_type=\"runs\", outcome=\"failure\"})")
44+
fmt.Printf("Number of failed databricks requests: %v\n", databricksFailures)
45+
if databricksFailures > 0 {
46+
onFailure("databricks_request_duration_seconds_count failure count is higher than 0")
47+
}
48+
49+
}
3750
}
38-
fmt.Printf("Load test finished with user count: %v\n", userCount)
3951
}
4052

4153
func getQueryResult(client *prometheus.Client, query string) float64 {

0 commit comments

Comments
 (0)