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

Method TestServerMetrics_Deleters

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

Source from the content-addressed store, hash-verified

61}
62
63func (s) TestServerMetrics_Deleters(t *testing.T) {
64 smr := NewServerMetricsRecorder()
65
66 smr.SetCPUUtilization(0.1)
67 smr.SetMemoryUtilization(0.2)
68 smr.SetApplicationUtilization(0.3)
69 smr.SetQPS(0.4)
70 smr.SetEPS(0.5)
71 smr.SetNamedUtilization("x", 0.6)
72 smr.SetNamedUtilization("y", 0.7)
73
74 // Now delete everything except named_utilization "y".
75 smr.DeleteCPUUtilization()
76 smr.DeleteMemoryUtilization()
77 smr.DeleteApplicationUtilization()
78 smr.DeleteQPS()
79 smr.DeleteEPS()
80 smr.DeleteNamedUtilization("x")
81
82 want := &ServerMetrics{
83 CPUUtilization: -1,
84 MemUtilization: -1,
85 AppUtilization: -1,
86 QPS: -1,
87 EPS: -1,
88 Utilization: map[string]float64{"y": 0.7},
89 NamedMetrics: map[string]float64{},
90 RequestCost: map[string]float64{},
91 }
92
93 got := smr.ServerMetrics()
94 if d := cmp.Diff(got, want); d != "" {
95 t.Fatalf("unexpected server metrics: -got +want: %v", d)
96 }
97}
98
99func (s) TestServerMetrics_Setters_Range(t *testing.T) {
100 smr := NewServerMetricsRecorder()

Callers

nothing calls this directly

Calls 15

SetCPUUtilizationMethod · 0.95
SetMemoryUtilizationMethod · 0.95
SetQPSMethod · 0.95
SetEPSMethod · 0.95
SetNamedUtilizationMethod · 0.95
DeleteCPUUtilizationMethod · 0.95
DeleteQPSMethod · 0.95
DeleteEPSMethod · 0.95

Tested by

no test coverage detected