From c2600f9e4d9f02b21d6e6104aaf5b456e0a19710 Mon Sep 17 00:00:00 2001 From: Carlo Mion Date: Sun, 24 Oct 2021 17:58:39 +0200 Subject: [PATCH] stats: fix missing computation of transferQueueSize when summing up statistics group - fixes #5749 --- fs/accounting/stats_groups.go | 1 + fs/accounting/stats_groups_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.go index 4c87bded4..400c72924 100644 --- a/fs/accounting/stats_groups.go +++ b/fs/accounting/stats_groups.go @@ -373,6 +373,7 @@ func (sg *statsGroups) sum(ctx context.Context) *StatsInfo { sum.lastError = stats.lastError } sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...) + sum.transferQueueSize += stats.transferQueueSize sum.oldDuration += stats.oldDuration sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...) stats.average.mu.Lock() diff --git a/fs/accounting/stats_groups_test.go b/fs/accounting/stats_groups_test.go index b8898b80e..2fd08c39d 100644 --- a/fs/accounting/stats_groups_test.go +++ b/fs/accounting/stats_groups_test.go @@ -47,12 +47,14 @@ func TestStatsGroupOperations(t *testing.T) { t.Parallel() stats1 := NewStats(ctx) stats1.bytes = 5 + stats1.transferQueueSize = 10 stats1.errors = 6 stats1.oldDuration = time.Second stats1.oldTimeRanges = []timeRange{{time.Now(), time.Now().Add(time.Second)}} stats2 := NewStats(ctx) stats2.bytes = 10 stats2.errors = 12 + stats1.transferQueueSize = 20 stats2.oldDuration = 2 * time.Second stats2.oldTimeRanges = []timeRange{{time.Now(), time.Now().Add(2 * time.Second)}} sg := newStatsGroups() @@ -60,6 +62,7 @@ func TestStatsGroupOperations(t *testing.T) { sg.set(ctx, "test2", stats2) sum := sg.sum(ctx) assert.Equal(t, stats1.bytes+stats2.bytes, sum.bytes) + assert.Equal(t, stats1.transferQueueSize+stats2.transferQueueSize, sum.transferQueueSize) assert.Equal(t, stats1.errors+stats2.errors, sum.errors) assert.Equal(t, stats1.oldDuration+stats2.oldDuration, sum.oldDuration) assert.Equal(t, stats1.average.speed+stats2.average.speed, sum.average.speed)