mirror of
https://github.com/rclone/rclone
synced 2024-11-17 17:30:37 +01:00
stats: fix missing computation of transferQueueSize when summing up statistics group - fixes #5749
This commit is contained in:
parent
7bd853ce35
commit
c2600f9e4d
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user