Address 2nd round of comments

This commit is contained in:
Wyatt 2017-05-04 15:33:12 -07:00
parent 6f4c139cf9
commit 8286cd0ae2
7 changed files with 43 additions and 96 deletions

View File

@ -8,6 +8,7 @@ gx-go=gx-go_$(gx-go_version)
gx_bin=$(deptools)/$(gx) gx_bin=$(deptools)/$(gx)
gx-go_bin=$(deptools)/$(gx-go) gx-go_bin=$(deptools)/$(gx-go)
bin_env=$(shell go env GOHOSTOS)-$(shell go env GOHOSTARCH) bin_env=$(shell go env GOHOSTOS)-$(shell go env GOHOSTARCH)
sharness = sharness/lib/sharness
export PATH := $(deptools):$(PATH) export PATH := $(deptools):$(PATH)
@ -58,11 +59,17 @@ deps: gx
test: deps test: deps
go test -tags silent -v ./... go test -tags silent -v ./...
test_sharness: sharness_deps
test_sharness: $(sharness)
@sh sharness/run-sharness-tests.sh @sh sharness/run-sharness-tests.sh
sharness_deps: clean_sharness $(sharness):
@./sharness/lib/install-sharness.sh echo "Downloading sharness"
@wget -q -O sharness/lib/sharness.tar.gz http://github.com/chriscool/sharness/archive/master.tar.gz
tar -zxf ./sharness/lib/sharness.tar.gz
ls sharness/lib
@mv sharness/lib/sharness-master sharness/lib/sharness
@rm sharness/lib/sharness.tar.gz
clean_sharness: clean_sharness:
@rm -rf ./sharness/test-results @rm -rf ./sharness/test-results
@ -75,4 +82,4 @@ rwundo: gx
$(gx-go_bin) rewrite --undo $(gx-go_bin) rewrite --undo
publish: rwundo publish: rwundo
$(gx_bin) publish $(gx_bin) publish
.PHONY: all gx deps test test_sharness sharness_deps rw rwundo publish service ctl install clean .PHONY: all gx deps test test_sharness sharness_deps clean_sharness rw rwundo publish service ctl install clean

View File

@ -1,49 +0,0 @@
#!/bin/sh
#install sharness.sh
#
# Copyright (c) 2014 Juan Batiz-Benet
# MIT Licensed; see the LICENSE file in this repository.
#
# settings
version=5eee9b51b5621cec95a64018f0cc779963b230d2
urlprefix=https://github.com/mlafeldt/sharness.git
if test ! -n "$clonedir" ; then
clonedir=sharness/lib
fi
sharnessdir=sharness
if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version"
then
# There is the right version file. Great, we are done!
exit 0
fi
die() {
echo >&2 "$@"
exit 1
}
checkout_version() {
git checkout "$version" || die "Could not checkout '$version'"
rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'"
touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'"
echo "Sharness version $version is checked out!"
}
if test -d "$clonedir/$sharnessdir/.git"
then
# We need to update sharness!
cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory"
git fetch || die "Could not fetch to update sharness"
checkout_version
else
# We need to clone sharness!
mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
cd "$clonedir" || die "Could not cd into '$clonedir' directory"
git clone "$urlprefix" || die "Could not clone '$urlprefix'"
cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
checkout_version
fi
exit 0

View File

