mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
uses iptb exclusively for mount-publish test
License: MIT Signed-off-by: Stephen Whitmore <noffle@ipfs.io>
This commit is contained in:
@ -1,10 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
|
||||||
# MIT Licensed; see the LICENSE file in this repository.
|
|
||||||
#
|
|
||||||
|
|
||||||
test_description="Test mount command in conjunction with publishing"
|
test_description="Test mount command in conjunction with publishing"
|
||||||
|
|
||||||
|
# imports
|
||||||
. lib/test-lib.sh
|
. lib/test-lib.sh
|
||||||
|
|
||||||
# if in travis CI, dont test mount (no fuse)
|
# if in travis CI, dont test mount (no fuse)
|
||||||
@ -16,56 +14,47 @@ fi
|
|||||||
|
|
||||||
test_init_ipfs
|
test_init_ipfs
|
||||||
|
|
||||||
# start iptb
|
# start iptb + wait for peering
|
||||||
iptb init -n 2 -f --bootstrap=star --port=$PORT_SWARM
|
NUM_NODES=3
|
||||||
iptb start --wait
|
iptb init -n $NUM_NODES -f --bootstrap=none --port=0
|
||||||
BADDR="/ip4/127.0.0.1/tcp/$PORT_SWARM/ipfs/"
|
startup_cluster $NUM_NODES
|
||||||
ADDR1="${BADDR}$(iptb get id 0)"
|
|
||||||
ADDR2="${BADDR}$(iptb get id 1)"
|
|
||||||
|
|
||||||
# bootstrap to the iptb peers
|
|
||||||
test_expect_success "bootstrap to iptb peers" '
|
|
||||||
ipfs bootstrap add '$ADDR1' &&
|
|
||||||
ipfs bootstrap add '$ADDR2'
|
|
||||||
'
|
|
||||||
|
|
||||||
# launch the daemon
|
|
||||||
test_launch_ipfs_daemon
|
|
||||||
|
|
||||||
# wait for peer bootstrapping
|
|
||||||
# TODO(noffle): this is very fragile -- how can we wait for this to happen for sure?
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
# pre-mount publish
|
# pre-mount publish
|
||||||
HASH=$(echo 'hello warld' | ipfs add -q)
|
HASH=$(echo 'hello warld' | ipfsi 0 add -q)
|
||||||
test_expect_success "can publish before mounting /ipns" '
|
test_expect_success "can publish before mounting /ipns" '
|
||||||
ipfs name publish '$HASH'
|
ipfsi 0 name publish '$HASH'
|
||||||
'
|
'
|
||||||
|
|
||||||
# mount
|
# mount
|
||||||
test_mount_ipfs
|
IPFS_MOUNT_DIR="$PWD/ipfs"
|
||||||
|
IPNS_MOUNT_DIR="$PWD/ipns"
|
||||||
test_expect_success "cannot publish after mounting /ipns" '
|
test_expect_success FUSE "'ipfs mount' succeeds" '
|
||||||
echo "Error: You cannot manually publish while IPNS is mounted." >expected &&
|
ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual
|
||||||
test_must_fail ipfs name publish '$HASH' 2>actual &&
|
'
|
||||||
|
test_expect_success FUSE "'ipfs mount' output looks good" '
|
||||||
|
echo "IPFS mounted at: $PWD/ipfs" >expected &&
|
||||||
|
echo "IPNS mounted at: $PWD/ipns" >>expected &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "cannot publish after mounting /ipns" '
|
||||||
|
echo "Error: You cannot manually publish while IPNS is mounted." >expected &&
|
||||||
|
test_must_fail ipfsi 0 name publish '$HASH' 2>actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success "unmount /ipns out-of-band" '
|
test_expect_success "unmount /ipns out-of-band" '
|
||||||
fusermount -u ipns
|
fusermount -u "'"$IPNS_MOUNT_DIR"'"
|
||||||
'
|
'
|
||||||
|
|
||||||
# wait a moment for the daemon to notice and clean up
|
|
||||||
# TODO(noffle): this is very fragile -- how can we wait for this to happen for sure?
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
test_expect_success "can publish after unmounting /ipns" '
|
test_expect_success "can publish after unmounting /ipns" '
|
||||||
ipfs name publish '$HASH'
|
ipfsi 0 name publish '$HASH'
|
||||||
'
|
'
|
||||||
|
|
||||||
# clean-up
|
# clean-up ipfs
|
||||||
test_kill_ipfs_daemon
|
test_expect_success "unmount /ipfs" '
|
||||||
|
fusermount -u "'"$IPFS_MOUNT_DIR"'"
|
||||||
|
'
|
||||||
iptb stop
|
iptb stop
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user