267506bb20
metabase has become a central concept and it's more suitable for it to be directly nested under satellite rather than being part of metainfo. metainfo is going to be the "endpoint" logic for handling requests. Change-Id: I53770d6761ac1e9a1283b5aa68f471b21e784198
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package checker
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap"
|
|
|
|
"storj.io/common/storj"
|
|
"storj.io/common/testcontext"
|
|
"storj.io/common/testrand"
|
|
"storj.io/storj/satellite/metabase"
|
|
"storj.io/storj/satellite/overlay"
|
|
)
|
|
|
|
func TestReliabilityCache_Concurrent(t *testing.T) {
|
|
ctx := testcontext.New(t)
|
|
defer ctx.Cleanup()
|
|
|
|
ocache, err := overlay.NewService(zap.NewNop(), fakeOverlayDB{}, overlay.Config{})
|
|
require.NoError(t, err)
|
|
rcache := NewReliabilityCache(ocache, time.Millisecond)
|
|
|
|
for i := 0; i < 10; i++ {
|
|
ctx.Go(func() error {
|
|
for i := 0; i < 10000; i++ {
|
|
pieces := []metabase.Piece{{StorageNode: testrand.NodeID()}}
|
|
_, err := rcache.MissingPieces(ctx, time.Now(), pieces)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
ctx.Wait()
|
|
}
|
|
|
|
type fakeOverlayDB struct{ overlay.DB }
|
|
|
|
func (fakeOverlayDB) Reliable(context.Context, *overlay.NodeCriteria) (storj.NodeIDList, error) {
|
|
return storj.NodeIDList{
|
|
testrand.NodeID(),
|
|
testrand.NodeID(),
|
|
testrand.NodeID(),
|
|
testrand.NodeID(),
|
|
}, nil
|
|
}
|