MCPcopy
hub / github.com/grpc/grpc-go / TestServerMetrics_Setters

Method TestServerMetrics_Setters

orca/server_metrics_test.go:36–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func (s) TestServerMetrics_Setters(t *testing.T) {
37 smr := NewServerMetricsRecorder()
38
39 smr.SetCPUUtilization(0.1)
40 smr.SetMemoryUtilization(0.2)
41 smr.SetApplicationUtilization(0.3)
42 smr.SetQPS(0.4)
43 smr.SetEPS(0.5)
44 smr.SetNamedUtilization("x", 0.6)
45
46 want := &ServerMetrics{
47 CPUUtilization: 0.1,
48 MemUtilization: 0.2,
49 AppUtilization: 0.3,
50 QPS: 0.4,
51 EPS: 0.5,
52 Utilization: map[string]float64{"x": 0.6},
53 NamedMetrics: map[string]float64{},
54 RequestCost: map[string]float64{},
55 }
56
57 got := smr.ServerMetrics()
58 if d := cmp.Diff(got, want); d != "" {
59 t.Fatalf("unexpected server metrics: -got +want: %v", d)
60 }
61}
62
63func (s) TestServerMetrics_Deleters(t *testing.T) {
64 smr := NewServerMetricsRecorder()

Callers

nothing calls this directly

Calls 9

SetCPUUtilizationMethod · 0.95
SetMemoryUtilizationMethod · 0.95
SetQPSMethod · 0.95
SetEPSMethod · 0.95
SetNamedUtilizationMethod · 0.95
NewServerMetricsRecorderFunction · 0.85
ServerMetricsMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected