summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2010-02-04 03:40:20 +0000
committerMatthias Radestock <matthias@lshift.net>2010-02-04 03:40:20 +0000
commitb3711bfb0cf231d352ef96d9b95f01780d2731a2 (patch)
treedd00bb2d527ab40c8c3c7a2c7382d0472bd4c9f6 /src
parente40b1a9d3e92edd821e9e914bb406970268ce361 (diff)
downloadrabbitmq-server-git-b3711bfb0cf231d352ef96d9b95f01780d2731a2.tar.gz
add tests for pg_local
these give us nearly complete code coverage
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_tests.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 8b5467e6c4..d4eb3adeda 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -49,6 +49,7 @@ test_content_prop_roundtrip(Datum, Binary) ->
all_tests() ->
passed = test_priority_queue(),
+ passed = test_pg_local(),
passed = test_unfold(),
passed = test_parsing(),
passed = test_topic_matching(),
@@ -183,6 +184,28 @@ test_simple_n_element_queue(N) ->
{true, false, N, ToListRes, Items} = test_priority_queue(Q),
passed.
+test_pg_local() ->
+ [P, Q] = [spawn(fun () -> receive X -> X end end) || _ <- [x, x]],
+ check_pg_local(ok, [], []),
+ check_pg_local(pg_local:join(a, P), [P], []),
+ check_pg_local(pg_local:join(b, P), [P], [P]),
+ check_pg_local(pg_local:join(a, P), [P, P], [P]),
+ check_pg_local(pg_local:join(a, Q), [P, P, Q], [P]),
+ check_pg_local(pg_local:join(b, Q), [P, P, Q], [P, Q]),
+ check_pg_local(pg_local:join(b, Q), [P, P, Q], [P, Q, Q]),
+ check_pg_local(pg_local:leave(a, P), [P, Q], [P, Q, Q]),
+ check_pg_local(pg_local:leave(b, P), [P, Q], [Q, Q]),
+ check_pg_local(pg_local:leave(a, P), [Q], [Q, Q]),
+ check_pg_local(pg_local:leave(a, P), [Q], [Q, Q]),
+ [X ! done || X <- [P, Q]],
+ check_pg_local(ok, [], []),
+ passed.
+
+check_pg_local(ok, APids, BPids) ->
+ ok = pg_local:sync(),
+ [true, true] = [lists:sort(Pids) == lists:sort(pg_local:get_members(Key)) ||
+ {Key, Pids} <- [{a, APids}, {b, BPids}]].
+
test_unfold() ->
{[], test} = rabbit_misc:unfold(fun (_V) -> false end, test),
List = lists:seq(2,20,2),