Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
2c1c48a1
提交
2c1c48a1
authored
4月 23, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add iptb sharness test for multi-ipns name resolution
上级
c1560bef
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
106 行增加
和
17 行删除
+106
-17
Godeps.json
Godeps/Godeps.json
+1
-1
README.md
...ps/_workspace/src/github.com/whyrusleeping/iptb/README.md
+28
-14
main.go
Godeps/_workspace/src/github.com/whyrusleeping/iptb/main.go
+29
-2
t0101-iptb-name.sh
test/sharness/t0101-iptb-name.sh
+48
-0
没有找到文件。
Godeps/Godeps.json
浏览文件 @
2c1c48a1
...
...
@@ -38,7 +38,7 @@
},
{
"ImportPath"
:
"github.com/whyrusleeping/iptb"
,
"Rev"
:
"
5ee5bc0bb43502dfc798786a78df2448c91dd76
4"
"Rev"
:
"
7f5790b9a136aca057bc8f1dc711e204c634350
4"
},
{
"ImportPath"
:
"github.com/Sirupsen/logrus"
,
...
...
Godeps/_workspace/src/github.com/whyrusleeping/iptb/README.md
浏览文件 @
2c1c48a1
#Ipfs Testbed
# IPTB
iptb is a program used to manage a cluster of ipfs nodes locally on your
computer. It allows the creation of up to 1000 (limited by poor port choice)
nodes, and allows for various other setup options to be selected such as
different bootstrapping patterns. iptb makes testing networks in ipfs
easy!
##commands:
### Commands:
-
init
-
creates and initializes 'n' repos
-
Options:
-
-n=
[
number of nodes
]
-
-f : force overwriting of existing nodes
-
-bootstrap : select bootstrapping style for cluster choices: star, none
-
start
-
starts up all testbed nodes
-
Options:
-
-wait : wait until daemons are fully initialized
-
stop
-
kills all testbed nodes
-
restart
-
kills and then restarts all testbed nodes
### init -n=[number of nodes]
creates and initializes 'n' repos
-
shell
[
n
]
-
execs your shell with environment variables set as follows:
-
IPFS_PATH - set to testbed node n's IPFS_PATH
-
NODE
[
x
]
- set to the peer ID of node x
### start
starts up all testbed nodes
### Configuration
By default, iptb uses
`$HOME/testbed`
to store created nodes. This path is
configurable via the environment variables
`IPTB_ROOT`
.
### stop
kills all testbed nodes
### restart
kills, then restarts all testbed nodes
### shell [n]
execs your shell with environment variables set as follows:
-
IPFS_PATH - set to testbed node n's IPFS_PATH
-
NODE
[
x
]
- set to the peer ID of node x
Godeps/_workspace/src/github.com/whyrusleeping/iptb/main.go
浏览文件 @
2c1c48a1
package
main
import
(
"errors"
"flag"
"fmt"
serial
"github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
"io/ioutil"
"log"
"net"
...
...
@@ -14,6 +14,8 @@ import (
"sync"
"syscall"
"time"
serial
"github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
)
// GetNumNodes returns the number of testbed nodes configured in the testbed directory
...
...
@@ -313,6 +315,15 @@ func IpfsShell(n int) error {
return
syscall
.
Exec
(
shell
,
[]
string
{
shell
},
nenvs
)
}
func
GetAttr
(
attr
string
,
node
int
)
(
string
,
error
)
{
switch
attr
{
case
"id"
:
return
GetPeerID
(
node
)
default
:
return
""
,
errors
.
New
(
"unrecognized attribute"
)
}
}
var
helptext
=
`Ipfs Testbed
Commands:
...
...
@@ -340,6 +351,10 @@ Commands:
IPFS_PATH - set to testbed node n's IPFS_PATH
NODE[x] - set to the peer ID of node x
get [attribute] [node]
get an attribute of the given node
currently supports: "id"
Env Vars:
IPTB_ROOT:
...
...
@@ -348,7 +363,7 @@ IPTB_ROOT:
func
handleErr
(
s
string
,
err
error
)
{
if
err
!=
nil
{
fmt
.
Println
(
s
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
s
,
err
)
os
.
Exit
(
1
)
}
}
...
...
@@ -396,6 +411,18 @@ func main() {
err
=
IpfsShell
(
n
)
handleErr
(
"ipfs shell err: "
,
err
)
case
"get"
:
if
len
(
flag
.
Args
())
<
3
{
fmt
.
Println
(
"iptb get [attr] [node]"
)
os
.
Exit
(
1
)
}
attr
:=
flag
.
Arg
(
1
)
num
,
err
:=
strconv
.
Atoi
(
flag
.
Arg
(
2
))
handleErr
(
"error parsing node number: "
,
err
)
val
,
err
:=
GetAttr
(
attr
,
num
)
handleErr
(
"error getting attribute: "
,
err
)
fmt
.
Println
(
val
)
default
:
flag
.
Usage
()
os
.
Exit
(
1
)
...
...
test/sharness/t0101-iptb-name.sh
0 → 100755
浏览文件 @
2c1c48a1
#!/bin/sh
#
# Copyright (c) 2014 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test ipfs repo operations"
.
lib/test-lib.sh
export
IPTB_ROOT
=
"
`
pwd
`
/.iptb"
test_expect_success
"set up an iptb cluster"
'
iptb -n=4 init &&
iptb -wait start
'
test_expect_success
"add an obect on one node"
'
export IPFS_PATH="$IPTB_ROOT/1"
echo "ipns is super fun" > file &&
HASH_FILE=`ipfs add -q file`
'
test_expect_success
"publish that object as an ipns entry"
'
ipfs name publish $HASH_FILE
'
test_expect_success
"add an entry on another node pointing to that one"
'
export IPFS_PATH="$IPTB_ROOT/2"
NODE1_ID=`iptb get id 1` &&
ipfs name publish /ipns/$NODE1_ID
'
test_expect_success
"cat that entry on a third node"
'
export IPFS_PATH="$IPTB_ROOT/3"
NODE2_ID=`iptb get id 2` &&
ipfs cat /ipns/$NODE2_ID > output
'
test_expect_success
"ensure output was the same"
'
test_cmp file output
'
test_expect_success
"shut down iptb"
'
iptb stop
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论