ipfs-cluster/sharness/t0010-ctl-basic-commands.sh
Wyatt 47b744f1c0 ipfs-cluster-service state upgrade cli command
ipfs-cluster-service now has a migration subcommand that upgrades
    persistant state snapshots with an out-of-date format version to the
    newest version of raft state. If all cluster members shutdown with
    consistent state, upgrade ipfs-cluster, and run the state upgrade command,
    the new version of cluster will be compatible with persistent storage.
    ipfs-cluster now validates its persistent state upon loading it and exits
    with a clear error in the case the state format version is not up to date.

    Raft snapshotting is enforced on all shutdowns and the json backup is no
    longer run.  This commit makes use of recent changes to libp2p-raft
    allowing raft states to implement their own marshaling strategies. Now
    mapstate handles the logic for its (de)serialization.  In the interest of
    supporting various potential upgrade formats the state serialization
    begins with a varint (right now one byte) describing the version.

    Some go tests are modified and a go test is added to cover new ipfs-cluster
    raft snapshot reading functions.  Sharness tests are added to cover the
    state upgrade command.
2017-11-28 22:35:48 -05:00

64 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
test_description="Test ctl installation and some basic commands"
. lib/test-lib.sh
test_expect_success "current dir is writeable" '
echo "Writability check" >test.txt &&
test_when_finished "rm test.txt"
'
test_expect_success "cluster-ctl --version succeeds" '
ipfs-cluster-ctl --version
'
test_expect_success "cluster-ctl help commands succeed" '
ipfs-cluster-ctl --help &&
ipfs-cluster-ctl -h &&
ipfs-cluster-ctl h &&
ipfs-cluster-ctl help
'
test_expect_success "cluster-ctl help has 120 char limits" '
ipfs-cluster-ctl --help >help.txt &&
test_when_finished "rm help.txt" &&
LENGTH="$(cat help.txt | awk '"'"'{print length }'"'"' | sort -nr | head -n 1)" &&
[ ! "$LENGTH" -gt 120 ]
'
test_expect_success "cluster-ctl help output looks good" '
ipfs-cluster-ctl --help | egrep -q -i "^(Usage|Commands|Global options)"
'
test_expect_success "cluster-ctl commands output looks good" '
ipfs-cluster-ctl commands > commands.txt &&
test_when_finished "rm commands.txt" &&
egrep -q "ipfs-cluster-ctl id" commands.txt &&
egrep -q "ipfs-cluster-ctl peers" commands.txt &&
egrep -q "ipfs-cluster-ctl pin" commands.txt &&
egrep -q "ipfs-cluster-ctl status" commands.txt &&
egrep -q "ipfs-cluster-ctl sync" commands.txt &&
egrep -q "ipfs-cluster-ctl recover" commands.txt &&
egrep -q "ipfs-cluster-ctl version" commands.txt &&
egrep -q "ipfs-cluster-ctl commands" commands.txt
'
test_expect_success "All cluster-ctl command docs are 120 columns or less" '
export failure="0" &&
ipfs-cluster-ctl commands | awk "NF" >commands.txt &&
test_when_finished "rm commands.txt" &&
while read cmd
do
LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -n 1)"
[ "$LENGTH" -gt 120 ] &&
{ echo "$cmd" help text is longer than 119 chars "($LENGTH)"; export failure="1"; }
done <commands.txt
if [ $failure -eq "1" ]; then
return 1
fi
'
test_done