Skip to content

Commit

Permalink
Switch To Circle CI (#57)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hannahhoward authored Mar 27, 2020
1 parent 94cf785 commit bd3f4b4
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 120 deletions.
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ go 1.12
require (
github.com/gogo/protobuf v1.3.1
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.3-0.20190908200855-f22eea50656c
github.com/ipfs/go-cid v0.0.4-0.20191112011718-79e75dffeb10
github.com/ipfs/go-datastore v0.1.0
github.com/ipfs/go-ipfs-blockstore v0.1.0
github.com/ipfs/go-blockservice v0.1.3
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-ipfs-blockstore v0.1.4
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.1
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-ipfs-files v0.0.4
github.com/ipfs/go-ipfs-util v0.0.1
github.com/ipfs/go-ipld-format v0.0.2
github.com/ipfs/go-log v1.0.0
github.com/ipfs/go-log v1.0.2
github.com/ipfs/go-merkledag v0.2.4
github.com/ipfs/go-peertaskqueue v0.2.0
github.com/ipfs/go-unixfs v0.2.2-0.20190827150610-868af2e9e5cb
github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785
github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-libp2p v0.3.0
github.com/libp2p/go-libp2p-core v0.2.4
github.com/multiformats/go-multiaddr v0.1.1
github.com/multiformats/go-multihash v0.0.9
github.com/libp2p/go-libp2p v0.6.0
github.com/libp2p/go-libp2p-core v0.5.0
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multihash v0.0.13
)
156 changes: 132 additions & 24 deletions go.sum

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions impl/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()}

Expand Down
6 changes: 3 additions & 3 deletions messagequeue/messagequeue.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (mq *MessageQueue) runQueue() {
return
case <-mq.ctx.Done():
if mq.sender != nil {
mq.sender.Reset()
_ = mq.sender.Reset()
}
return
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
11 changes: 6 additions & 5 deletions network/libp2p_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
Expand Down Expand Up @@ -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()

Expand All @@ -130,7 +131,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) {
defer s.Close()

if gsnet.receiver == nil {
s.Reset()
_ = s.Reset()
return
}

Expand All @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion network/libp2p_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
19 changes: 11 additions & 8 deletions requestmanager/asyncloader/asyncloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions requestmanager/asyncloader/responsecache/responsecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Loading

0 comments on commit bd3f4b4

Please sign in to comment.