-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathdashboard_test.go
More file actions
71 lines (60 loc) · 1.92 KB
/
dashboard_test.go
File metadata and controls
71 lines (60 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package tests
import (
"testing"
v1 "github.com/stackrox/rox/generated/api/v1"
"github.com/stackrox/rox/pkg/concurrency"
"github.com/stackrox/rox/pkg/roxctl/common"
)
func getAlertsSummaryByCluster(service v1.AlertServiceClient) func() error {
return getAlertsSummary(service, v1.GetAlertsCountsRequest_CLUSTER)
}
func getAlertsSummaryByCategory(service v1.AlertServiceClient) func() error {
return getAlertsSummary(service, v1.GetAlertsCountsRequest_CATEGORY)
}
func getAlertsSummary(service v1.AlertServiceClient, groupBy v1.GetAlertsCountsRequest_RequestGroup) func() error {
return func() error {
alertCountsRequest := &v1.GetAlertsCountsRequest{
Request: &v1.ListAlertsRequest{
Query: "",
},
GroupBy: groupBy,
}
_, err := service.GetAlertsCounts(common.Context(), alertCountsRequest)
return err
}
}
func getAlertsSummaryTimeseries(service v1.AlertServiceClient) func() error {
return func() error {
request := &v1.ListAlertsRequest{
Query: "",
}
_, err := service.GetAlertTimeseries(common.Context(), request)
return err
}
}
func getDeploymentsWithProcessInfo(service v1.DeploymentServiceClient) func() error {
return func() error {
query := &v1.RawQuery{
Query: "",
}
_, err := service.ListDeploymentsWithProcessInfo(common.Context(), query)
return err
}
}
func BenchmarkDashboard(b *testing.B) {
envVars := getEnvVars()
connection, err := getConnection(envVars.endpoint, envVars.password)
if err != nil {
log.Fatal(err)
}
alertService := v1.NewAlertServiceClient(connection)
deploymentService := v1.NewDeploymentServiceClient(connection)
for b.Loop() {
wg := concurrency.NewWaitGroup(0)
asyncWithWaitGroup(getAlertsSummaryByCluster(alertService), &wg)
asyncWithWaitGroup(getDeploymentsWithProcessInfo(deploymentService), &wg)
asyncWithWaitGroup(getAlertsSummaryByCategory(alertService), &wg)
asyncWithWaitGroup(getAlertsSummaryTimeseries(alertService), &wg)
<-wg.Done()
}
}