Documentation
¶
Index ¶
- Constants
- func GenerateBlocksOfSize(n int, size int64) []blocks.Block
- func GenerateCid() cid.Cid
- func GenerateCids(n int) []cid.Cid
- func GenerateHTTPMultiAddr() multiaddr.Multiaddr
- func GenerateMultiAddr() multiaddr.Multiaddr
- func GenerateNoDupes(gen func() unixfs.DirEntry) unixfs.DirEntry
- func GeneratePeers(t *testing.T, n int) []peer.ID
- func GenerateRetrievalCandidates(t *testing.T, n int, protocols ...metadata.Protocol) []types.RetrievalCandidate
- func GenerateRetrievalCandidatesForCID(t *testing.T, n int, c cid.Cid, protocols ...metadata.Protocol) []types.RetrievalCandidate
- func GenerateRetrievalIDs(t *testing.T, n int) []types.RetrievalID
- func GenerateRetrievalRequests(t *testing.T, n int) []types.RetrievalRequest
- func GenerateStrictlyNestedShardedDir(t *testing.T, linkSys *linking.LinkSystem, randReader io.Reader, ...) unixfs.DirEntry
- func RandomBytes(n int64) []byte
- func ToBlocks(t *testing.T, lsys linking.LinkSystem, root cid.Cid, selNode datamodel.Node) []blocks.Block
- func VerifyCollectedEvent(t *testing.T, actual types.RetrievalEvent, expected types.RetrievalEvent)
- func VerifyContainsCollectedEvent(t *testing.T, afterStart time.Duration, expectedList []types.RetrievalEvent, ...) types.EventCode
- type AsyncCollectingEventsListener
- type ClientRetrievalRequest
- type CollectingEventsListener
- type DelayedClientReturn
- type DelayedConnectReturn
- type DiscoveredCandidate
- type ExpectedActionsAtTime
- type MockCandidateSource
- type MockClient
- func (mc *MockClient) Connect(ctx context.Context, minerPeer peer.AddrInfo) error
- func (mc *MockClient) GetConnectReturns() map[string]DelayedConnectReturn
- func (mc *MockClient) GetReceivedLinkSystems() []ipld.LinkSystem
- func (mc *MockClient) GetRetrievalReturns() map[string]DelayedClientReturn
- func (mc *MockClient) RetrieveFromPeer(ctx context.Context, linkSystem ipld.LinkSystem, peerID peer.ID, ...) (*types.RetrievalStats, error)
- func (mc *MockClient) SetConnectReturns(connectReturns map[string]DelayedConnectReturn)
- func (mc *MockClient) SetRetrievalReturns(retrievalReturns map[string]DelayedClientReturn)
- func (mc *MockClient) VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyReceivedRetrievalFrom(ctx context.Context, t *testing.T, p peer.ID) ClientRetrievalRequest
- func (mc *MockClient) VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type MockRoundTripRemote
- type MockRoundTripper
- func (mrt *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
- func (mrt *MockRoundTripper) VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type MockSession
- func (ms *MockSession) AddToRetrieval(retrievalId types.RetrievalID, storageProviderIds []peer.ID) error
- func (ms *MockSession) ChooseNextProvider(peers []peer.ID, metadata []metadata.Protocol) int
- func (ms *MockSession) EndRetrieval(retrievalId types.RetrievalID) error
- func (ms *MockSession) FilterIndexerCandidate(candidate types.RetrievalCandidate) (bool, types.RetrievalCandidate)
- func (ms *MockSession) RecordConnectTime(storageProviderId peer.ID, connectTime time.Duration)
- func (ms *MockSession) RecordFailure(retrievalId types.RetrievalID, storageProviderId peer.ID) error
- func (ms *MockSession) RecordFirstByteTime(storageProviderId peer.ID, firstByteTime time.Duration)
- func (ms *MockSession) RecordSuccess(storageProviderId peer.ID, bandwidthBytesPerSecond uint64)
- func (ms *MockSession) RegisterRetrieval(retrievalId types.RetrievalID, cid cid.Cid, selector datamodel.Node) bool
- func (ms *MockSession) SetBlockList(blockList map[peer.ID]bool)
- func (ms *MockSession) SetCandidatePreferenceOrder(candidatePreferenceOrder []types.RetrievalCandidate)
- func (ms *MockSession) VerifyMetricsAt(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type ParentStore
- type RemoteStats
- type RetrievalVerifier
- type RunRetrieval
- type SessionMetric
- type SessionMetricType
- type ThreadsafeStore
- type VerifierClient
Constants ¶
const ( SessionMetric_Success = SessionMetricType("success") SessionMetric_Failure = SessionMetricType("failure") SessionMetric_Connect = SessionMetricType("connect") SessionMetric_FirstByte = SessionMetricType("first-byte") )
Variables ¶
This section is empty.
Functions ¶
func GenerateBlocksOfSize ¶
GenerateBlocksOfSize generates a series of blocks of the given byte size
func GenerateHTTPMultiAddr ¶
func GenerateMultiAddr ¶
func GenerateNoDupes ¶
GenerateNoDupes runs the unixfsnode/testutil generator function repeatedly until it produces a DAG with strictly no duplicate CIDs.
func GeneratePeers ¶
GeneratePeers creates n peer ids.
func GenerateRetrievalCandidates ¶
func GenerateRetrievalCandidates(t *testing.T, n int, protocols ...metadata.Protocol) []types.RetrievalCandidate
GenerateRetrievalCandidates produces n retrieval candidates
func GenerateRetrievalCandidatesForCID ¶
func GenerateRetrievalCandidatesForCID(t *testing.T, n int, c cid.Cid, protocols ...metadata.Protocol) []types.RetrievalCandidate
GenerateRetrievalCandidates produces n retrieval candidates
func GenerateRetrievalIDs ¶
func GenerateRetrievalIDs(t *testing.T, n int) []types.RetrievalID
func GenerateRetrievalRequests ¶
func GenerateRetrievalRequests(t *testing.T, n int) []types.RetrievalRequest
GenerateRetrievalRequests produces retrieval requests
func GenerateStrictlyNestedShardedDir ¶
func GenerateStrictlyNestedShardedDir(t *testing.T, linkSys *linking.LinkSystem, randReader io.Reader, targetSize int) unixfs.DirEntry
GenerateStrictlyNestedShardedDir is a wrapper around unixfsnode/testutil.GenerateDirectory that uses dark magic to repeatedly generate a sharded directory until it produces one that is strictly nested. That is, it produces a sharded directory structure with strictly at least one level of sharding with at least two child shards.
Since it is possible to produce a sharded directory that is contained in a single block, this function provides a way to generate a sharded directory for cases where we need to test multi-level sharding.
func RandomBytes ¶
RandomBytes returns a byte array of the given size with random values.
func ToBlocks ¶
func ToBlocks(t *testing.T, lsys linking.LinkSystem, root cid.Cid, selNode datamodel.Node) []blocks.Block
ToBlocks makes a block array from ordered blocks in a traversal
func VerifyCollectedEvent ¶
func VerifyCollectedEvent(t *testing.T, actual types.RetrievalEvent, expected types.RetrievalEvent)
func VerifyContainsCollectedEvent ¶
func VerifyContainsCollectedEvent(t *testing.T, afterStart time.Duration, expectedList []types.RetrievalEvent, actual types.RetrievalEvent) types.EventCode
Types ¶
type AsyncCollectingEventsListener ¶
type AsyncCollectingEventsListener struct {
// contains filtered or unexported fields
}
func NewAsyncCollectingEventsListener ¶
func NewAsyncCollectingEventsListener(ctx context.Context) *AsyncCollectingEventsListener
func (*AsyncCollectingEventsListener) Collect ¶
func (ev *AsyncCollectingEventsListener) Collect(evt types.RetrievalEvent)
func (*AsyncCollectingEventsListener) VerifyNextEvents ¶
func (ev *AsyncCollectingEventsListener) VerifyNextEvents(t *testing.T, afterStart time.Duration, expectedEvents []types.RetrievalEvent)
type ClientRetrievalRequest ¶
type ClientRetrievalRequest struct {
Peer peer.ID
Proposal *retrievaltypes.DealProposal
Selector ipld.Node
}
type CollectingEventsListener ¶
type CollectingEventsListener struct {
CollectedEvents []types.RetrievalEvent
// contains filtered or unexported fields
}
func NewCollectingEventsListener ¶
func NewCollectingEventsListener() *CollectingEventsListener
func (*CollectingEventsListener) Collect ¶
func (el *CollectingEventsListener) Collect(event types.RetrievalEvent)
type DelayedClientReturn ¶
type DelayedClientReturn struct {
ResultStats *types.RetrievalStats
ResultErr error
Delay time.Duration
}
type DelayedConnectReturn ¶
type DiscoveredCandidate ¶
type DiscoveredCandidate struct {
Cid cid.Cid
Candidate types.RetrievalCandidate
}
type ExpectedActionsAtTime ¶
type ExpectedActionsAtTime struct {
AfterStart time.Duration
ReceivedConnections []peer.ID
ReceivedRetrievals []peer.ID
ServedRetrievals []RemoteStats
CompletedRetrievals []peer.ID
CandidatesDiscovered []DiscoveredCandidate
ExpectedEvents []types.RetrievalEvent
ExpectedMetrics []SessionMetric
}
func BlockReceivedActions ¶
func BlockReceivedActions(baseTime time.Time, baseAfterStart time.Duration, rid types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code, blockTime time.Duration, blks []blocks.Block) []ExpectedActionsAtTime
func SortActions ¶
func SortActions(actions []ExpectedActionsAtTime) []ExpectedActionsAtTime
type MockCandidateSource ¶
type MockCandidateSource struct {
// contains filtered or unexported fields
}
func NewMockCandidateSource ¶
func NewMockCandidateSource(err error, candidates map[cid.Cid][]types.RetrievalCandidate) *MockCandidateSource
func (*MockCandidateSource) FindCandidates ¶
func (me *MockCandidateSource) FindCandidates(ctx context.Context, c cid.Cid, cb func(types.RetrievalCandidate)) error
func (*MockCandidateSource) VerifyCandidatesDiscovered ¶
func (me *MockCandidateSource) VerifyCandidatesDiscovered(ctx context.Context, t *testing.T, afterStart time.Duration, expectedCandidatesDiscovered []DiscoveredCandidate)
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
func NewMockClient ¶
func NewMockClient(connectReturns map[string]DelayedConnectReturn, retrievalReturns map[string]DelayedClientReturn, clock clock.Clock) *MockClient
func (*MockClient) GetConnectReturns ¶
func (mc *MockClient) GetConnectReturns() map[string]DelayedConnectReturn
func (*MockClient) GetReceivedLinkSystems ¶
func (mc *MockClient) GetReceivedLinkSystems() []ipld.LinkSystem
func (*MockClient) GetRetrievalReturns ¶
func (mc *MockClient) GetRetrievalReturns() map[string]DelayedClientReturn
func (*MockClient) RetrieveFromPeer ¶
func (mc *MockClient) RetrieveFromPeer( ctx context.Context, linkSystem ipld.LinkSystem, peerID peer.ID, proposal *retrievaltypes.DealProposal, selector ipld.Node, maxBlocks uint64, eventsCallback datatransfer.Subscriber, gracefulShutdownRequested <-chan struct{}, ) (*types.RetrievalStats, error)
func (*MockClient) SetConnectReturns ¶
func (mc *MockClient) SetConnectReturns(connectReturns map[string]DelayedConnectReturn)
func (*MockClient) SetRetrievalReturns ¶
func (mc *MockClient) SetRetrievalReturns(retrievalReturns map[string]DelayedClientReturn)
func (*MockClient) VerifyConnectionsReceived ¶
func (*MockClient) VerifyReceivedRetrievalFrom ¶
func (mc *MockClient) VerifyReceivedRetrievalFrom(ctx context.Context, t *testing.T, p peer.ID) ClientRetrievalRequest
func (*MockClient) VerifyRetrievalsCompleted ¶
func (*MockClient) VerifyRetrievalsReceived ¶
func (*MockClient) VerifyRetrievalsServed ¶
func (mc *MockClient) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats)
type MockRoundTripRemote ¶
type MockRoundTripper ¶
type MockRoundTripper struct {
// contains filtered or unexported fields
}
func NewMockRoundTripper ¶
func (*MockRoundTripper) VerifyConnectionsReceived ¶
func (*MockRoundTripper) VerifyRetrievalsCompleted ¶
func (*MockRoundTripper) VerifyRetrievalsReceived ¶
func (*MockRoundTripper) VerifyRetrievalsServed ¶
func (mrt *MockRoundTripper) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats)
type MockSession ¶
type MockSession struct {
// contains filtered or unexported fields
}
func NewMockSession ¶
func NewMockSession(ctx context.Context) *MockSession
func (*MockSession) AddToRetrieval ¶
func (ms *MockSession) AddToRetrieval(retrievalId types.RetrievalID, storageProviderIds []peer.ID) error
func (*MockSession) ChooseNextProvider ¶
func (*MockSession) EndRetrieval ¶
func (ms *MockSession) EndRetrieval(retrievalId types.RetrievalID) error
func (*MockSession) FilterIndexerCandidate ¶
func (ms *MockSession) FilterIndexerCandidate(candidate types.RetrievalCandidate) (bool, types.RetrievalCandidate)
func (*MockSession) RecordConnectTime ¶
func (ms *MockSession) RecordConnectTime(storageProviderId peer.ID, connectTime time.Duration)
func (*MockSession) RecordFailure ¶
func (ms *MockSession) RecordFailure(retrievalId types.RetrievalID, storageProviderId peer.ID) error
func (*MockSession) RecordFirstByteTime ¶
func (ms *MockSession) RecordFirstByteTime(storageProviderId peer.ID, firstByteTime time.Duration)
func (*MockSession) RecordSuccess ¶
func (ms *MockSession) RecordSuccess(storageProviderId peer.ID, bandwidthBytesPerSecond uint64)
func (*MockSession) RegisterRetrieval ¶
func (ms *MockSession) RegisterRetrieval(retrievalId types.RetrievalID, cid cid.Cid, selector datamodel.Node) bool
func (*MockSession) SetBlockList ¶
func (ms *MockSession) SetBlockList(blockList map[peer.ID]bool)
func (*MockSession) SetCandidatePreferenceOrder ¶
func (ms *MockSession) SetCandidatePreferenceOrder(candidatePreferenceOrder []types.RetrievalCandidate)
func (*MockSession) VerifyMetricsAt ¶
func (ms *MockSession) VerifyMetricsAt(ctx context.Context, t *testing.T, afterStart time.Duration, expectedMetrics []SessionMetric)
type ParentStore ¶
type ParentStore interface {
storage.ReadableStorage
storage.StreamingReadableStorage
storage.WritableStorage
}
type RemoteStats ¶
type RetrievalVerifier ¶
type RetrievalVerifier struct {
ExpectedSequence []ExpectedActionsAtTime
}
func (RetrievalVerifier) RunWithVerification ¶
func (rv RetrievalVerifier) RunWithVerification( ctx context.Context, t *testing.T, clock *clock.Mock, client VerifierClient, mockCandidateSource *MockCandidateSource, mockSession *MockSession, cancelFunc context.CancelFunc, cancelAfter time.Duration, runRetrievals []RunRetrieval, ) []types.RetrievalResult
type RunRetrieval ¶
type RunRetrieval func(cb func(types.RetrievalEvent)) (*types.RetrievalStats, error)
type SessionMetric ¶
type SessionMetricType ¶
type SessionMetricType string
type ThreadsafeStore ¶
type ThreadsafeStore struct {
ParentStore
// contains filtered or unexported fields
}
func (*ThreadsafeStore) GetStream ¶
func (tss *ThreadsafeStore) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
type VerifierClient ¶
type VerifierClient interface {
VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, expectedConnections []peer.ID)
VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, expectedRetrievals []peer.ID)
VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats)
VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, expectedRetrievals []peer.ID)
}