This is an automated email from the ASF dual-hosted git repository. kocolosk pushed a commit to branch mem3-seedlist in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 6f3507303b3b1b0cb0ace0f552f2ac5fe336ece2 Author: Adam Kocoloski <kocol...@apache.org> AuthorDate: Wed Oct 17 16:28:48 2018 -0400 Add some unit tests for seedlist configuration Missing from this test suite is anything that actually triggers an internal replication between nodes in a cluster, because I don't know how to do that (or if it is even possible). --- src/mem3/test/mem3_seeds_test.erl | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/mem3/test/mem3_seeds_test.erl b/src/mem3/test/mem3_seeds_test.erl new file mode 100644 index 0000000..19e0079 --- /dev/null +++ b/src/mem3/test/mem3_seeds_test.erl @@ -0,0 +1,64 @@ +% 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. + +-module(mem3_seeds_test). + +-include_lib("eunit/include/eunit.hrl"). + +a_test_() -> + Tests = [ + {"empty seedlist should set status ok", fun empty_seedlist_status_ok/0}, + {"all seedlist nodes unreachable keeps status seeding", fun seedlist_misconfiguration/0}, + {"seedlist entries should be present in _nodes", fun check_nodelist/0} + ], + {setup, fun setup/0, fun teardown/1, Tests}. + +empty_seedlist_status_ok() -> + ok = application:start(mem3), + try + {ok, {Result}} = mem3_seeds:get_status(), + ?assertEqual({[]}, couch_util:get_value(seeds, Result)), + ?assertEqual(ok, couch_util:get_value(status, Result)) + after + application:stop(mem3) + end. + +seedlist_misconfiguration() -> + config:set("cluster", "seedlist", "couc...@node1.example.com,couc...@node2.example.com", false), + ok = application:start(mem3), + try + {ok, {Result}} = mem3_seeds:get_status(), + {Seeds} = couch_util:get_value(seeds, Result), + ?assertEqual(2, length(Seeds)), + ?assertMatch({_}, couch_util:get_value('couc...@node1.example.com', Seeds)), + ?assertMatch({_}, couch_util:get_value('couc...@node2.example.com', Seeds)), + ?assertEqual(seeding, couch_util:get_value(status, Result)) + after + application:stop(mem3) + end. + +check_nodelist() -> + config:set("cluster", "seedlist", "couc...@node1.example.com,couc...@node2.example.com", false), + ok = application:start(mem3), + try + Nodes = mem3:nodes(), + ?assert(lists:member('couc...@node1.example.com', Nodes)), + ?assert(lists:member('couc...@node2.example.com', Nodes)) + after + application:stop(mem3) + end. + +setup() -> + test_util:start_couch([rexi]). + +teardown(Ctx) -> + test_util:stop_couch(Ctx).