From c248651f3f62093ea87a098c00f52465f264157b Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Fri, 2 Jul 2021 19:16:11 +0300 Subject: [PATCH] satellite/metabase/{meta,segment}loop: fix test flakiness When the delta is very small from the bounds then the ratio calculation doesn't work that well. Let's allow 100 from the bounds, since that would be expected in any case. We won't add a configuration for it, since it's not that useful. Change-Id: I049066a42470b825f430b7f32ebe92d544c6cc8b --- satellite/metabase/metaloop/service.go | 6 ++++++ satellite/metabase/segmentloop/service.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/satellite/metabase/metaloop/service.go b/satellite/metabase/metaloop/service.go index 2e30580ed..66df5041e 100644 --- a/satellite/metabase/metaloop/service.go +++ b/satellite/metabase/metaloop/service.go @@ -429,6 +429,12 @@ func (loop *Service) verifyCount(kind string, before, after, processed int64) er mon.IntVal("metaloop_verify_" + kind + "_outside").Observe(deltaFromBounds) mon.FloatVal("metaloop_verify_" + kind + "_outside_ratio").Observe(ratio) + // If we have very few items from the bounds, then it's expected and the ratio does not capture it well. + const minimumDeltaThreshold = 100 + if deltaFromBounds < minimumDeltaThreshold { + return nil + } + if ratio > loop.config.SuspiciousProcessedRatio { return Error.New("%s processed count looks suspicious: before:%v after:%v processed:%v ratio:%v threshold:%v", kind, before, after, processed, ratio, loop.config.SuspiciousProcessedRatio) } diff --git a/satellite/metabase/segmentloop/service.go b/satellite/metabase/segmentloop/service.go index 9747b2a01..4cd990a99 100644 --- a/satellite/metabase/segmentloop/service.go +++ b/satellite/metabase/segmentloop/service.go @@ -393,6 +393,12 @@ func (loop *Service) verifyCount(before, after, processed int64) error { mon.IntVal("segmentloop_verify_outside").Observe(deltaFromBounds) mon.FloatVal("segmentloop_verify_outside_ratio").Observe(ratio) + // If we have very few items from the bounds, then it's expected and the ratio does not capture it well. + const minimumDeltaThreshold = 100 + if deltaFromBounds < minimumDeltaThreshold { + return nil + } + if ratio > loop.config.SuspiciousProcessedRatio { return Error.New("processed count looks suspicious: before:%v after:%v processed:%v ratio:%v threshold:%v", before, after, processed, ratio, loop.config.SuspiciousProcessedRatio) }