@ -23,7 +23,7 @@ test_ipfs_init() {
ipfs init && ipfs init &&
eval 'ipfs daemon & export IPFS_D_PID=`echo $!`' && # Esoteric, but gets correct value of $! eval 'ipfs daemon & export IPFS_D_PID=`echo $!`' && # Esoteric, but gets correct value of $!
sleep 2 && sleep 2 &&
test_set_prereq IPFS_INIT test_set_prereq IPFS
} }
test_cluster_init() { test_cluster_init() {
@ -32,7 +32,7 @@ test_cluster_init() {
ipfs-cluster-service -f --config $CLUSTER_TEMP_DIR init && ipfs-cluster-service -f --config $CLUSTER_TEMP_DIR init &&
eval 'ipfs-cluster-service --config $CLUSTER_TEMP_DIR & export CLUSTER_D_PID=`echo $!`' && eval 'ipfs-cluster-service --config $CLUSTER_TEMP_DIR & export CLUSTER_D_PID=`echo $!`' &&
sleep 2 && sleep 2 &&
test_set_prereq CLUSTER_INIT test_set_prereq CLUSTER
} }
test_cluster_config() { test_cluster_config() {

View File

@ -4,6 +4,7 @@ test_description="Test ctl installation and some basic commands"
. lib/test-lib.sh . lib/test-lib.sh
test_expect_success "current dir is writeable" ' test_expect_success "current dir is writeable" '
echo "Writability check" >test.txt && echo "Writability check" >test.txt &&
test_when_finished "rm test.txt" test_when_finished "rm test.txt"
@ -32,9 +33,9 @@ test_expect_success "cluster-ctl help output looks good" '
' '
test_expect_success "cluster-ctl commands output looks good" ' test_expect_success "cluster-ctl commands output looks good" '
ipfs-cluster-ctl commands | awk '"'"'NF'"'"' >commands.txt && ipfs-cluster-ctl commands | awk "NF" >commands.txt &&
test_when_finished "rm commands.txt" && test_when_finished "rm commands.txt" &&
numCmds=`cat commands.txt | sed '"'"'/^s*$/d'"'"' | wc -l` && numCmds=`cat commands.txt | wc -l` &&
[ $numCmds -eq "8" ] && [ $numCmds -eq "8" ] &&
egrep -q "ipfs-cluster-ctl id" commands.txt && egrep -q "ipfs-cluster-ctl id" commands.txt &&
egrep -q "ipfs-cluster-ctl peers" commands.txt && egrep -q "ipfs-cluster-ctl peers" commands.txt &&
@ -48,11 +49,11 @@ test_expect_success "cluster-ctl commands output looks good" '
test_expect_success "All cluster-ctl command docs are 80 columns or less" ' test_expect_success "All cluster-ctl command docs are 80 columns or less" '
export failure="0" && export failure="0" &&
ipfs-cluster-ctl commands | awk '"'"'NF'"'"' >commands.txt && ipfs-cluster-ctl commands | awk "NF" >commands.txt &&
test_when_finished "rm commands.txt" && test_when_finished "rm commands.txt" &&
while read cmd while read cmd
do do
LENGTH="$($cmd --help | awk '"'"'{ print length }'"'"' | sort -nr | head -n 1)" LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -n 1)"
[ "$LENGTH" -gt 80 ] && [ "$LENGTH" -gt 80 ] &&
{ echo "$cmd" help text is longer than 79 chars "($LENGTH)"; export failure="1"; } { echo "$cmd" help text is longer than 79 chars "($LENGTH)"; export failure="1"; }
done <commands.txt done <commands.txt

View File

@ -4,14 +4,12 @@ test_description="Test service startup and init functionality"
. lib/test-lib.sh . lib/test-lib.sh
test_expect_success "ipfs setup" ' test_ipfs_init
test_ipfs_init && test_cluster_init
test_have_prereq IPFS_INIT
'
test_expect_success "ipfs cluster setup" ' test_expect_success "prerequisites" '
test_cluster_init && test_have_prereq IPFS &&
test_have_prereq CLUSTER_INIT test_have_prereq CLUSTER
' '
test_expect_success JQ "ipfs cluster config valid" ' test_expect_success JQ "ipfs cluster config valid" '
@ -25,8 +23,6 @@ test_expect_success "custer-service help output looks good" '
test_expect_success "cluster-service --version succeeds and matches ctl" ' test_expect_success "cluster-service --version succeeds and matches ctl" '
export SERV_VERSION=`ipfs-cluster-service --version` && export SERV_VERSION=`ipfs-cluster-service --version` &&
export CTL_VERSION=`ipfs-cluster-ctl --version` && export CTL_VERSION=`ipfs-cluster-ctl --version` &&
echo "$SERV_VERSION" &&
echo "$CTL_VERSION" &&
sv=($SERV_VERSION) && sv=($SERV_VERSION) &&
cv=($CTL_VERSION) && cv=($CTL_VERSION) &&
[ "${sv[2]}" = "${cv[2]}" ] [ "${sv[2]}" = "${cv[2]}" ]

View File

@ -4,63 +4,59 @@ test_description="Test ctl's status reporting functionality. Test errors on inc
. lib/test-lib.sh . lib/test-lib.sh
test_expect_success "pre-reqs enabled" ' test_ipfs_init
test_ipfs_init && test_cluster_init
test_have_prereq IPFS_INIT &&
test_cluster_init &&
test_have_prereq CLUSTER_INIT
'
test_expect_success JQ "cluster-ctl can read id" ' test_expect_success IPFS,CLUSTER,JQ "cluster-ctl can read id" '
test_cluster_config && test_cluster_config &&
ipfs-cluster-ctl id | egrep -q -i "$CLUSTER_CONFIG_ID" ipfs-cluster-ctl id | egrep -q -i "$CLUSTER_CONFIG_ID"
' '
test_expect_success "cluster-ctl list 0 peers" ' test_expect_success IPFS,CLUSTER "cluster-ctl list 0 peers" '
export PEER_OUT=`ipfs-cluster-ctl peers ls` && export PEER_OUT=`ipfs-cluster-ctl peers ls` &&
sorted_peer_out=$(printf '"'"'%s\n'"'"' $PEER_OUT | sort -u) && sorted_peer_out=$(printf "%s\n" $PEER_OUT | sort -u) &&
export SELF_OUT=`ipfs-cluster-ctl id` && export SELF_OUT=`ipfs-cluster-ctl id` &&
sorted_self_out=$(printf '"'"'%s\n'"'"' $SELF_OUT | sort -u) && sorted_self_out=$(printf "%s\n" $SELF_OUT | sort -u) &&
[ "$sorted_peer_out" = "$sorted_self_out" ] [ "$sorted_peer_out" = "$sorted_self_out" ]
' '
test_expect_success "cluster-ctl add need peer id" ' test_expect_success IPFS,CLUSTER "cluster-ctl add need peer id" '
test_must_fail ipfs-cluster-ctl peers add test_must_fail ipfs-cluster-ctl peers add
' '
test_expect_success "cluster-ctl add invalid peer id" ' test_expect_success IPFS,CLUSTER "cluster-ctl add invalid peer id" '
test_must_fail ipfs-cluster-ctl peers add XXXinvalid-peerXXX test_must_fail ipfs-cluster-ctl peers add XXXinvalid-peerXXX
' '
test_expect_success "cluster-ctl rm needs peer id" ' test_expect_success IPFS,CLUSTER "cluster-ctl rm needs peer id" '
test_must_fail ipfs-cluster-ctl peers rm test_must_fail ipfs-cluster-ctl peers rm
' '
test_expect_success"cluster-ctl rm invalid peer id" ' test_expect_success IPFS,CLUSTER "cluster-ctl rm invalid peer id" '
test_must_fail ipfs-cluster-ctl peers rm XXXinvalid-peerXXX test_must_fail ipfs-cluster-ctl peers rm XXXinvalid-peerXXX
' '
test_expect_success "empty cluster-ctl status succeeds" ' test_expect_success IPFS,CLUSTER "empty cluster-ctl status succeeds" '
ipfs-cluster-ctl status ipfs-cluster-ctl status
' '
test_expect_success "invalid CID status" ' test_expect_success IPFS,CLUSTER "invalid CID status" '
test_must_fail ipfs-cluster-ctl status XXXinvalid-CIDXXX test_must_fail ipfs-cluster-ctl status XXXinvalid-CIDXXX
' '
test_expect_success "empty cluster-ctl sync succeeds" ' test_expect_success IPFS,CLUSTER "empty cluster-ctl sync succeeds" '
ipfs-cluster-ctl sync ipfs-cluster-ctl sync
' '
test_expect_success "empty cluster_ctl recover needs CID" ' test_expect_success IPFS,CLUSTER "empty cluster_ctl recover needs CID" '
test_must_fail ipfs-cluster-ctl recover test_must_fail ipfs-cluster-ctl recover
' '
test_expect_success "pin ls succeeds" ' test_expect_success IPFS,CLUSTER "pin ls succeeds" '
ipfs-cluster-ctl pin ls ipfs-cluster-ctl pin ls
' '
test_expect_success "pin ls on invalid CID succeeds" ' test_expect_success IPFS,CLUSTER "pin ls on invalid CID succeeds" '
ipfs-cluster-ctl pin ls XXXinvalid-CIDXXX ipfs-cluster-ctl pin ls XXXinvalid-CIDXXX
' '

View File

@ -5,14 +5,10 @@ test_description="Test cluster-ctl's pinning and unpinning functionality"
. lib/test-lib.sh . lib/test-lib.sh
test_expect_success "pre-reqs enabled" ' test_ipfs_init
test_ipfs_init && test_cluster_init
test_have_prereq IPFS_INIT &&
test_cluster_init &&
test_have_prereq CLUSTER_INIT
'
test_expect_success "pin data to cluster with ctl" ' test_expect_success IPFS,CLUSTER "pin data to cluster with ctl" '
cid=$(echo "test" | ipfs add -q) && cid=$(echo "test" | ipfs add -q) &&
echo $cid && echo $cid &&
ipfs-cluster-ctl pin add "$cid" && ipfs-cluster-ctl pin add "$cid" &&
@ -20,7 +16,7 @@ test_expect_success "pin data to cluster with ctl" '
ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED" ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED"
' '
test_expect_success "unpin data from cluster with ctl" ' test_expect_success IPFS,CLUSTER "unpin data from cluster with ctl" '
ipfs-cluster-ctl pin rm "$cid" && ipfs-cluster-ctl pin rm "$cid" &&
!(ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid") && !(ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid") &&
ipfs-cluster-ctl status "$cid" | grep -q -i "UNPINNED" ipfs-cluster-ctl status "$cid" | grep -q -i "UNPINNED"