Unverified Commit bd3f4b47 authored by Hannah Howard's avatar Hannah Howard Committed by GitHub

Switch To Circle CI (#57)

* ci(circle): switch to circle

Use configs from bitswap

* fix(deps): update and standardize

* fix(lint): fix lint errors

* fix(tests): relax timings for context cancels

Since we are not relying on context cancellation as anything but a test failsafe, relax timings
significantly for slower machines

* fix(test): fix minor test error

* fix(tests): minor timing fix

* fix(lint): fix lint errors

* fix(tests): relax timings for context cancels

Since we are not relying on context cancellation as anything but a test failsafe, relax timings
parent 94cf785f
version: 2.1
orbs:
ci-go: ipfs/ci-go@0.2
workflows:
version: 2
test:
jobs:
- ci-go/build
- ci-go/lint
- ci-go/test
- ci-go/test:
race: true
name: "ci-go/test/race"
- ci-go/benchmark:
tolerance: 50
requires:
- ci-go/test
os:
- linux
language: go
go:
- 1.11.x
env:
global:
- GOTFLAGS="-race"
matrix:
- BUILD_DEPTYPE=gomod
# disable travis install
install:
- true
script:
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
cache:
directories:
- $GOPATH/src/gx
- $GOPATH/pkg/mod
- $HOME/.cache/go-build
notifications:
email: false
......@@ -2,9 +2,11 @@
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Coverage Status](https://codecov.io/gh/ipfs/go-graphsync/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-graphsync)
[![Travis CI](https://travis-ci.com/ipfs/go-graphsync.svg?branch=master)](https://travis-ci.com/ipfs/go-graphsync)
[![Matrix](https://img.shields.io/badge/matrix-%23ipfs%3Amatrix.org-blue.svg?style=flat-square)](https://matrix.to/#/#ipfs:matrix.org)
[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Discord](https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord&style=flat-square)](https://discord.gg/24fmuwR)
[![Coverage Status](https://codecov.io/gh/ipfs/go-graphsync/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-graphsync/branch/master)
[![Build Status](https://circleci.com/gh/ipfs/go-bitswap.svg?style=svg)](https://circleci.com/gh/ipfs/go-graphsync)
> An implementation of the [graphsync protocol](https://github.com/ipld/specs/blob/master/block-layer/graphsync/graphsync.md) in go!
......
This diff is collapsed.
......@@ -134,7 +134,10 @@ func TestSendResponseToIncomingRequest(t *testing.T) {
message := gsmsg.New()
message.AddRequest(gsmsg.NewRequest(requestID, blockChain.TipLink.(cidlink.Link).Cid, blockChain.Selector(), graphsync.Priority(math.MaxInt32), td.extension))
// send request across network
td.gsnet1.SendMessage(ctx, td.host2.ID(), message)
err = td.gsnet1.SendMessage(ctx, td.host2.ID(), message)
if err != nil {
t.Fatal("Unable to send message")
}
// read the values sent back to requestor
var received gsmsg.GraphSyncMessage
var receivedBlocks []blocks.Block
......@@ -427,13 +430,17 @@ func TestUnixFSFetch(t *testing.T) {
requestor := New(ctx, td.gsnet1, loader1, storer1)
responder := New(ctx, td.gsnet2, loader2, storer2)
extensionName := graphsync.ExtensionName("Free for all")
responder.RegisterRequestReceivedHook(func(p peer.ID, requestData graphsync.RequestData, hookActions graphsync.RequestReceivedHookActions) {
err = responder.RegisterRequestReceivedHook(func(p peer.ID, requestData graphsync.RequestData, hookActions graphsync.RequestReceivedHookActions) {
hookActions.ValidateRequest()
hookActions.SendExtensionData(graphsync.ExtensionData{
Name: extensionName,
Data: nil,
})
})
if err != nil {
t.Fatal("unable to register extension")
}
// make a go-ipld-prime link for the root UnixFS node
clink := cidlink.Link{Cid: nd.Cid()}
......
......@@ -102,7 +102,7 @@ func (mq *MessageQueue) runQueue() {
return
case <-mq.ctx.Done():
if mq.sender != nil {
mq.sender.Reset()
_ = mq.sender.Reset()
}
return
}
......@@ -185,7 +185,7 @@ func (mq *MessageQueue) attemptSendAndRecovery(message gsmsg.GraphSyncMessage) b
}
log.Infof("graphsync send error: %s", err)
mq.sender.Reset()
_ = mq.sender.Reset()
mq.sender = nil
select {
......@@ -195,7 +195,7 @@ func (mq *MessageQueue) attemptSendAndRecovery(message gsmsg.GraphSyncMessage) b
return true
case <-time.After(time.Millisecond * 100):
// wait 100ms in case disconnect notifications are still propogating
log.Warning("SendMsg errored but neither 'done' nor context.Done() were set")
log.Warn("SendMsg errored but neither 'done' nor context.Done() were set")
}
err = mq.initializeSender()
......
......@@ -62,7 +62,7 @@ func msgToStream(ctx context.Context, s network.Stream, msg gsmsg.GraphSyncMessa
deadline = dl
}
if err := s.SetWriteDeadline(deadline); err != nil {
log.Warningf("error setting deadline: %s", err)
log.Warnf("error setting deadline: %s", err)
}
switch s.Protocol() {
......@@ -76,7 +76,7 @@ func msgToStream(ctx context.Context, s network.Stream, msg gsmsg.GraphSyncMessa
}
if err := s.SetWriteDeadline(time.Time{}); err != nil {
log.Warningf("error resetting deadline: %s", err)
log.Warnf("error resetting deadline: %s", err)
}
return nil
}
......@@ -105,11 +105,12 @@ func (gsnet *libp2pGraphSyncNetwork) SendMessage(
}
if err = msgToStream(ctx, s, outgoing); err != nil {
s.Reset()
_ = s.Reset()
return err
}
// TODO(https://github.com/libp2p/go-libp2p-net/issues/28): Avoid this goroutine.
//nolint
go helpers.AwaitEOF(s)
return s.Close()
......@@ -130,7 +131,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) {
defer s.Close()
if gsnet.receiver == nil {
s.Reset()
_ = s.Reset()
return
}
......@@ -139,7 +140,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) {
received, err := gsmsg.FromPBReader(reader)
if err != nil {
if err != io.EOF {
s.Reset()
_ = s.Reset()
go gsnet.receiver.ReceiveError(err)
log.Debugf("graphsync net handleNewStream from %s error: %s", s.Conn().RemotePeer(), err)
}
......
......@@ -95,7 +95,10 @@ func TestMessageSendAndReceive(t *testing.T) {
t.Fatal("Unable to connect peers")
}
gsnet1.SendMessage(ctx, host2.ID(), sent)
err = gsnet1.SendMessage(ctx, host2.ID(), sent)
if err != nil {
t.Fatal("Unable to send message")
}
select {
case <-ctx.Done():
......
......@@ -18,13 +18,16 @@ import (
func TestAsyncLoadInitialLoadSucceedsLocallyPresent(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
loader, storer := testutil.NewTestStore(blockStore)
block := testutil.GenerateBlocksOfSize(1, 100)[0]
writer, commit, err := storer(ipld.LinkContext{})
if err != nil {
t.Fatal("should be able to store")
}
_, err = writer.Write(block.RawData())
if err != nil {
t.Fatal("could not seed block store")
......@@ -65,7 +68,7 @@ func TestAsyncLoadInitialLoadSucceedsLocallyPresent(t *testing.T) {
func TestAsyncLoadInitialLoadSucceedsResponsePresent(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -118,7 +121,7 @@ func TestAsyncLoadInitialLoadSucceedsResponsePresent(t *testing.T) {
func TestAsyncLoadInitialLoadFails(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -166,7 +169,7 @@ func TestAsyncLoadInitialLoadFails(t *testing.T) {
func TestAsyncLoadInitialLoadIndeterminateWhenRequestNotInProgress(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -203,7 +206,7 @@ func TestAsyncLoadInitialLoadIndeterminateWhenRequestNotInProgress(t *testing.T)
func TestAsyncLoadInitialLoadIndeterminateThenSucceeds(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -267,7 +270,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenSucceeds(t *testing.T) {
func TestAsyncLoadInitialLoadIndeterminateThenFails(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -324,7 +327,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenFails(t *testing.T) {
func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......@@ -373,7 +376,7 @@ func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
func TestAsyncLoadTwiceLoadsLocallySecondTime(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
blockStore := make(map[ipld.Link][]byte)
......
......@@ -15,7 +15,7 @@ import (
func TestAsyncLoadInitialLoadSucceeds(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
......@@ -50,7 +50,7 @@ func TestAsyncLoadInitialLoadSucceeds(t *testing.T) {
func TestAsyncLoadInitialLoadFails(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
......@@ -85,7 +85,7 @@ func TestAsyncLoadInitialLoadFails(t *testing.T) {
func TestAsyncLoadInitialLoadIndeterminateRetryFalse(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
loadAttempter := func(graphsync.RequestID, ipld.Link) ([]byte, error) {
......@@ -125,7 +125,7 @@ func TestAsyncLoadInitialLoadIndeterminateRetryFalse(t *testing.T) {
func TestAsyncLoadInitialLoadIndeterminateRetryTrueThenRetriedSuccess(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
called := make(chan struct{}, 2)
......@@ -174,7 +174,7 @@ func TestAsyncLoadInitialLoadIndeterminateRetryTrueThenRetriedSuccess(t *testing
func TestAsyncLoadInitialLoadIndeterminateThenRequestFinishes(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
callCount := 0
called := make(chan struct{}, 2)
......
......@@ -16,10 +16,6 @@ import (
var log = logging.Logger("graphsync")
type responseCacheMessage interface {
handle(rc *ResponseCache)
}
// UnverifiedBlockStore is an interface for storing blocks
// as they come in and removing them as they are verified
type UnverifiedBlockStore interface {
......
......@@ -36,8 +36,14 @@ func TestVerifyBlockPresent(t *testing.T) {
t.Fatal("block should be returned on verification if added")
}
reader, err = loader(cidlink.Link{Cid: block.Cid()}, ipld.LinkContext{})
if err != nil {
t.Fatal("error loading block")
}
var buffer bytes.Buffer
io.Copy(&buffer, reader)
_, err = io.Copy(&buffer, reader)
if err != nil {
t.Fatal("error occurred copying data")
}
if !reflect.DeepEqual(buffer.Bytes(), block.RawData()) || err != nil {
t.Fatal("block should be stored after verification and therefore loadable")
}
......
......@@ -32,7 +32,7 @@ func makeAsyncLoadFn(responseChan chan types.AsyncLoadResult, calls chan callPar
func TestWrappedAsyncLoaderReturnsValues(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
responseChan := make(chan types.AsyncLoadResult, 1)
calls := make(chan callParams, 1)
......@@ -60,7 +60,7 @@ func TestWrappedAsyncLoaderReturnsValues(t *testing.T) {
func TestWrappedAsyncLoaderSideChannelsErrors(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
responseChan := make(chan types.AsyncLoadResult, 1)
calls := make(chan callParams, 1)
......@@ -88,7 +88,7 @@ func TestWrappedAsyncLoaderSideChannelsErrors(t *testing.T) {
func TestWrappedAsyncLoaderContextCancels(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
subCtx, subCancel := context.WithCancel(ctx)
responseChan := make(chan types.AsyncLoadResult, 1)
......
......@@ -397,7 +397,7 @@ func (rm *RequestManager) executeTraversal(
loaderFn := loader.WrapAsyncLoader(ctx, rm.asyncLoader.AsyncLoad, requestID, inProgressErr)
visitor := visitToChannel(ctx, inProgressChan)
go func() {
ipldutil.Traverse(ctx, loaderFn, root, selector, visitor)
_ = ipldutil.Traverse(ctx, loaderFn, root, selector, visitor)
select {
case networkError := <-networkErrorChan:
select {
......
......@@ -20,7 +20,6 @@ import (
"github.com/ipld/go-ipld-prime"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
gsmsg "github.com/ipfs/go-graphsync/message"
"github.com/ipfs/go-graphsync/testutil"
)
......@@ -100,14 +99,6 @@ func (fal *fakeAsyncLoader) verifyNoRemainingData(t *testing.T, requestID graphs
fal.responseChannelsLk.Unlock()
}
func cidsForBlocks(blks []blocks.Block) []cid.Cid {
cids := make([]cid.Cid, 0, 5)
for _, block := range blks {
cids = append(cids, block.Cid())
}
return cids
}
func (fal *fakeAsyncLoader) asyncLoad(requestID graphsync.RequestID, link ipld.Link) chan types.AsyncLoadResult {
fal.responseChannelsLk.Lock()
responseChannel, ok := fal.responseChannels[requestKey{requestID, link}]
......
......@@ -29,12 +29,12 @@ func metadataForResponses(responses []gsmsg.GraphSyncResponse) map[graphsync.Req
for _, response := range responses {
mdRaw, found := response.Extension(graphsync.ExtensionMetadata)
if !found {
log.Warningf("Unable to decode metadata in response for request id: %d", response.RequestID())
log.Warnf("Unable to decode metadata in response for request id: %d", response.RequestID())
continue
}
md, err := metadata.DecodeMetadata(mdRaw)
if err != nil {
log.Warningf("Unable to decode metadata in response for request id: %d", response.RequestID())
log.Warnf("Unable to decode metadata in response for request id: %d", response.RequestID())
continue
}
responseMetadata[response.RequestID()] = md
......
......@@ -34,7 +34,7 @@ func (fph *fakePeerHandler) SendResponse(p peer.ID, responses []gsmsg.GraphSyncR
func TestPeerResponseManagerSendsResponses(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 20*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
p := testutil.GeneratePeers(1)[0]
requestID1 := graphsync.RequestID(rand.Int31())
......@@ -173,7 +173,7 @@ func TestPeerResponseManagerSendsVeryLargeBlocksResponses(t *testing.T) {
// generate large blocks before proceeding
blks := testutil.GenerateBlocksOfSize(5, 1000000)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
links := make([]ipld.Link, 0, len(blks))
for _, block := range blks {
......@@ -294,7 +294,7 @@ func TestPeerResponseManagerSendsVeryLargeBlocksResponses(t *testing.T) {
func TestPeerResponseManagerSendsExtensionData(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 20*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
p := testutil.GeneratePeers(1)[0]
requestID1 := graphsync.RequestID(rand.Int31())
......
......@@ -127,7 +127,7 @@ func (fprs *fakePeerResponseSender) FinishWithError(requestID graphsync.RequestI
func TestIncomingQuery(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 40*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
blockStore := make(map[ipld.Link][]byte)
......@@ -177,7 +177,7 @@ func TestIncomingQuery(t *testing.T) {
func TestCancellationQueryInProgress(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 40*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
blockStore := make(map[ipld.Link][]byte)
......@@ -259,7 +259,7 @@ drainqueue:
func TestEarlyCancellation(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 40*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
blockStore := make(map[ipld.Link][]byte)
......@@ -306,7 +306,7 @@ func TestEarlyCancellation(t *testing.T) {
func TestValidationAndExtensions(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 40*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
blockStore := make(map[ipld.Link][]byte)
......
......@@ -18,13 +18,12 @@ import (
)
var blockGenerator = blocksutil.NewBlockGenerator()
var prioritySeq int
var seedSeq int64
// RandomBytes returns a byte array of the given size with random values.
func RandomBytes(n int64) []byte {
data := new(bytes.Buffer)
random.WritePseudoRandomBytes(n, data, seedSeq)
_ = random.WritePseudoRandomBytes(n, data, seedSeq)
seedSeq++
return data.Bytes()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment