...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package zpages
17
18 import (
19 "context"
20 "testing"
21 "time"
22
23 "go.opencensus.io/internal/testpb"
24 "go.opencensus.io/stats/view"
25 )
26
27 func TestRpcz(t *testing.T) {
28 client, cleanup := testpb.NewTestClient(t)
29 defer cleanup()
30
31 _, err := client.Single(context.Background(), &testpb.FooRequest{})
32 if err != nil {
33 t.Fatal(err)
34 }
35
36 view.SetReportingPeriod(time.Millisecond)
37 time.Sleep(2 * time.Millisecond)
38 view.SetReportingPeriod(time.Second)
39
40 mu.Lock()
41 defer mu.Unlock()
42
43 if len(snaps) == 0 {
44 t.Fatal("Expected len(snaps) > 0")
45 }
46
47 snapshot, ok := snaps[methodKey{"testpb.Foo/Single", false}]
48 if !ok {
49 t.Fatal("Expected method stats not recorded")
50 }
51
52 if got, want := snapshot.CountTotal, uint64(1); got != want {
53 t.Errorf("snapshot.CountTotal = %d; want %d", got, want)
54 }
55 }
56
View as plain text