MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / TestNetworkPluginManagerMetrics

Function TestNetworkPluginManagerMetrics

network/plugins_test.go:30–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestNetworkPluginManagerMetrics(t *testing.T) {
31 metrics.Register()
32
33 operation := "test_operation"
34 recordOperation(operation, time.Now())
35 recordError(operation)
36
37 cases := []struct {
38 metricName string
39 want string
40 }{
41 {
42 metricName: "kubelet_network_plugin_operations_total",
43 want: `
44# HELP kubelet_network_plugin_operations_total [ALPHA] Cumulative number of network plugin operations by operation type.
45# TYPE kubelet_network_plugin_operations_total counter
46kubelet_network_plugin_operations_total{operation_type="test_operation"} 1
47`,
48 },
49 {
50 metricName: "kubelet_network_plugin_operations_errors_total",
51 want: `
52# HELP kubelet_network_plugin_operations_errors_total [ALPHA] Cumulative number of network plugin operation errors by operation type.
53# TYPE kubelet_network_plugin_operations_errors_total counter
54kubelet_network_plugin_operations_errors_total{operation_type="test_operation"} 1
55`,
56 },
57 }
58
59 for _, tc := range cases {
60 t.Run(tc.metricName, func(t *testing.T) {
61 if err := testutil.GatherAndCompare(legacyregistry.DefaultGatherer, strings.NewReader(tc.want), tc.metricName); err != nil {
62 t.Fatal(err)
63 }
64 })
65 }
66}

Callers

nothing calls this directly

Calls 4

RegisterFunction · 0.92
recordOperationFunction · 0.70
recordErrorFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…