ipfs-cluster/sharness/t0021-service-init.sh
Hector Sanjuan 00e78a6b6d
Daemon: support remote configuration (#868)
* Daemon: support remote configuration

This:

* Adds support for fetching the configuration from a remote HTTP location:

`ipfs-cluster-service init http://localhost:8080/ipfs/Qm...` will instruct
cluster to read the configuration file from ipfs on start (potentially making
use of ipns and dnslink).

This is done by creating a `service.json` like `{ "source": <url> }`.

The source is then read when loading that configuration every time the daemon starts.

This allows to let users always use a mutating remote configuration, potentially
adding/removing trusted peers from the list or adjusting other things.

* Configuration and state helpers from ipfs-cluster-service have been extracted
to its own cmdutils package. This will help supporting something like an
`ipfs-cluster-follow` command in the next releases.

* Allows to disable the rest api by not defining it in the configuration (I thought
this was already so, but apparently only affected the ipfsproxy).

* Removes informer/allocator configurations from the daemon (--alloc). No one used
a non default pair. In fact, it was potentially buggy to use the reposize one.
2019-08-09 12:56:27 +02:00

24 lines
786 B
Bash
Executable File

#!/bin/bash
test_description="Test init functionality"
. lib/test-lib.sh
test_expect_success "cluster-service init with --peers succeeds and fills peerstore" '
PEER1=/ip4/192.168.0.129/tcp/9196/ipfs/12D3KooWRN8KRjpyg9rsW2w7StbBRGper65psTZm68cjud9KAkaW
PEER2=/ip4/192.168.0.129/tcp/9196/ipfs/12D3KooWPwrYNj7VficHw5qYidepMGA85756kYgMdNmRM9A1ZHjN
ipfs-cluster-service --config "test-config" init --peers $PEER1,$PEER2 &&
grep -q $PEER1 test-config/peerstore &&
grep -q $PEER2 test-config/peerstore
'
test_expect_success "cluster-service init without --peers succeeds and creates empty peerstore" '
ipfs-cluster-service --config "test-config" init -f &&
[ -f "test-config/peerstore" ] &&
[ ! -s "test-config/peerstore" ]
'
test_clean_cluster
test_done