config: profile tests, docs

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera 2017-09-06 13:54:45 +02:00
parent b59354bf6a
commit d7376cdab0
3 changed files with 51 additions and 12 deletions

View File

@ -17,6 +17,7 @@ on a running daemon do not read the config file at runtime.
- [`Mounts`](#mounts)
- [`Reprovider`](#reprovider)
- [`Swarm`](#swarm)
- [`Profiles`](#profiles)
## `Addresses`
Contains information about various listener addresses to be used by this node.
@ -287,3 +288,17 @@ LowWater is the minimum number of connections to maintain.
HighWater is the number of connections that, when exceeded, will trigger a connection GC operation.
- `GracePeriod`
GracePeriod is a time duration that new connections are immune from being closed by the connection manager.
## Profiles
Configuration profiles allow to tweak configuration quickly. Profiles can be
applied with `--profile` flag to `ipfs init` or with `ipfs config profile apply`
command.
- `server` profile
Recommended for nodes with public IPv4 address, disables host and content
discovery in local networks.
- `test` profile
Reduces external interference, useful for running ipfs in test environments.
Note that with these settings node won't be able to talk to the rest of the
network without manual bootstrap.

View File

@ -7,7 +7,7 @@ type Profile struct {
Unapply Transformer
}
// Profiles is a map holding configuration transformers
// Profiles is a map holding configuration transformers. Docs are in docs/config.md
var Profiles = map[string]*Profile{
"server": {
Apply: func(c *Config) error {
@ -65,17 +65,17 @@ var Profiles = map[string]*Profile{
},
"badgerds": {
Apply: func(c *Config) error {
c.Datastore.Spec = map[string]interface{}{
"type": "measure",
"prefix": "badger.datastore",
"child": map[string]interface{}{
"type": "badgerds",
"path": "badgerds",
"syncWrites": true,
},
}
return nil
},
c.Datastore.Spec = map[string]interface{}{
"type": "measure",
"prefix": "badger.datastore",
"child": map[string]interface{}{
"type": "badgerds",
"path": "badgerds",
"syncWrites": true,
},
}
return nil
},
Unapply: func(c *Config) error {
c.Datastore.Spec = DefaultDatastoreConfig().Spec
return nil

View File

@ -151,6 +151,30 @@ test_config_cmd() {
echo "Error: setting private key with API is not supported" > replace_expected
test_cmp replace_out replace_expected
'
test_expect_success "'ipfs config Swarm.AddrFilters' looks good" '
ipfs config Swarm.AddrFilters > actual_config &&
test $(cat actual_config | wc -l) = 1
'
test_expect_success "'ipfs config profile apply server' works" '
ipfs config profile apply server
'
test_expect_success "'ipfs config Swarm.AddrFilters' looks good with server profile" '
ipfs config Swarm.AddrFilters > actual_config &&
test $(cat actual_config | wc -l) = 17
'
test_expect_success "'ipfs config profile revert server' works" '
ipfs config profile revert server
'
test_expect_success "'ipfs config Swarm.AddrFilters' looks good with reverted server profile" '
ipfs config Swarm.AddrFilters > actual_config &&
test $(cat actual_config | wc -l) = 1
'
}
test_init_ipfs