storj/satellite/repair/checker/online_test.go
Egon Elbre 5d0816430f
rename all the things (#2531)
* rename pkg/linksharing to linksharing
* rename pkg/httpserver to linksharing/httpserver
* rename pkg/eestream to uplink/eestream
* rename pkg/stream to uplink/stream
* rename pkg/metainfo/kvmetainfo to uplink/metainfo/kvmetainfo
* rename pkg/auth/signing to pkg/signing
* rename pkg/storage to uplink/storage
* rename pkg/accounting to satellite/accounting
* rename pkg/audit to satellite/audit
* rename pkg/certdb to satellite/certdb
* rename pkg/discovery to satellite/discovery
* rename pkg/overlay to satellite/overlay
* rename pkg/datarepair to satellite/repair
2019-07-28 08:55:36 +03:00

53 lines
1.1 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package checker
import (
"context"
"testing"
"time"
"go.uber.org/zap"
"storj.io/storj/internal/testcontext"
"storj.io/storj/internal/testrand"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/storj"
"storj.io/storj/satellite/overlay"
)
func TestReliabilityCache_Concurrent(t *testing.T) {
ctx := testcontext.New(t)
defer ctx.Cleanup()
ocache := overlay.NewCache(zap.NewNop(), fakeOverlayDB{}, overlay.NodeSelectionConfig{})
rcache := NewReliabilityCache(ocache, time.Millisecond)
for i := 0; i < 10; i++ {
ctx.Go(func() error {
for i := 0; i < 10000; i++ {
pieces := []*pb.RemotePiece{{NodeId: 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
}