ipfs-cluster/sharness/t0053-service-state-import.sh
Hector Sanjuan 063c5f1b78 Service: Select consensus on "init" (not on "daemon")
Fixes #865.

This makes the necessary changes so that consensu is selected on "init" with a
flag set, by default, to "crdt". This generates only a "crdt" or a "raft"
section, not both.

If the configuration file has a "raft" section, "raft" will be used to start
the daemon. If it has a "crdt" section, "crdt" will be used. If it has none or
both sections, an error will happen.

This also affects "state *" commands, which will now autoselect how to work
from the existing configuration.
2019-08-09 19:20:53 +02:00

57 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
test_description="Test service state import"
. lib/test-lib.sh
test_ipfs_init
test_cluster_init
test_confirm_importState
# Kill cluster daemon but keep data folder
cluster_kill
# WARNING: Updating the added content needs updating the importState file.
test_expect_success IPFS,CLUSTER "state import fails on incorrect format (crdt)" '
sleep 5 &&
echo "not exactly json" > badImportFile &&
test_expect_code 1 ipfs-cluster-service --config "test-config" state import -f badImportFile
'
test_expect_success IPFS,CLUSTER,IMPORTSTATE "state import succeeds on correct format (crdt)" '
sleep 5
cid=`docker exec ipfs sh -c "echo test_53 | ipfs add -q"` &&
ipfs-cluster-service --config "test-config" state import -f importState &&
cluster_start &&
sleep 5 &&
ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid" &&
ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED"
'
# Kill cluster daemon but keep data folder
cluster_kill
sleep 5
test_expect_success IPFS,CLUSTER "state import fails on incorrect format (raft)" '
ipfs-cluster-service --config "test-config" init --force --consensus raft &&
echo "not exactly json" > badImportFile &&
test_expect_code 1 ipfs-cluster-service --config "test-config" state import -f badImportFile
'
test_expect_success IPFS,CLUSTER,IMPORTSTATE "state import succeeds on correct format (raft)" '
sleep 5
cid=`docker exec ipfs sh -c "echo test_53 | ipfs add -q"` &&
ipfs-cluster-service --config "test-config" state import -f importState &&
cluster_start &&
sleep 5 &&
ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid" &&
ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED"
'
test_clean_ipfs
test_clean_cluster
test_done