forked from Trial97/bechRPCAttributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.0_test.go
47 lines (43 loc) · 1.02 KB
/
1.0_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
package main
import (
"sync"
"testing"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc/jsonrpc"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
var (
newRPC *birpc.Client
newCfgPath = "./1.0"
addressNew = "127.0.0.1:4012"
onceNew sync.Once
)
func BenchmarkNew(b *testing.B) {
onceNew.Do(func() {
err := StartEngine("cgr-engine2", newCfgPath, addressNew, 500)
if err != nil {
b.Fatal(err)
}
})
var err error
if newRPC, err = jsonrpc.Dial(utils.TCP, addressNew); err != nil {
b.Fatal(err)
}
var rpl string
var a engine.ExternalAttributeProfile
ctx := context.Background()
b.ResetTimer()
for i := 0; i < b.N; i++ {
if err := newRPC.Call(ctx, "AdminSv1.SetAttributeProfile", attr, &rpl); err != nil {
b.Fatal(err)
}
if err := newRPC.Call(ctx, "AdminSv1.GetAttributeProfile", tntID, &a); err != nil {
b.Fatal(err)
}
if err := newRPC.Call(ctx, "AdminSv1.RemoveAttributeProfile", tntID, &rpl); err != nil {
b.Fatal(err)
}
}
}