diff options
author | Jan Lehnardt <jan@apache.org> | 2017-06-03 11:38:30 +0200 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2017-06-03 11:38:30 +0200 |
commit | 401d7762792878f5787744ae2f6b8c7e31241cb8 (patch) | |
tree | 84b8ad030bc1b3581da40ff6ccd1ba50601ce55b | |
parent | e8d1e32ba3b4f5f3be0e06e5269b12d811f24d52 (diff) | |
parent | b107042a3193047bdf66fa5c5154c7f2f586814a (diff) | |
download | couchdb-401d7762792878f5787744ae2f6b8c7e31241cb8.tar.gz |
Merge remote-tracking branch 'robertkowalski/2594-2598-number-of-nodes'
* robertkowalski/2594-2598-number-of-nodes:
fix wording
use config:setineger/3
require nodecount on setup
-rw-r--r-- | src/setup.erl | 13 | ||||
-rw-r--r-- | src/setup_httpd.erl | 3 | ||||
-rwxr-xr-x | test/t-frontend-setup.sh | 7 | ||||
-rwxr-xr-x | test/t.sh | 7 |
4 files changed, 23 insertions, 7 deletions
diff --git a/src/setup.erl b/src/setup.erl index b27c6c63d..e58c32d4a 100644 --- a/src/setup.erl +++ b/src/setup.erl @@ -24,6 +24,11 @@ require_admins(undefined, {undefined, undefined}) -> require_admins(_,_) -> ok. +require_node_count(undefined) -> + throw({error, "Cluster setup requires node_count to be configured"}); +require_node_count(_) -> + ok. + error_bind_address() -> throw({error, "Cluster setup requires bind_addres != 127.0.0.1"}). @@ -91,7 +96,8 @@ enable_cluster_http(Options) -> {<<"username">>, couch_util:get_value(username, Options)}, {<<"password">>, couch_util:get_value(password, Options)}, {<<"bind_address">>, couch_util:get_value(bind_address, Options)}, - {<<"port">>, couch_util:get_value(port, Options)} + {<<"port">>, couch_util:get_value(port, Options)}, + {<<"node_count">>, couch_util:get_value(node_count, Options)} ]}), Headers = [ @@ -142,6 +148,10 @@ enable_cluster_int(Options, no) -> config:set("chttpd", "bind_address", binary_to_list(NewBindAddress)) end, + NodeCount = couch_util:get_value(node_count, Options), + ok = require_node_count(NodeCount), + config:set_integer("cluster", "n", NodeCount), + Port = proplists:get_value(port, Options), case Port of undefined -> @@ -152,7 +162,6 @@ enable_cluster_int(Options, no) -> config:set_integer("chttpd", "port", Port) end, couch_log:notice("Enable Cluster: ~p~n", [Options]). - %cluster_state:set(enabled). maybe_set_admin(Username, Password) -> case couch_auth_cache:get_admin(Username) of diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl index 006ed455b..73fa4ee38 100644 --- a/src/setup_httpd.erl +++ b/src/setup_httpd.erl @@ -61,7 +61,8 @@ handle_action("enable_cluster", Setup) -> {port, <<"port">>}, {remote_node, <<"remote_node">>}, {remote_current_user, <<"remote_current_user">>}, - {remote_current_password, <<"remote_current_password">>} + {remote_current_password, <<"remote_current_password">>}, + {node_count, <<"node_count">>} ], Setup), case setup:enable_cluster(Options) of {error, cluster_enabled} -> diff --git a/test/t-frontend-setup.sh b/test/t-frontend-setup.sh index 1c610b6cc..74743bb76 100755 --- a/test/t-frontend-setup.sh +++ b/test/t-frontend-setup.sh @@ -16,10 +16,10 @@ HEADERS="-HContent-Type:application/json" curl a:b@127.0.0.1:15986/_nodes/_all_docs # Enable Cluster on node A -curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0"}' $HEADERS +curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0","node_count":2}' $HEADERS # Enable Cluster on node B -curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","remote_node":"127.0.0.1","port":"25984","remote_current_user":"a","remote_current_password":"b","username":"foo","password":"baz","bind_address":"0.0.0.0"}' $HEADERS +curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","remote_node":"127.0.0.1","port":"25984","remote_current_user":"a","remote_current_password":"b","username":"foo","password":"baz","bind_address":"0.0.0.0","node_count":2}' $HEADERS # Add node B on node A curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"add_node","username":"foo","password":"baz","host":"127.0.0.1","port":25984}' $HEADERS @@ -57,4 +57,7 @@ curl a:b@127.0.0.1:25984/_replicator curl a:b@127.0.0.1:25984/_metadata curl a:b@127.0.0.1:25984/_global_changes +# Number of nodes is set to 2 +curl a:b@127.0.0.1:25984/_node/node2@127.0.0.1/_config/cluster/n + echo "YAY ALL GOOD" @@ -16,10 +16,10 @@ HEADERS="-HContent-Type:application/json" curl a:b@127.0.0.1:15986/_nodes/_all_docs # Enable Cluster on node A -curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0"}' $HEADERS +curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0","node_count":2}' $HEADERS # Enable Cluster on node B -curl a:b@127.0.0.1:25984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0"}' $HEADERS +curl a:b@127.0.0.1:25984/_cluster_setup -d '{"action":"enable_cluster","username":"foo","password":"baz","bind_address":"0.0.0.0","node_count":2}' $HEADERS # Add node B on node A curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"add_node","username":"foo","password":"baz","host":"127.0.0.1","port":25984}' $HEADERS @@ -57,4 +57,7 @@ curl a:b@127.0.0.1:25984/_replicator curl a:b@127.0.0.1:25984/_metadata curl a:b@127.0.0.1:25984/_global_changes +# Number of nodes is set to 2 +curl a:b@127.0.0.1:25984/_node/node2@127.0.0.1/_config/cluster/n + echo "YAY ALL GOOD" |