ipfs-cluster/sharness/t0052-service-state-export.sh
Hector Sanjuan a97ed10d0b Adopt api.Cid type - replaces cid.Cid everwhere.
This commit introduces an api.Cid type and replaces the usage of cid.Cid
everywhere.

The main motivation here is to override MarshalJSON so that Cids are
JSON-ified as '"Qm...."' instead of '{ "/": "Qm....." }', as this "ipld"
representation of IDs is horrible to work with, and our APIs are not issuing
IPLD objects to start with.

Unfortunately, there is no way to do this cleanly, and the best way is to just
switch everything to our own type.
2022-04-07 14:27:39 +02:00

38 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
test_description="Test service state export"
. lib/test-lib.sh
test_ipfs_init
test_cluster_init "" crdt
test_expect_success IPFS,CLUSTER,JQ "state export saves the correct state to expected file (crdt)" '
cid=`docker exec ipfs sh -c "echo test_52-1 | ipfs add -q"` &&
ipfs-cluster-ctl pin add "$cid" &&
sleep 5 &&
cluster_kill && sleep 5 &&
ipfs-cluster-service --debug --config "test-config" state export -f export.json &&
[ -f export.json ] &&
jq -r ".cid" export.json | grep -q "$cid"
'
cluster_kill
sleep 5
test_cluster_init "" raft
test_expect_success IPFS,CLUSTER,JQ "state export saves the correct state to expected file (raft)" '
cid=`docker exec ipfs sh -c "echo test_52-2 | ipfs add -q"` &&
ipfs-cluster-ctl pin add "$cid" &&
sleep 5 &&
cluster_kill && sleep 5 &&
ipfs-cluster-service --debug --config "test-config" state export -f export.json &&
[ -f export.json ] &&
jq -r ".cid" export.json | grep -q "$cid"
'
test_clean_ipfs
test_clean_cluster
test_done