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
The following commit(s) were added to refs/heads/mem3-seedlist by this push: new b85a9e2 Add some unit tests for seedlist configuration b85a9e2 is described below commit b85a9e26c1d4076e66f7a787b9c234e43dc09f23 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 | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 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..7d4fa85 --- /dev/null +++ b/src/mem3/test/mem3_seeds_test.erl @@ -0,0 +1,52 @@ +% 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} + ], + {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. + +setup() -> + test_util:start_couch([rexi]). + +teardown(Ctx) -> + test_util:stop_couch(Ctx).