Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve/fix GeoCouch tests

The GeoCouch tests didn't pass after CouchDB commit
0bd5d2244ffefed7f1e61f7dc9919de1f274c520.

Change-Id: I3369218ca95f12eba22285c17ec5f1bcec754289
Reviewed-on: http://review.couchbase.org/12617
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
  • Loading branch information...
commit ab77ef58a22cbb8a7f8c7cfebbc52a8eaa526949 1 parent 72fb18f
@vmx vmx authored vmx committed
Showing with 48 additions and 20 deletions.
  1. +8 −6 test/001-vtree.t
  2. +40 −14 test/002-bulk.t
View
14 test/001-vtree.t
@@ -29,6 +29,7 @@ main(_) ->
ok.
test() ->
+ couch_file_write_guard:sup_start_link(),
test_within(),
test_intersect(),
test_disjoint(),
@@ -128,7 +129,7 @@ test_insert() ->
[get_node(Fd, Pos5_1), get_node(Fd, Pos5_2)]}},
{ok, Tree1Node1_2_3_4_5},
"Insert a nodes into a full leaf node (root node)"),
- ok.
+ ok = couch_file:close(Fd).
test_within() ->
@@ -254,7 +255,7 @@ test_lookup() ->
etap:is(length(Lookup7), 3, "Query with multiple windows (2 windows)"),
{ok, Lookup8} = gc_test_util:lookup(Fd, Pos5, [Bbox2, Bbox4, {-20,1,-9,15}]),
etap:is(length(Lookup8), 4, "Query with multiple windows (3 windows)"),
- ok.
+ ok = couch_file:close(Fd).
test_multilookup() ->
@@ -318,7 +319,7 @@ test_multilookup() ->
etap:is(Lookup5, [],
"Don't find any nodes in tree (tree height=2) 2 bboxes (both "
"outside of all nodes"),
- ok.
+ ok = couch_file:close(Fd).
test_split_bbox_if_flipped() ->
%etap:plan(17),
@@ -812,7 +813,7 @@ test_delete() ->
{ok, {Mbr, _, [Node14od]}} = get_node(Fd, Pos19C1),
{empty, nil} = vtree:delete(Fd, <<"Node14">>, Mbr, Pos19),
- ok.
+ ok = couch_file:close(Fd).
test_delete_same_id() ->
% Test what happens if multiple emits in one function happened
@@ -941,7 +942,7 @@ test_delete_same_id() ->
etap:is(vtree:delete(Fd, <<"Node">>, Node5Mbr, Pos25_6), not_found,
"Node can't be found (tree height=2) (same ID)"),
- ok.
+ ok = couch_file:close(Fd).
test_split_node() ->
%etap:plan(3),
@@ -969,6 +970,7 @@ test_count_total() ->
"/tmp/randtree.bin", 20),
Count1 = vtree:count_total(Fd1, RootPos1),
etap:is(Count1, 20, "Total number of geometries is correct (a)"),
+ ok = couch_file:close(Fd1),
{ok, {Fd2, {RootPos2, _}}} = gc_test_util:build_random_tree(
"/tmp/randtree.bin", 338),
@@ -978,7 +980,7 @@ test_count_total() ->
Count3 = vtree:count_total(Fd2, nil),
etap:is(Count3, 0,
"Total number of geometries is correct (for empty tree)"),
- ok.
+ ok = couch_file:close(Fd2).
%% Helpers %%
View
54 test/002-bulk.t
@@ -45,6 +45,7 @@ main(_) ->
test() ->
+ couch_file_write_guard:sup_start_link(),
test_bulk_load(),
test_bulk_load_regression(),
test_omt_load(),
@@ -147,7 +148,7 @@ test_bulk_load() ->
etap:is(Results4_2,
[{4,[3],47},{4,[3],64},{4,[3],72},{5,[4],136},{6,[5],236}],
"Insertion was correct (bulk_load) (b)"),
- ok.
+ ok = couch_file:close(Fd).
test_bulk_load_regression() ->
Filename = "/tmp/bulk.bin",
@@ -175,7 +176,8 @@ test_bulk_load_regression() ->
"Number of nodes is correct (bulk_load_regression)"),
LeafDepths2 = vtreestats:leaf_depths(Fd, Pos2),
etap:is(LeafDepths2, [3],
- "Tree depth is equal and correct (bulk_load_regression)").
+ "Tree depth is equal and correct (bulk_load_regression)"),
+ ok = couch_file:close(Fd).
test_omt_load() ->
@@ -337,8 +339,8 @@ test_omt_write_tree() ->
[Node|Acc]
end, [], LeafNodes1 ++ LeafNodes2),
{Omt4, _OmtHeight4} = ?MOD:omt_load(LeafNodes3, 2),
- etap:is(Omt4, Omt1, "Round-trip worked (omt_write_tree)").
-
+ etap:is(Omt4, Omt1, "Round-trip worked (omt_write_tree)"),
+ ok = couch_file:close(Fd).
test_omt_sort_nodes() ->
Nodes1 = lists:foldl(fun(I, Acc) ->
@@ -412,7 +414,8 @@ test_seedtree_insert() ->
SeedTree7Tree = SeedTree7#seedtree_root.tree,
SeedTree7Inserted = get_seedtree_children(SeedTree7Tree),
etap:is(SeedTree7Inserted, [[Node], [Node6], [], []],
- "Seed tree is correct (seedtree_insert) (c)").
+ "Seed tree is correct (seedtree_insert) (c)"),
+ ok = couch_file:close(Fd).
test_seedtree_insert_list() ->
@@ -447,7 +450,8 @@ test_seedtree_insert_list() ->
SeedTree7Tree = SeedTree7#seedtree_root.tree,
SeedTree7Inserted = get_seedtree_children(SeedTree7Tree),
etap:is(SeedTree7Inserted, [[Node], [Node6], [], []],
- "Seed tree is correct (seedtree_insert_list) (a)").
+ "Seed tree is correct (seedtree_insert_list) (a)"),
+ ok = couch_file:close(Fd).
test_seedtree_init() ->
{ok, {Fd, {RootPos, _}}} = gc_test_util:build_random_tree(
@@ -467,7 +471,8 @@ test_seedtree_init() ->
SeedTree4 = ?MOD:seedtree_init(Fd, RootPos, 15),
etap:is(SeedTree4#seedtree_root.tree,
SeedTree3#seedtree_root.tree,
- "Lowest level of the seed tree was used").
+ "Lowest level of the seed tree was used"),
+ ok = couch_file:close(Fd).
test_seedtree_write_single() ->
@@ -494,7 +499,8 @@ test_seedtree_write_single() ->
"Number of nodes is correct (seedtree_write_single)"),
LeafDepths1 = vtreestats:leaf_depths(Fd, ResultPos1),
etap:is(LeafDepths1, [1],
- "Tree depth is equal and correct (seedtree_write_single)").
+ "Tree depth is equal and correct (seedtree_write_single)"),
+ ok = couch_file:close(Fd).
test_seedtree_write_case1() ->
@@ -527,6 +533,7 @@ test_seedtree_write_case1() ->
LeafDepths1 = vtreestats:leaf_depths(Fd, ResultPos1),
etap:is(LeafDepths1, [3],
"Tree depth is equal and correct (seedtree_write_case1)"),
+ ok = couch_file:close(Fd),
% Test 1.2: input tree produces splits (seedtree height=1)
TargetTreeNodeNum2 = 64,
@@ -548,6 +555,7 @@ test_seedtree_write_case1() ->
LeafDepths2 = vtreestats:leaf_depths(Fd2, ResultPos2),
etap:is(LeafDepths2, [3],
"Tree depth is equal and correct (seedtree_write_case1) (height==1)"),
+ ok = couch_file:close(Fd2),
% Test 1.3: input tree produces splits (recursively) (seedtree height=2)
% It would create a root node with 5 nodes
@@ -569,6 +577,7 @@ test_seedtree_write_case1() ->
LeafDepths3 = vtreestats:leaf_depths(Fd3, ResultPos3),
etap:is(LeafDepths3, [4],
"Tree depth is equal and correct (seedtree_write_case1) (height==2)"),
+ ok = couch_file:close(Fd3),
% Test 1.4: input tree produces splits (recursively) (seedtree height=3)
TargetTreeNodeNum4 = 900,
@@ -589,6 +598,7 @@ test_seedtree_write_case1() ->
LeafDepths4 = vtreestats:leaf_depths(Fd4, ResultPos4),
etap:is(LeafDepths4, [5],
"Tree depth is equal and correct (seedtree_write_case1) (height==3)"),
+ ok = couch_file:close(Fd4),
% Test 1.5: adding new data with height=4 (seedtree height=1)
TargetTreeNodeNum5 = 800,
@@ -611,7 +621,8 @@ test_seedtree_write_case1() ->
LeafDepths5 = vtreestats:leaf_depths(Fd5, ResultPos5),
etap:is(LeafDepths5, [5],
"Tree depth is equal and correct (seedtree_write_case1) (height==1) "
- "(new data height==4)").
+ "(new data height==4)"),
+ ok = couch_file:close(Fd5).
test_seedtree_write_case2() ->
% Test "Case 2: input R-tree is not shorter than the level of the
@@ -661,6 +672,7 @@ test_seedtree_write_case2() ->
LeafDepths2 = vtreestats:leaf_depths(Fd, ResultPos2),
etap:is(LeafDepths2, [5],
"Tree depth is equal and correct (seedtree_write_case2) (2 levels)"),
+ ok = couch_file:close(Fd),
% Test 2.3: input tree is too high (1 level) and procudes split
% (seedtree height=1)
@@ -682,6 +694,7 @@ test_seedtree_write_case2() ->
LeafDepths3 = vtreestats:leaf_depths(Fd3, ResultPos3),
etap:is(LeafDepths3, [3],
"Tree depth is equal and correct (seedtree_write_case2) (1 level)"),
+ ok = couch_file:close(Fd3),
% Test 2.4: input tree is too high (1 level) and produces multiple
% splits (recusively) (seedtree height=2)
@@ -707,6 +720,7 @@ test_seedtree_write_case2() ->
etap:is(LeafDepths4, [4],
"Tree depth is equal and correct (seedtree_write_case2) "
"(input tree 1 level too high)"),
+ ok = couch_file:close(Fd4),
% Test 2.5: input tree is too high (2 levels) and produces multiple
% splits (recusively) (seedtree height=2)
@@ -732,6 +746,7 @@ test_seedtree_write_case2() ->
etap:is(LeafDepths5, [4],
"Tree depth is equal and correct (seedtree_write_case2) "
"(input tree 2 levels too high)"),
+ ok = couch_file:close(Fd5),
% Test 2.6: input tree is too high (2 levels). Insert a OMT tree that
% leads to massive overflow
@@ -755,7 +770,8 @@ test_seedtree_write_case2() ->
LeafDepths6 = vtreestats:leaf_depths(Fd6, ResultPos6),
etap:is(LeafDepths6, [4],
"Tree depth is equal and correct (seedtree_write_case2) "
- "(input tree 2 levels too high, massive overflow)").
+ "(input tree 2 levels too high, massive overflow)"),
+ ok = couch_file:close(Fd6).
test_seedtree_write_case3() ->
% Test "Case 3: input R-tree is shorter than the level of the child level of the target node" (chapter 6.3)
@@ -783,6 +799,7 @@ test_seedtree_write_case3() ->
LeafDepths1 = vtreestats:leaf_depths(Fd, ResultPos1),
etap:is(LeafDepths1, [3],
"Tree depth is equal and correct (seedtree_write_case3)"),
+ ok = couch_file:close(Fd),
% Test 3.2: input tree is too small (2 levels)
@@ -815,6 +832,7 @@ test_seedtree_write_case3() ->
etap:is(LeafDepths2, [5],
"Tree depth is equal and correct (seedtree_write_case3) "
"(input tree 2 levels too small)"),
+ ok = couch_file:close(Fd2),
% Test 3.3: input tree is too small (1 level) and procudes split
% (seedtree height=1)
@@ -841,6 +859,7 @@ test_seedtree_write_case3() ->
etap:is(LeafDepths3, [3],
"Tree depth is equal and correct (seedtree_write_case3) "
"(input tree 1 level too small, seed tree height==1))"),
+ ok = couch_file:close(Fd3),
% Test 3.4: input tree is too small (1 level) and produces multiple
% splits (recusively) (seedtree height=2)
@@ -865,6 +884,7 @@ test_seedtree_write_case3() ->
etap:is(LeafDepths4, [4],
"Tree depth is equal and correct (seedtree_write_case3) "
"(input tree 1 level too small, seed tree height==2))"),
+ ok = couch_file:close(Fd4),
% Test 3.5: input tree is too small (2 levels) and produces multiple
% splits (recusively) (seedtree height=2)
@@ -888,7 +908,8 @@ test_seedtree_write_case3() ->
LeafDepths5 = vtreestats:leaf_depths(Fd5, ResultPos5),
etap:is(LeafDepths5, [4],
"Tree depth is equal and correct (seedtree_write_case3) "
- "(input tree 2 levels too small, seed tree height==2))").
+ "(input tree 2 levels too small, seed tree height==2))"),
+ ok = couch_file:close(Fd5).
test_insert_subtree() ->
@@ -933,7 +954,8 @@ test_insert_subtree() ->
etap:is(length(Lookup2), 270,
"Number of nodes is correct (insert_subtree) (splitted root node)"),
etap:is(LeafDepths2, [4],
- "Tree depth is equal and correct (insert_subtree) (splitted root node)").
+ "Tree depth is equal and correct (insert_subtree) (splitted root node)"),
+ ok = couch_file:close(Fd).
test_insert_outliers() ->
@@ -1092,7 +1114,8 @@ test_insert_outliers() ->
LeafDepths6 = vtreestats:leaf_depths(Fd, ResultPos6),
etap:is(LeafDepths6, [3],
"Tree depth is equal and correct (insert_outliers) "
- "(higher than target tree, doesn't fit into one node)").
+ "(higher than target tree, doesn't fit into one node)"),
+ ok = couch_file:close(Fd).
test_seedtree_write_insert() ->
@@ -1132,7 +1155,9 @@ test_seedtree_write_insert() ->
% single level target tree. There was a bug that couldn't handle it.
Leafnode = {Mbr1, #node{type=leaf}, Nodes1},
Result2 = ?MOD:seedtree_write_insert(Fd, [Leafnode], OmtTree1, OmtHeight1),
- etap:is(length(Result2), 8 , "Multiple root nodes (single level target)").
+ etap:is(length(Result2), 8 , "Multiple root nodes (single level target)"),
+ ok = couch_file:close(Fd).
+
%% Helpers %%
@@ -1176,6 +1201,7 @@ create_random_nodes_and_packed_tree(NodesNum, TreeNodeNum, MaxFilled) ->
{Nodes, Fd, RootPos}.
+
% @doc Returns the children of the seedtree leafs. It's a list where every
% element contains the list of children of one seedtree leaf.
-spec get_seedtree_children(Seedtree::tuple()) -> [tuple()].
Please sign in to comment.
Something went wrong with that request. Please try again.