From 42f8d4e28fc05f3532f5cf7d2294049e3314896a Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Mon, 18 Jan 2021 00:57:09 -0500 Subject: [PATCH] Added comment explaining the new unit test --- .../flowcontrol/metrics/sample_and_watermark_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics/sample_and_watermark_test.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics/sample_and_watermark_test.go index 0b7810dcc9a..2726101a7e8 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics/sample_and_watermark_test.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics/sample_and_watermark_test.go @@ -35,6 +35,15 @@ const ( numIterations = 100 ) +/* TestSampler does a rough behavioral test of SampleAndWatermarkHistograms. + The test creates one and exercises it, checking that the count in the + sampling histogram is correct at each step. A fake clock is used, and + the exercise consists of changing that fake clock by an amount of time + chosen uniformly at random from a range that goes from a little negative + to somewhat more than two sampling periods. The negative changes are + included because negative changes have been observed in real monotonic + clock readings. +*/ func TestSampler(t *testing.T) { t0 := time.Now() clk := clock.NewFakePassiveClock(t0) @@ -74,6 +83,7 @@ func TestSampler(t *testing.T) { } } +/* getHistogramCount returns the count of the named histogram */ func getHistogramCount(regs Registerables, metricName string) (int64, error) { considered := []string{} mfs, err := legacyregistry.DefaultGatherer.Gather()