MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestRPCConcurrentCall

Function TestRPCConcurrentCall

internal/rpc/rpc_test.go:16–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestRPCConcurrentCall(t *testing.T) {
17 if !testutils.IsSingleTesting() {
18 return
19 }
20
21 rpcClient, err := rpc.SharedRPC()
22 if err != nil {
23 t.Fatal(err)
24 }
25
26 var before = time.Now()
27 defer func() {
28 t.Log("cost:", time.Since(before).Seconds()*1000, "ms")
29 }()
30
31 var concurrent = 3
32
33 var wg = sync.WaitGroup{}
34 wg.Add(concurrent)
35
36 for i := 0; i < concurrent; i++ {
37 go func() {
38 defer wg.Done()
39
40 _, err = rpcClient.NodeRPC.FindCurrentNodeConfig(rpcClient.Context(), &pb.FindCurrentNodeConfigRequest{})
41 if err != nil {
42 t.Log(err)
43 }
44 }()
45 }
46
47 wg.Wait()
48}
49
50func TestRPC_Retry(t *testing.T) {
51 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 7

IsSingleTestingFunction · 0.92
SharedRPCFunction · 0.92
LogMethod · 0.80
DoneMethod · 0.80
ContextMethod · 0.80
AddMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected