From 25dd873233ad5e3b1f7da0d6ba6d78b47074e397 Mon Sep 17 00:00:00 2001 From: Jian Xiao <99709935+jianoaix@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:08:39 -0800 Subject: [PATCH] Deflake dataapi server test (#267) --- disperser/dataapi/metrics_handlers.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/disperser/dataapi/metrics_handlers.go b/disperser/dataapi/metrics_handlers.go index 6d76d7e9b..90692cb7a 100644 --- a/disperser/dataapi/metrics_handlers.go +++ b/disperser/dataapi/metrics_handlers.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/big" + "sort" "strconv" "time" @@ -186,6 +187,14 @@ func (s *server) getOperatorNonsigningPercentage(ctx context.Context, intervalSe } } + // Sort by descending order of nonsigning rate. + sort.Slice(operators, func(i, j int) bool { + if operators[i].Percentage == operators[j].Percentage { + return operators[i].OperatorId < operators[j].OperatorId + } + return operators[i].Percentage > operators[j].Percentage + }) + return &OperatorsNonsigningPercentage{ Meta: Meta{ Size: len(operators),