From a1fe84cfa8643ea174a5fe05510aad8b7d0aabd5 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Sat, 27 Nov 2021 17:31:27 -0500 Subject: Remove obsolete ddoc_cache_opener --- src/ddoc_cache/src/ddoc_cache.app.src | 3 +- src/ddoc_cache/src/ddoc_cache_opener.erl | 57 ---------------------- src/ddoc_cache/src/ddoc_cache_sup.erl | 8 --- .../test/eunit/ddoc_cache_eviction_test.erl | 15 +----- .../test/eunit/ddoc_cache_opener_test.erl | 31 ------------ .../test/eunit/ddoc_cache_refresh_test.erl | 11 +---- 6 files changed, 3 insertions(+), 122 deletions(-) delete mode 100644 src/ddoc_cache/src/ddoc_cache_opener.erl delete mode 100644 src/ddoc_cache/test/eunit/ddoc_cache_opener_test.erl diff --git a/src/ddoc_cache/src/ddoc_cache.app.src b/src/ddoc_cache/src/ddoc_cache.app.src index faacdf570..0132fe108 100644 --- a/src/ddoc_cache/src/ddoc_cache.app.src +++ b/src/ddoc_cache/src/ddoc_cache.app.src @@ -14,8 +14,7 @@ {description, "Design Document Cache"}, {vsn, git}, {registered, [ - ddoc_cache_lru, - ddoc_cache_opener + ddoc_cache_lru ]}, {applications, [ kernel, diff --git a/src/ddoc_cache/src/ddoc_cache_opener.erl b/src/ddoc_cache/src/ddoc_cache_opener.erl deleted file mode 100644 index b6b3dc9d5..000000000 --- a/src/ddoc_cache/src/ddoc_cache_opener.erl +++ /dev/null @@ -1,57 +0,0 @@ -% 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(ddoc_cache_opener). --behaviour(gen_server). --vsn(1). - --export([ - start_link/0 -]). - --export([ - init/1, - terminate/2, - handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3 -]). - -start_link() -> - gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). - -init(_) -> - {ok, nil}. - -terminate(_Reason, _St) -> - ok. - -handle_call(Msg, _From, St) -> - {stop, {invalid_call, Msg}, {invalid_call, Msg}, St}. - -% The do_evict clauses are upgrades while we're -% in a rolling reboot. -handle_cast({do_evict, _} = Msg, St) -> - gen_server:cast(ddoc_cache_lru, Msg), - {noreply, St}; -handle_cast({do_evict, DbName, DDocIds}, St) -> - gen_server:cast(ddoc_cache_lru, {do_refresh, DbName, DDocIds}), - {noreply, St}; -handle_cast(Msg, St) -> - {stop, {invalid_cast, Msg}, St}. - -handle_info(Msg, St) -> - {stop, {invalid_info, Msg}, St}. - -code_change(_OldVsn, State, _Extra) -> - {ok, State}. diff --git a/src/ddoc_cache/src/ddoc_cache_sup.erl b/src/ddoc_cache/src/ddoc_cache_sup.erl index cf1a1aafb..e94b542bd 100644 --- a/src/ddoc_cache/src/ddoc_cache_sup.erl +++ b/src/ddoc_cache/src/ddoc_cache_sup.erl @@ -30,14 +30,6 @@ init([]) -> 5000, worker, [ddoc_cache_lru] - }, - { - ddoc_cache_opener, - {ddoc_cache_opener, start_link, []}, - permanent, - 5000, - worker, - [ddoc_cache_opener] } ], {ok, {{one_for_one, 25, 1}, Children}}. diff --git a/src/ddoc_cache/test/eunit/ddoc_cache_eviction_test.erl b/src/ddoc_cache/test/eunit/ddoc_cache_eviction_test.erl index 68f9f2efe..fffb3ed47 100644 --- a/src/ddoc_cache/test/eunit/ddoc_cache_eviction_test.erl +++ b/src/ddoc_cache/test/eunit/ddoc_cache_eviction_test.erl @@ -40,8 +40,7 @@ check_eviction_test_() -> fun stop_couch/1, ddoc_cache_tutil:with([ {"evict_all", fun evict_all/1}, - {"dont_evict_all_unrelated", fun dont_evict_all_unrelated/1}, - {"check_upgrade_clause", fun check_upgrade_clause/1} + {"dont_evict_all_unrelated", fun dont_evict_all_unrelated/1} ]) }. @@ -73,15 +72,3 @@ dont_evict_all_unrelated({DbName, _}) -> {ok, _} = ddoc_cache_lru:handle_db_event(ShardName, deleted, foo), meck:wait(ddoc_cache_ev, event, [evict_noop, <<"test">>], 1000), ?assertEqual(4, ets:info(?CACHE, size)). - -check_upgrade_clause({DbName, _}) -> - ddoc_cache_tutil:clear(), - meck:reset(ddoc_cache_ev), - {ok, _} = ddoc_cache:open_doc(DbName, ?FOOBAR), - meck:wait(ddoc_cache_ev, event, [started, '_'], 1000), - meck:wait(ddoc_cache_ev, event, [default_started, '_'], 1000), - ?assertEqual(2, ets:info(?CACHE, size)), - gen_server:cast(ddoc_cache_opener, {do_evict, DbName}), - meck:wait(ddoc_cache_ev, event, [evicted, DbName], 1000), - meck:wait(2, ddoc_cache_ev, event, [removed, '_'], 1000), - ?assertEqual(0, ets:info(?CACHE, size)). diff --git a/src/ddoc_cache/test/eunit/ddoc_cache_opener_test.erl b/src/ddoc_cache/test/eunit/ddoc_cache_opener_test.erl deleted file mode 100644 index ba5bff057..000000000 --- a/src/ddoc_cache/test/eunit/ddoc_cache_opener_test.erl +++ /dev/null @@ -1,31 +0,0 @@ -% 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(ddoc_cache_opener_test). - --include_lib("couch/include/couch_db.hrl"). --include_lib("eunit/include/eunit.hrl"). --include("ddoc_cache_test.hrl"). - -empty_hull_test() -> - InitExpect = {ok, nil}, - TermExpect = ok, - CallExpect = {stop, {invalid_call, foo}, {invalid_call, foo}, baz}, - CastExpect = {stop, {invalid_cast, foo}, bar}, - InfoExpect = {stop, {invalid_info, foo}, bar}, - CCExpect = {ok, bar}, - ?assertEqual(InitExpect, ddoc_cache_opener:init(foo)), - ?assertEqual(TermExpect, ddoc_cache_opener:terminate(foo, bar)), - ?assertEqual(CallExpect, ddoc_cache_opener:handle_call(foo, bar, baz)), - ?assertEqual(CastExpect, ddoc_cache_opener:handle_cast(foo, bar)), - ?assertEqual(InfoExpect, ddoc_cache_opener:handle_info(foo, bar)), - ?assertEqual(CCExpect, ddoc_cache_opener:code_change(foo, bar, baz)). diff --git a/src/ddoc_cache/test/eunit/ddoc_cache_refresh_test.erl b/src/ddoc_cache/test/eunit/ddoc_cache_refresh_test.erl index 2db5b6cd2..e690f8235 100644 --- a/src/ddoc_cache/test/eunit/ddoc_cache_refresh_test.erl +++ b/src/ddoc_cache/test/eunit/ddoc_cache_refresh_test.erl @@ -42,8 +42,7 @@ check_refresh_test_() -> {"refresh_ddoc_rev", fun refresh_ddoc_rev/1}, {"refresh_vdu", fun refresh_vdu/1}, {"refresh_custom", fun refresh_custom/1}, - {"refresh_multiple", fun refresh_multiple/1}, - {"check_upgrade_clause", fun check_upgrade_clause/1} + {"refresh_multiple", fun refresh_multiple/1} ]) }. @@ -136,14 +135,6 @@ refresh_multiple({DbName, _}) -> ?assertEqual({ok, DDoc}, ddoc_cache:open_doc(DbName, ?FOOBAR, Rev)), ?assertEqual(2, ets:info(?CACHE, size)). -check_upgrade_clause({DbName, _}) -> - ddoc_cache_tutil:clear(), - meck:reset(ddoc_cache_ev), - {ok, _} = ddoc_cache:open_doc(DbName, ?FOOBAR), - [#entry{key = Key}] = ets:tab2list(?CACHE), - gen_server:cast(ddoc_cache_opener, {do_evict, DbName, [?FOOBAR]}), - meck:wait(ddoc_cache_ev, event, [update_noop, Key], 1000). - rand_string() -> Bin = crypto:strong_rand_bytes(8), to_hex(Bin, []). -- cgit v1.2.1