[#1350] node: Add unit test to measure time required for evacuation
All checks were successful
DCO action / DCO (pull_request) Successful in 50s
Tests and linters / Run gofumpt (pull_request) Successful in 1m13s
Vulncheck / Vulncheck (pull_request) Successful in 2m0s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m14s
Build / Build Components (pull_request) Successful in 2m27s
Tests and linters / Staticcheck (pull_request) Successful in 2m43s
Tests and linters / gopls check (pull_request) Successful in 2m43s
Tests and linters / Lint (pull_request) Successful in 3m24s
Tests and linters / Tests (pull_request) Successful in 4m18s
Tests and linters / Tests with -race (pull_request) Successful in 5m49s
All checks were successful
DCO action / DCO (pull_request) Successful in 50s
Tests and linters / Run gofumpt (pull_request) Successful in 1m13s
Vulncheck / Vulncheck (pull_request) Successful in 2m0s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m14s
Build / Build Components (pull_request) Successful in 2m27s
Tests and linters / Staticcheck (pull_request) Successful in 2m43s
Tests and linters / gopls check (pull_request) Successful in 2m43s
Tests and linters / Lint (pull_request) Successful in 3m24s
Tests and linters / Tests (pull_request) Successful in 4m18s
Tests and linters / Tests with -race (pull_request) Successful in 5m49s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
bcc0fed99c
commit
2218e42a10
1 changed files with 59 additions and 1 deletions
|
@ -32,10 +32,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type containerStorage struct {
|
type containerStorage struct {
|
||||||
cntmap map[cid.ID]*container.Container
|
cntmap map[cid.ID]*container.Container
|
||||||
|
latency time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *containerStorage) Get(id cid.ID) (*coreContainer.Container, error) {
|
func (cs *containerStorage) Get(id cid.ID) (*coreContainer.Container, error) {
|
||||||
|
time.Sleep(cs.latency)
|
||||||
coreCnt := coreContainer.Container{
|
coreCnt := coreContainer.Container{
|
||||||
Value: *cs.cntmap[id],
|
Value: *cs.cntmap[id],
|
||||||
}
|
}
|
||||||
|
@ -694,3 +696,59 @@ func TestEvacuateShardObjectsRepOneOnly(t *testing.T) {
|
||||||
require.Equal(t, uint64(4), res.ObjectsSkipped())
|
require.Equal(t, uint64(4), res.ObjectsSkipped())
|
||||||
require.Equal(t, uint64(0), res.ObjectsFailed())
|
require.Equal(t, uint64(0), res.ObjectsFailed())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEvacuateShardObjectsRepOneOnlyBench(t *testing.T) {
|
||||||
|
t.Skip()
|
||||||
|
e, ids, _ := newEngineEvacuate(t, 2, 0)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, e.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
|
cnrmap := make(map[cid.ID]*container.Container)
|
||||||
|
var cids []cid.ID
|
||||||
|
// Create containers with policy REP 1
|
||||||
|
for i := range 10_000 {
|
||||||
|
cnr1 := container.Container{}
|
||||||
|
p1 := netmap.PlacementPolicy{}
|
||||||
|
p1.SetContainerBackupFactor(1)
|
||||||
|
x1 := netmap.ReplicaDescriptor{}
|
||||||
|
x1.SetNumberOfObjects(2)
|
||||||
|
p1.AddReplicas(x1)
|
||||||
|
cnr1.SetPlacementPolicy(p1)
|
||||||
|
cnr1.SetAttribute("i", strconv.Itoa(i))
|
||||||
|
|
||||||
|
var idCnr1 cid.ID
|
||||||
|
container.CalculateID(&idCnr1, cnr1)
|
||||||
|
|
||||||
|
cnrmap[idCnr1] = &cnr1
|
||||||
|
cids = append(cids, idCnr1)
|
||||||
|
}
|
||||||
|
|
||||||
|
e.SetContainerSource(&containerStorage{
|
||||||
|
cntmap: cnrmap,
|
||||||
|
latency: time.Millisecond * 100,
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, cnt := range cids {
|
||||||
|
for range 1 {
|
||||||
|
obj := testutil.GenerateObjectWithCID(cnt)
|
||||||
|
var putPrm shard.PutPrm
|
||||||
|
putPrm.SetObject(obj)
|
||||||
|
_, err := e.shards[ids[0].String()].Put(context.Background(), putPrm)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var prm EvacuateShardPrm
|
||||||
|
prm.ShardID = ids[0:1]
|
||||||
|
prm.Scope = EvacuateScopeObjects
|
||||||
|
prm.RepOneOnly = true
|
||||||
|
prm.ContainerWorkerCount = 10
|
||||||
|
|
||||||
|
require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly))
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
_, err := e.Evacuate(context.Background(), prm)
|
||||||
|
t.Logf("evacuate took %v\n", time.Since(start))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue