(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func 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 |
| 46 | kubelet_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 |
| 54 | kubelet_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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…