You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/01/05 11:35:03 UTC
[couchdb] branch master updated: Fix/1977 (#2296)
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3f64ef2 Fix/1977 (#2296)
3f64ef2 is described below
commit 3f64ef2b98796ba8e0391fb80483502fdafc6a8c
Author: Grzegorz Abramczyk <ab...@gmail.com>
AuthorDate: Sun Jan 5 12:34:51 2020 +0100
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 <ja...@apache.org>
---
dev/run | 2 +-
rel/overlay/etc/default.ini | 3 +++
src/setup/README.md | 17 +++++++++++++++++
src/setup/src/setup_sup.erl | 6 ++++++
src/setup/test/t-single-node-auto-setup.sh | 24 ++++++++++++++++++++++++
5 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/dev/run b/dev/run
index 482a0e8..3186a1f 100755
--- a/dev/run
+++ b/dev/run
@@ -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 7bfbbe9..d8476f3 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 e30c400..8a76d9d 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 b81aa3a..4670a0a 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 0000000..0276990
--- /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"