diff options
author | Grzegorz Abramczyk <abramczykg@gmail.com> | 2020-01-05 12:34:51 +0100 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2020-01-05 12:34:51 +0100 |
commit | 3f64ef2b98796ba8e0391fb80483502fdafc6a8c (patch) | |
tree | 0fa45dd994f1f946b99af70b1521cdcc3c6c3ef5 | |
parent | 5ef18802cb82169843bd32edee838d4302d0dd97 (diff) | |
download | couchdb-3f64ef2b98796ba8e0391fb80483502fdafc6a8c.tar.gz |
Fix/1977 (#2296)
* Added db initialization for standalone instance
* Test setup
* Updated readme
* Added standalone option to rel/overlay/etc/default.ini
* Simplified test setup
* s/standalone/single_node/
Co-authored-by: Jan Lehnardt <jan@apache.org>
-rwxr-xr-x | dev/run | 2 | ||||
-rw-r--r-- | rel/overlay/etc/default.ini | 3 | ||||
-rw-r--r-- | src/setup/README.md | 17 | ||||
-rw-r--r-- | src/setup/src/setup_sup.erl | 6 | ||||
-rwxr-xr-x | src/setup/test/t-single-node-auto-setup.sh | 24 |
5 files changed, 51 insertions, 1 deletions
@@ -411,7 +411,7 @@ def hack_default_ini(ctx, node, contents): contents, flags=re.MULTILINE, ) - + contents = re.sub("n=3", "n=%s" % ctx["N"], contents) return contents diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini index 7bfbbe941..d8476f3e1 100644 --- a/rel/overlay/etc/default.ini +++ b/rel/overlay/etc/default.ini @@ -68,6 +68,9 @@ default_engine = couch ; inadvertently abusing partitions resulting in hot shards. The default ; is 10GiB. A value of 0 or less will disable partition size checks. ;max_partition_size = 10737418240 +; +; Start node in single_node mode so default databases are created immediately. +;single_node = true [purge] ; Allowed maximum number of documents in one purge request diff --git a/src/setup/README.md b/src/setup/README.md index e30c40027..8a76d9dc5 100644 --- a/src/setup/README.md +++ b/src/setup/README.md @@ -141,6 +141,23 @@ b. Same as in a. _replicator and _metadata, _db_updates endpoints and whatever else is needed. // TBD: collect what else is needed. +## Single node auto setup + +Option `single_node` set to `true` in `[couchdb]` configuration executes single node configuration on startup so the node is ready for use immediately. + +### Testing single_node auto setup + +Pass `--config-overrides single_node=true` and `-n 1` to `dev/run` + + + $ dev/run --no-join -n 1 --admin a:b --config-overrides single_node=true + + +Then, in a new terminal: + + $ src/setup/test/t-single_node.sh + +The script should show that single node is enabled. ## The Setup Endpoint diff --git a/src/setup/src/setup_sup.erl b/src/setup/src/setup_sup.erl index b81aa3afb..4670a0a59 100644 --- a/src/setup/src/setup_sup.erl +++ b/src/setup/src/setup_sup.erl @@ -35,4 +35,10 @@ start_link() -> %% =================================================================== init([]) -> + case config:get_boolean("couchdb", "single_node", false) of + true -> + setup:finish_cluster([]); + false -> + ok + end, {ok, {{one_for_one, 5, 10}, couch_epi:register_service(setup_epi, [])}}. diff --git a/src/setup/test/t-single-node-auto-setup.sh b/src/setup/test/t-single-node-auto-setup.sh new file mode 100755 index 000000000..0276990f5 --- /dev/null +++ b/src/setup/test/t-single-node-auto-setup.sh @@ -0,0 +1,24 @@ +#!/bin/sh -ex +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +HEADERS="-HContent-Type:application/json" + +# Show cluster state: +curl a:b@127.0.0.1:15986/_nodes/_all_docs +curl a:b@127.0.0.1:15984/_all_dbs +curl a:b@127.0.0.1:15984/_cluster_setup + +# Change the check +curl -g 'a:b@127.0.0.1:15984/_cluster_setup?ensure_dbs_exist=["_replicator","_users"]' + +echo "YAY ALL GOOD" |