Skip to content

Commit

Permalink
Merge pull request #5920 from hexdigest/master
Browse files Browse the repository at this point in the history
Fixed and cleaned up TestIpfsStressRead
  • Loading branch information
Stebalien authored Jan 21, 2019
2 parents 5b6f41a + 71a177c commit 083d85c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions fuse/readonly/ipfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ package readonly

import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"strings"
"sync"
"testing"

Expand Down Expand Up @@ -173,13 +175,20 @@ func TestIpfsStressRead(t *testing.T) {

for i := 0; i < 2000; i++ {
item, _ := iface.ParsePath(paths[rand.Intn(len(paths))])
fname := path.Join(mnt.Dir, item.String())

relpath := strings.Replace(item.String(), item.Namespace(), "", 1)
fname := path.Join(mnt.Dir, relpath)

rbuf, err := ioutil.ReadFile(fname)
if err != nil {
errs <- err
}

read, err := api.Unixfs().Get(nd.Context(), item)
//nd.Context() is never closed which leads to
//hitting 8128 goroutine limit in go test -race mode
ctx, cancelFunc := context.WithCancel(context.Background())

read, err := api.Unixfs().Get(ctx, item)
if err != nil {
errs <- err
}
Expand All @@ -189,6 +198,8 @@ func TestIpfsStressRead(t *testing.T) {
errs <- err
}

cancelFunc()

if !bytes.Equal(rbuf, data) {
errs <- errors.New("incorrect read")
}
Expand Down

0 comments on commit 083d85c

Please sign in to comment.