Permalink
Browse files

MB-100 Remove unreliable and not needed test

This is for old CouchDB functionallity, and it fails in the
build bot very often for unknown reasons. Equivalent test,
for new view engine under src/couch_set_view/test, without
any failures.

Change-Id: If65423d5ce42d8bf09f5e74a79eaee08454636cb
Reviewed-on: http://review.couchbase.org/23262
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
  • Loading branch information...
1 parent 83caba6 commit 41e04f04c24e4a7ef7fca509237f313dd533bccf @fdmanana fdmanana committed with fdmanana Dec 13, 2012
Showing with 0 additions and 307 deletions.
  1. +0 −306 test/etap/200-view-group-no-db-leaks.t
  2. +0 −1 test/etap/Makefile.am
@@ -1,306 +0,0 @@
-#!/usr/bin/env escript
-%% -*- erlang -*-
-%%! -smp enable
-
-% 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.
-
--record(user_ctx, {
- name = null,
- roles = [],
- handler
-}).
-
--record(db, {
- main_pid = nil,
- update_pid = nil,
- compactor_pid = nil,
- instance_start_time, % number of microsecs since jan 1 1970 as a binary string
- fd,
- fd_ref_counter,
- header = nil,
- committed_update_seq,
- fulldocinfo_by_id_btree,
- docinfo_by_seq_btree,
- local_docs_btree,
- update_seq,
- name,
- filepath,
- security = [],
- security_ptr = nil,
- user_ctx = #user_ctx{},
- waiting_delayed_commit = nil,
- fsync_options = [],
- options = []
-}).
-
-test_db_name() -> <<"couch_test_view_group_db_leaks">>.
-ddoc_name() -> <<"foo">>.
-
-main(_) ->
- test_util:init_code_path(),
-
- etap:plan(28),
- case (catch test()) of
- ok ->
- etap:end_tests();
- Other ->
- etap:diag(io_lib:format("Test died abnormally: ~p", [Other])),
- etap:bail(Other)
- end,
- ok.
-
-test() ->
- couch_server_sup:start_link(test_util:config_files()),
- timer:sleep(1000),
- put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
- put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
-
- delete_db(),
- create_db(),
-
- create_docs(),
- ok = create_design_doc(),
-
- ViewGroup = couch_view:get_group_server(
- test_db_name(), <<"_design/", (ddoc_name())/binary>>),
- etap:is(is_pid(ViewGroup), true, "got view group pid"),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- query_view(3, null, false),
- check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- create_new_doc(<<"doc1000">>),
- query_view(4, null, false),
- check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- Ref1 = get_db_ref_counter(),
- compact_db(),
- check_db_ref_count(),
- Ref2 = get_db_ref_counter(),
- etap:isnt(Ref1, Ref2, "DB ref counter changed"),
- etap:is(false, is_process_alive(Ref1), "old DB ref counter is not alive"),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- compact_view_group(),
- check_db_ref_count(),
- Ref3 = get_db_ref_counter(),
- etap:is(Ref3, Ref2, "DB ref counter didn't change"),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- create_new_doc(<<"doc1001">>),
- query_view(5, null, false),
- check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
-
- etap:diag("updating the design document with a new view definition"),
- ok = update_ddoc_view(),
-
- NewViewGroup = couch_view:get_group_server(
- test_db_name(), <<"_design/", (ddoc_name())/binary>>),
- etap:is(is_pid(NewViewGroup), true, "got new view group pid"),
- etap:is(is_process_alive(NewViewGroup), true, "new view group pid is alive"),
- etap:isnt(NewViewGroup, ViewGroup, "new view group has a different pid"),
- etap:diag("querying view with ?stale=ok, must return empty row set"),
- query_view(0, foo, ok),
- etap:diag("querying view (without stale), must return 5 rows with value 1"),
- query_view(5, 1, false),
- MonRef = erlang:monitor(process, ViewGroup),
- receive
- {'DOWN', MonRef, _, _, _} ->
- etap:diag("old view group is dead after ddoc update")
- after 5000 ->
- etap:bail("old view group is not dead after ddoc update")
- end,
-
- etap:diag("deleting database"),
- MonRef2 = erlang:monitor(process, NewViewGroup),
- ok = couch_server:delete(test_db_name(), []),
- receive
- {'DOWN', MonRef2, _, _, _} ->
- etap:diag("new view group is dead after DB deletion")
- after 5000 ->
- etap:bail("new view group did not die after DB deletion")
- end,
-
- ok = timer:sleep(1000),
- delete_db(),
- couch_server_sup:stop(),
- ok.
-
-admin_user_ctx() ->
- {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
-
-create_db() ->
- {ok, #db{main_pid = Pid} = Db} = couch_db:create(
- test_db_name(), [admin_user_ctx()]),
- put(db_main_pid, Pid),
- ok = couch_db:close(Db).
-
-delete_db() ->
- couch_server:delete(test_db_name(), [admin_user_ctx()]).
-
-compact_db() ->
- {ok, Db} = couch_db:open_int(test_db_name(), []),
- {ok, _} = couch_db:start_compact(Db),
- ok = couch_db:close(Db),
- wait_db_compact_done(10).
-
-wait_db_compact_done(0) ->
- etap:bail("DB compaction failed to finish.");
-wait_db_compact_done(N) ->
- {ok, Db} = couch_db:open_int(test_db_name(), []),
- ok = couch_db:close(Db),
- case is_pid(Db#db.compactor_pid) of
- false ->
- ok;
- true ->
- ok = timer:sleep(500),
- wait_db_compact_done(N - 1)
- end.
-
-compact_view_group() ->
- {ok, Pid} = couch_view_compactor:start_compact(test_db_name(), ddoc_name()),
- Ref = erlang:monitor(process, Pid),
- receive
- {'DOWN', Ref, _, _, normal} ->
- etap:diag("View group compaction finished");
- {'DOWN', Ref, _, _, Reason} ->
- etap:diag("View group compaction finished with error: " ++
- couch_util:to_list(Reason))
- after 90000 ->
- etap:bail("Timeout waiting for view group compaction")
- end.
-
-get_db_ref_counter() ->
- {ok, #db{fd_ref_counter = Ref} = Db} = couch_db:open_int(test_db_name(), []),
- ok = couch_db:close(Db),
- Ref.
-
-check_db_ref_count() ->
- {ok, #db{fd_ref_counter = Ref} = Db} = couch_db:open_int(test_db_name(), []),
- ok = couch_db:close(Db),
- etap:is(couch_ref_counter:count(Ref), 2,
- "DB ref counter is only held by couch_db and couch_db_updater"),
- ok.
-
-create_docs() ->
- {ok, Db} = couch_db:open(test_db_name(), [admin_user_ctx()]),
- Doc1 = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, <<"doc1">>}
- ]}},
- {<<"json">>, {[
- {<<"value">>, 1}
- ]}}
- ]}),
- Doc2 = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, <<"doc2">>}
- ]}},
- {<<"json">>, {[
- {<<"value">>, 2}
- ]}}
- ]}),
- Doc3 = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, <<"doc3">>}
- ]}},
- {<<"json">>, {[
- {<<"value">>, 3}
- ]}}
- ]}),
- ok = couch_db:update_docs(Db, [Doc1, Doc2, Doc3], [sort_docs]),
- couch_db:ensure_full_commit(Db),
- couch_db:close(Db).
-
-create_design_doc() ->
- {ok, Db} = couch_db:open(test_db_name(), [admin_user_ctx()]),
- DDoc = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, <<"_design/", (ddoc_name())/binary>>}
- ]}},
- {<<"json">>, {[
- {<<"language">>, <<"javascript">>},
- {<<"views">>, {[
- {<<"bar">>, {[
- {<<"map">>, <<"function(doc) { emit(doc._id, null); }">>}
- ]}}
- ]}}
- ]}}
- ]}),
- ok = couch_db:update_doc(Db, DDoc, []),
- couch_db:ensure_full_commit(Db),
- couch_db:close(Db).
-
-update_ddoc_view() ->
- {ok, Db} = couch_db:open(test_db_name(), [admin_user_ctx()]),
- DDoc = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, <<"_design/", (ddoc_name())/binary>>}
- ]}},
- {<<"json">>, {[
- {<<"language">>, <<"javascript">>},
- {<<"views">>, {[
- {<<"bar">>, {[
- {<<"map">>, <<"function(doc) { emit(doc._id, 1); }">>}
- ]}}
- ]}}
- ]}}
- ]}),
- ok = couch_db:update_doc(Db, DDoc, []),
- couch_db:ensure_full_commit(Db),
- couch_db:close(Db).
-
-create_new_doc(Id) ->
- {ok, Db} = couch_db:open(test_db_name(), [admin_user_ctx()]),
- Doc666 = couch_doc:from_json_obj({[
- {<<"meta">>, {[
- {<<"id">>, Id}
- ]}},
- {<<"json">>, {[
- {<<"value">>, 999}
- ]}}
- ]}),
- ok = couch_db:update_docs(Db, [Doc666]),
- couch_db:ensure_full_commit(Db),
- couch_db:close(Db).
-
-db_url() ->
- "http://" ++ get(addr) ++ ":" ++ get(port) ++ "/" ++
- binary_to_list(test_db_name()).
-
-query_view(ExpectedRowCount, ExpectedRowValue, Stale) ->
- {ok, Code, _Headers, Body} = test_util:request(
- db_url() ++ "/_design/" ++ binary_to_list(ddoc_name()) ++ "/_view/bar"
- ++ case Stale of
- false -> [];
- _ -> "?stale=" ++ atom_to_list(Stale)
- end,
- [],
- get),
- etap:is(Code, 200, "got view response"),
- {Props} = ejson:decode(Body),
- Rows = couch_util:get_value(<<"rows">>, Props, []),
- etap:is(length(Rows), ExpectedRowCount, "result set has correct # of rows"),
- lists:foreach(
- fun({Row}) ->
- case couch_util:get_value(<<"value">>, Row) of
- ExpectedRowValue ->
- ok;
- _ ->
- etap:bail("row has incorrect value")
- end
- end,
- Rows).
View
@@ -63,6 +63,5 @@ EXTRA_DIST = \
100-ref-counter.t \
150-invalid-view-seq.t \
190-json-stream-parse.t \
- 200-view-group-no-db-leaks.t \
201-view-group-shutdown.t \
202-dev-view-group-shutdown.t

0 comments on commit 41e04f0

Please sign in to comment.