015cb94909
Exemplars are representative elements for the stat. For example if a stat min is `30`, we can save one example with that value. More details about the concept is here: https://grafana.com/docs/grafana/latest/fundamentals/exemplars/ In our context, which save the segment + position in case of min is updated, to make it easier to look after the segment in danger. Change-Id: I19be482f1ddc7f1711e722c7b17480366d2c8312
81 lines
2.4 KiB
Go
81 lines
2.4 KiB
Go
// Copyright (C) 2023 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package durability_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap"
|
|
|
|
"storj.io/common/storj/location"
|
|
"storj.io/common/testcontext"
|
|
"storj.io/storj/private/testplanet"
|
|
"storj.io/storj/satellite"
|
|
"storj.io/storj/satellite/durability"
|
|
)
|
|
|
|
func TestDurabilityIntegration(t *testing.T) {
|
|
testplanet.Run(t, testplanet.Config{
|
|
SatelliteCount: 1,
|
|
StorageNodeCount: 6,
|
|
UplinkCount: 1,
|
|
Reconfigure: testplanet.Reconfigure{
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
config.Metainfo.RS.Min = 3
|
|
config.Metainfo.RS.Repair = 5
|
|
config.Metainfo.RS.Success = 5
|
|
config.Metainfo.RS.Total = 6
|
|
},
|
|
},
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
{
|
|
// upload object
|
|
project, err := planet.Uplinks[0].OpenProject(ctx, planet.Satellites[0])
|
|
require.NoError(t, err)
|
|
|
|
_, err = project.CreateBucket(ctx, "bucket1")
|
|
assert.NoError(t, err)
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
object, err := project.UploadObject(ctx, "bucket1", fmt.Sprintf("key%d", i), nil)
|
|
assert.NoError(t, err)
|
|
|
|
_, err = object.Write(make([]byte, 10240))
|
|
assert.NoError(t, err)
|
|
|
|
err = object.Commit()
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
require.NoError(t, project.Close())
|
|
}
|
|
|
|
{
|
|
// we uploaded to 5 nodes, having 2 node in HU means that we control at least 1 piece, but max 2
|
|
require.NoError(t, planet.Satellites[0].Overlay.Service.TestNodeCountryCode(ctx, planet.StorageNodes[0].NodeURL().ID, location.Hungary.String()))
|
|
require.NoError(t, planet.Satellites[0].Overlay.Service.TestNodeCountryCode(ctx, planet.StorageNodes[1].NodeURL().ID, location.Hungary.String()))
|
|
}
|
|
|
|
result := make(map[string]*durability.HealthStat)
|
|
planet.Satellites[0].RangedLoop.DurabilityReport.Observer.TestChangeReporter(func(n time.Time, name string, stat *durability.HealthStat) {
|
|
result[name] = stat
|
|
})
|
|
|
|
rangedLoopService := planet.Satellites[0].RangedLoop.RangedLoop.Service
|
|
_, err := rangedLoopService.RunOnce(ctx)
|
|
|
|
require.Len(t, result, 15)
|
|
// one or two pieces are controlled out of the 5-6 --> 3 or 4 pieces are available without HU nodes
|
|
require.True(t, result["c:HU"].Min() > 2)
|
|
require.True(t, result["c:HU"].Min() < 5)
|
|
require.NoError(t, err)
|
|
})
|
|
}
|