Unverified 提交 083d85ca 作者: Steven Allen 提交者: GitHub

Merge pull request #5920 from hexdigest/master

Fixed and cleaned up TestIpfsStressRead
......@@ -4,12 +4,14 @@ package readonly
import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"strings"
"sync"
"testing"
......@@ -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
}
......@@ -189,6 +198,8 @@ func TestIpfsStressRead(t *testing.T) {
errs <- err
}
cancelFunc()
if !bytes.Equal(rbuf, data) {
errs <- errors.New("incorrect read")
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论