forked from Nerzal/gocloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_benchmark_test.go
48 lines (43 loc) · 957 Bytes
/
client_benchmark_test.go
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
package gocloak_test
import (
"context"
"testing"
"github.com/Nerzal/gocloak/v8"
"github.com/stretchr/testify/assert"
)
func BenchmarkLogin(b *testing.B) {
cfg := GetConfig(b)
client := gocloak.NewClient(cfg.HostName)
SetUpTestUser(b, client)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := client.Login(
context.Background(),
cfg.GoCloak.ClientID,
cfg.GoCloak.ClientSecret,
cfg.GoCloak.Realm,
cfg.GoCloak.UserName,
cfg.GoCloak.Password,
)
assert.NoError(b, err, "Failed %d", i)
}
}
func BenchmarkLoginParallel(b *testing.B) {
cfg := GetConfig(b)
client := gocloak.NewClient(cfg.HostName)
SetUpTestUser(b, client)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_, err := client.Login(
context.Background(),
cfg.GoCloak.ClientID,
cfg.GoCloak.ClientSecret,
cfg.GoCloak.Realm,
cfg.GoCloak.UserName,
cfg.GoCloak.Password,
)
assert.NoError(b, err)
}
})
}