mirror of
https://github.com/rclone/rclone.git
synced 2025-08-19 01:46:31 +02:00
accounting: change stats interface
This is done to make clear ownership over accounting object and prepare for removing global stats object. Stats elapsed time calculation has been altered to account for actual transfer time instead of stats creation time.
This commit is contained in:
committed by
Nick Craig-Wood
parent
2d561b51db
commit
be0464f5f1
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/ncw/rclone/fs/accounting"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/fstest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -49,6 +51,7 @@ func TestMultithreadCopy(t *testing.T) {
|
||||
{size: multithreadChunkSize*2 + 1, streams: 2},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) {
|
||||
var err error
|
||||
contents := fstest.RandomString(test.size)
|
||||
t1 := fstest.Time("2001-02-03T04:05:06.499999999Z")
|
||||
file1 := r.WriteObject(context.Background(), "file1", contents, t1)
|
||||
@@ -57,8 +60,13 @@ func TestMultithreadCopy(t *testing.T) {
|
||||
|
||||
src, err := r.Fremote.NewObject(context.Background(), "file1")
|
||||
require.NoError(t, err)
|
||||
accounting.Stats.ResetCounters()
|
||||
tr := accounting.Stats.NewTransfer(src)
|
||||
|
||||
dst, err := multiThreadCopy(context.Background(), r.Flocal, "file1", src, 2)
|
||||
defer func() {
|
||||
tr.Done(err)
|
||||
}()
|
||||
dst, err := multiThreadCopy(context.Background(), r.Flocal, "file1", src, 2, tr)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, src.Size(), dst.Size())
|
||||
assert.Equal(t, "file1", dst.Remote())
|
||||
|
Reference in New Issue
Block a user