Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
36a21561
提交
36a21561
authored
2月 23, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stress test for ipfs fuse
上级
88b5a1a0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
104 行增加
和
8 行删除
+104
-8
mock.go
core/mock.go
+2
-0
ipfs_test.go
fuse/readonly/ipfs_test.go
+102
-8
没有找到文件。
core/mock.go
浏览文件 @
36a21561
package
core
import
(
ctxgroup
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
syncds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...
...
@@ -39,6 +40,7 @@ func NewMockNode() (*IpfsNode, error) {
nd
.
Peerstore
=
peer
.
NewPeerstore
()
nd
.
Peerstore
.
AddPrivKey
(
p
,
ident
.
PrivateKey
())
nd
.
Peerstore
.
AddPubKey
(
p
,
ident
.
PublicKey
())
nd
.
ContextGroup
=
ctxgroup
.
WithContext
(
ctx
)
nd
.
PeerHost
,
err
=
mocknet
.
New
(
ctx
)
.
AddPeer
(
ident
.
PrivateKey
(),
ident
.
Address
())
// effectively offline
if
err
!=
nil
{
...
...
fuse/readonly/ipfs_test.go
浏览文件 @
36a21561
...
...
@@ -2,16 +2,18 @@ package readonly
import
(
"bytes"
"crypto/rand"
//context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"sync"
"testing"
fstest
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs/fstestutil"
core
"github.com/jbenet/go-ipfs/core"
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
importer
"github.com/jbenet/go-ipfs/importer"
chunk
"github.com/jbenet/go-ipfs/importer/chunk"
dag
"github.com/jbenet/go-ipfs/merkledag"
...
...
@@ -26,12 +28,6 @@ func maybeSkipFuseTests(t *testing.T) {
}
}
func
randBytes
(
size
int
)
[]
byte
{
b
:=
make
([]
byte
,
size
)
rand
.
Read
(
b
)
return
b
}
func
randObj
(
t
*
testing
.
T
,
nd
*
core
.
IpfsNode
,
size
int64
)
(
*
dag
.
Node
,
[]
byte
)
{
buf
:=
make
([]
byte
,
size
)
u
.
NewTimeSeededRand
()
.
Read
(
buf
)
...
...
@@ -89,6 +85,104 @@ func TestIpfsBasicRead(t *testing.T) {
}
}
func
getPaths
(
t
*
testing
.
T
,
ipfs
*
core
.
IpfsNode
,
name
string
,
n
*
dag
.
Node
)
[]
string
{
if
len
(
n
.
Links
)
==
0
{
return
[]
string
{
name
}
}
var
out
[]
string
for
_
,
lnk
:=
range
n
.
Links
{
child
,
err
:=
lnk
.
GetNode
(
ipfs
.
DAG
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sub
:=
getPaths
(
t
,
ipfs
,
path
.
Join
(
name
,
lnk
.
Name
),
child
)
out
=
append
(
out
,
sub
...
)
}
return
out
}
// Perform a large number of concurrent reads to stress the system
func
TestIpfsStressRead
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
t
.
SkipNow
()
}
nd
,
mnt
:=
setupIpfsTest
(
t
,
nil
)
defer
mnt
.
Close
()
var
ks
[]
u
.
Key
var
paths
[]
string
nobj
:=
50
ndiriter
:=
50
// Make a bunch of objects
for
i
:=
0
;
i
<
nobj
;
i
++
{
fi
,
_
:=
randObj
(
t
,
nd
,
rand
.
Int63n
(
50000
))
k
,
err
:=
fi
.
Key
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ks
=
append
(
ks
,
k
)
paths
=
append
(
paths
,
k
.
String
())
}
// Now make a bunch of dirs
for
i
:=
0
;
i
<
ndiriter
;
i
++
{
db
:=
uio
.
NewDirectory
(
nd
.
DAG
)
for
j
:=
0
;
j
<
1
+
rand
.
Intn
(
10
);
j
++
{
name
:=
fmt
.
Sprintf
(
"child%d"
,
j
)
err
:=
db
.
AddChild
(
name
,
ks
[
rand
.
Intn
(
len
(
ks
))])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
newdir
:=
db
.
GetNode
()
k
,
err
:=
nd
.
DAG
.
Add
(
newdir
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ks
=
append
(
ks
,
k
)
npaths
:=
getPaths
(
t
,
nd
,
k
.
String
(),
newdir
)
paths
=
append
(
paths
,
npaths
...
)
}
// Now read a bunch, concurrently
wg
:=
sync
.
WaitGroup
{}
for
s
:=
0
;
s
<
4
;
s
++
{
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
for
i
:=
0
;
i
<
2000
;
i
++
{
item
:=
paths
[
rand
.
Intn
(
len
(
paths
))]
fname
:=
path
.
Join
(
mnt
.
Dir
,
item
)
rbuf
,
err
:=
ioutil
.
ReadFile
(
fname
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
read
,
err
:=
coreunix
.
Cat
(
nd
,
item
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
data
,
err
:=
ioutil
.
ReadAll
(
read
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
rbuf
,
data
)
{
t
.
Fatal
(
"Incorrect Read!"
)
}
}
}()
}
wg
.
Wait
()
}
// Test writing a file and reading it back
func
TestIpfsBasicDirRead
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论