diff --git a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics_test.go b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics_test.go index 200739b1bd7..3c8a33d49c5 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics_test.go @@ -316,6 +316,7 @@ apiserver_resource_size_estimate_bytes{group="foo",resource="bar"} -1 func TestDeleteStoreStats(t *testing.T) { registry := metrics.NewKubeRegistry() registry.MustRegister(objectCounts) + registry.MustRegister(newObjectCounts) registry.MustRegister(resourceSizeEstimate) UpdateStoreStats(schema.GroupResource{Group: "foo1", Resource: "bar1"}, storage.Stats{ObjectCount: 10}, nil) @@ -325,12 +326,16 @@ func TestDeleteStoreStats(t *testing.T) { # TYPE apiserver_resource_size_estimate_bytes gauge apiserver_resource_size_estimate_bytes{group="foo1",resource="bar1"} -1 apiserver_resource_size_estimate_bytes{group="foo2",resource="bar2"} 200 +# HELP apiserver_resource_objects [ALPHA] Number of stored objects at the time of last check split by kind. In case of a fetching error, the value will be -1. +# TYPE apiserver_resource_objects gauge +apiserver_resource_objects{group="foo1",resource="bar1"} 10 +apiserver_resource_objects{group="foo2",resource="bar2"} 20 # HELP apiserver_storage_objects [STABLE] [DEPRECATED, consider using apiserver_resource_objects instead] Number of stored objects at the time of last check split by kind. In case of a fetching error, the value will be -1. # TYPE apiserver_storage_objects gauge apiserver_storage_objects{resource="bar1.foo1"} 10 apiserver_storage_objects{resource="bar2.foo2"} 20 ` - if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_size_estimate_bytes"); err != nil { + if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_objects", "apiserver_resource_size_estimate_bytes"); err != nil { t.Fatal(err) } @@ -339,19 +344,24 @@ apiserver_storage_objects{resource="bar2.foo2"} 20 expectedMetrics = `# HELP apiserver_resource_size_estimate_bytes [ALPHA] Estimated size of stored objects in database. Estimate is based on sum of last observed sizes of serialized objects. In case of a fetching error, the value will be -1. # TYPE apiserver_resource_size_estimate_bytes gauge apiserver_resource_size_estimate_bytes{group="foo2",resource="bar2"} 200 +# HELP apiserver_resource_objects [ALPHA] Number of stored objects at the time of last check split by kind. In case of a fetching error, the value will be -1. +# TYPE apiserver_resource_objects gauge +apiserver_resource_objects{group="foo2",resource="bar2"} 20 # HELP apiserver_storage_objects [STABLE] [DEPRECATED, consider using apiserver_resource_objects instead] Number of stored objects at the time of last check split by kind. In case of a fetching error, the value will be -1. # TYPE apiserver_storage_objects gauge apiserver_storage_objects{resource="bar2.foo2"} 20 ` - if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_size_estimate_bytes"); err != nil { + if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_objects", "apiserver_resource_size_estimate_bytes"); err != nil { t.Fatal(err) } DeleteStoreStats(schema.GroupResource{Group: "foo2", Resource: "bar2"}) expectedMetrics = `# HELP apiserver_storage_objects [STABLE] [DEPRECATED, consider using apiserver_resource_objects instead] Number of stored objects at the time of last check split by kind. In case of a fetching error, the value will be -1. # TYPE apiserver_storage_objects gauge +# HELP apiserver_resource_size_estimate_bytes [ALPHA] Estimated size of stored objects in database. Estimate is based on sum of last observed sizes of serialized objects. In case of a fetching error, the value will be -1. +# TYPE apiserver_resource_size_estimate_bytes gauge ` - if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_size_estimate_bytes"); err != nil { + if err := testutil.GatherAndCompare(registry, strings.NewReader(expectedMetrics), "apiserver_storage_objects", "apiserver_resource_objects", "apiserver_resource_size_estimate_bytes"); err != nil { t.Fatal(err) } }