mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 12:20:03 +08:00
Add iptb sharness test for multi-ipns name resolution
This commit is contained in:
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -38,7 +38,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath":"github.com/whyrusleeping/iptb",
|
"ImportPath":"github.com/whyrusleeping/iptb",
|
||||||
"Rev": "5ee5bc0bb43502dfc798786a78df2448c91dd764"
|
"Rev": "7f5790b9a136aca057bc8f1dc711e204c6343504"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/Sirupsen/logrus",
|
"ImportPath": "github.com/Sirupsen/logrus",
|
||||||
|
46
Godeps/_workspace/src/github.com/whyrusleeping/iptb/README.md
generated
vendored
46
Godeps/_workspace/src/github.com/whyrusleeping/iptb/README.md
generated
vendored
@ -1,20 +1,34 @@
|
|||||||
#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]
|
- shell [n]
|
||||||
creates and initializes 'n' repos
|
- execs your shell with environment variables set as follows:
|
||||||
|
|
||||||
### start
|
|
||||||
starts up all testbed nodes
|
|
||||||
|
|
||||||
### 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
|
- IPFS_PATH - set to testbed node n's IPFS_PATH
|
||||||
- NODE[x] - set to the peer ID of node x
|
- NODE[x] - set to the peer ID of node x
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
By default, iptb uses `$HOME/testbed` to store created nodes. This path is
|
||||||
|
configurable via the environment variables `IPTB_ROOT`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
31
Godeps/_workspace/src/github.com/whyrusleeping/iptb/main.go
generated
vendored
31
Godeps/_workspace/src/github.com/whyrusleeping/iptb/main.go
generated
vendored
@ -1,9 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
serial "github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -14,6 +14,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
serial "github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetNumNodes returns the number of testbed nodes configured in the testbed directory
|
// 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)
|
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
|
var helptext = `Ipfs Testbed
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
@ -340,6 +351,10 @@ Commands:
|
|||||||
IPFS_PATH - set to testbed node n's IPFS_PATH
|
IPFS_PATH - set to testbed node n's IPFS_PATH
|
||||||
NODE[x] - set to the peer ID of node x
|
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:
|
Env Vars:
|
||||||
|
|
||||||
IPTB_ROOT:
|
IPTB_ROOT:
|
||||||
@ -348,7 +363,7 @@ IPTB_ROOT:
|
|||||||
|
|
||||||
func handleErr(s string, err error) {
|
func handleErr(s string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(s, err)
|
fmt.Fprintln(os.Stderr, s, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,6 +411,18 @@ func main() {
|
|||||||
|
|
||||||
err = IpfsShell(n)
|
err = IpfsShell(n)
|
||||||
handleErr("ipfs shell err: ", err)
|
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:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
48
test/sharness/t0101-iptb-name.sh
Executable file
48
test/sharness/t0101-iptb-name.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/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
|
Reference in New Issue
Block a user