6502454947
With this change RS configuration will be set on satellite. Uplink with get RS values with BeginObject request and will use it. For backward compatibility and to avoid super large change redundancy scheme stored with bucket is not touched. This can be done in future. Change-Id: Ia5f76fc10c37e2c44e4f7b8754f28eafe1f97eff
104 lines
3.1 KiB
Go
104 lines
3.1 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package metrics_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/common/memory"
|
|
"storj.io/common/testcontext"
|
|
"storj.io/common/testrand"
|
|
"storj.io/storj/private/testplanet"
|
|
)
|
|
|
|
func TestCounterInlineAndRemote(t *testing.T) {
|
|
testplanet.Run(t, testplanet.Config{
|
|
SatelliteCount: 1, StorageNodeCount: 5, UplinkCount: 1,
|
|
Reconfigure: testplanet.Reconfigure{
|
|
Satellite: testplanet.ReconfigureRS(3, 4, 5, 5),
|
|
},
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
satellite := planet.Satellites[0]
|
|
ul := planet.Uplinks[0]
|
|
metricsChore := satellite.Metrics.Chore
|
|
metricsChore.Loop.Pause()
|
|
|
|
segmentSize := 8 * memory.KiB
|
|
|
|
// upload 2 inline files
|
|
for i := 0; i < 2; i++ {
|
|
testData := testrand.Bytes(segmentSize / 8)
|
|
path := "/some/inline/path/" + string(i)
|
|
err := ul.Upload(ctx, satellite, "bucket", path, testData)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
// upload 2 remote files with 1 segment
|
|
for i := 0; i < 2; i++ {
|
|
testData := testrand.Bytes(segmentSize)
|
|
path := "/some/remote/path/" + string(i)
|
|
err := ul.Upload(ctx, satellite, "testbucket", path, testData)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
metricsChore.Loop.TriggerWait()
|
|
require.EqualValues(t, 2, metricsChore.Counter.Inline)
|
|
require.EqualValues(t, 2, metricsChore.Counter.RemoteDependent)
|
|
require.EqualValues(t, 4, metricsChore.Counter.Total)
|
|
})
|
|
}
|
|
|
|
func TestCounterInlineOnly(t *testing.T) {
|
|
testplanet.Run(t, testplanet.Config{
|
|
SatelliteCount: 1, StorageNodeCount: 5, UplinkCount: 1,
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
satellite := planet.Satellites[0]
|
|
ul := planet.Uplinks[0]
|
|
metricsChore := satellite.Metrics.Chore
|
|
metricsChore.Loop.Pause()
|
|
|
|
// upload 2 inline files
|
|
for i := 0; i < 2; i++ {
|
|
testData := testrand.Bytes(memory.KiB)
|
|
path := "/some/inline/path/" + string(i)
|
|
err := ul.Upload(ctx, satellite, "bucket", path, testData)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
metricsChore.Loop.TriggerWait()
|
|
require.EqualValues(t, 2, metricsChore.Counter.Inline)
|
|
require.EqualValues(t, 0, metricsChore.Counter.RemoteDependent)
|
|
require.EqualValues(t, 2, metricsChore.Counter.Total)
|
|
})
|
|
}
|
|
|
|
func TestCounterRemoteOnly(t *testing.T) {
|
|
testplanet.Run(t, testplanet.Config{
|
|
SatelliteCount: 1, StorageNodeCount: 5, UplinkCount: 1,
|
|
Reconfigure: testplanet.Reconfigure{
|
|
Satellite: testplanet.ReconfigureRS(3, 4, 5, 5),
|
|
},
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
satellite := planet.Satellites[0]
|
|
ul := planet.Uplinks[0]
|
|
metricsChore := satellite.Metrics.Chore
|
|
metricsChore.Loop.Pause()
|
|
|
|
// upload 2 remote files with 1 segment
|
|
for i := 0; i < 2; i++ {
|
|
testData := testrand.Bytes(8 * memory.KiB)
|
|
path := "/some/remote/path/" + string(i)
|
|
err := ul.Upload(ctx, satellite, "testbucket", path, testData)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
metricsChore.Loop.TriggerWait()
|
|
require.EqualValues(t, 0, metricsChore.Counter.Inline)
|
|
require.EqualValues(t, 2, metricsChore.Counter.RemoteDependent)
|
|
require.EqualValues(t, 2, metricsChore.Counter.Total)
|
|
})
|
|
}
|