From 742cbc24b97bc4210510a3abe258fb74a5332ab9 Mon Sep 17 00:00:00 2001 From: Fred Dushin Date: Wed, 8 Apr 2015 16:30:52 -0400 Subject: [PATCH] Relaxed the capability check to make it a subset check. --- src/rt.erl | 17 +++++++++++++++-- tests/verify_counter_capability.erl | 4 ++-- tests/verify_crdt_capability.erl | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/rt.erl b/src/rt.erl index ec62f08a..f8288b6b 100644 --- a/src/rt.erl +++ b/src/rt.erl @@ -853,22 +853,35 @@ capability(Node, Capability, Default) -> wait_until_capability(Node, Capability, Value) -> rt:wait_until(Node, fun(_) -> - cap_equal(Value, capability(Node, Capability)) + Cap = capability(Node, Capability), + lager:info("Capability on node ~p is ~p~n",[Node, Cap]), + cap_equal(Value, Cap) end). wait_until_capability(Node, Capability, Value, Default) -> rt:wait_until(Node, fun(_) -> Cap = capability(Node, Capability, Default), - io:format("capability is ~p ~p",[Node, Cap]), + lager:info("Capability on node ~p is ~p~n",[Node, Cap]), cap_equal(Value, Cap) end). +wait_until_capability_contains(Node, Capability, Value) -> + rt:wait_until(Node, + fun(_) -> + Cap = capability(Node, Capability), + lager:info("Capability on node ~p is ~p~n",[Node, Cap]), + cap_subset(Value, Cap) + end). + cap_equal(Val, Cap) when is_list(Cap) -> lists:sort(Cap) == lists:sort(Val); cap_equal(Val, Cap) -> Val == Cap. +cap_subset(Val, Cap) when is_list(Cap) -> + sets:is_subset(sets:from_list(Val), sets:from_list(Cap)). + wait_until_owners_according_to(Node, Nodes) -> SortedNodes = lists:usort(Nodes), F = fun(N) -> diff --git a/tests/verify_counter_capability.erl b/tests/verify_counter_capability.erl index eb3f31d0..5f259c2d 100644 --- a/tests/verify_counter_capability.erl +++ b/tests/verify_counter_capability.erl @@ -40,7 +40,7 @@ confirm() -> %% Get put on all nodes Config = [], [Legacy, Previous] = Nodes = rt:build_cluster([{legacy, Config}, {previous, Config}]), - ?assertEqual(ok, rt:wait_until_capability(Previous, {riak_kv, crdt}, [pncounter])), + ?assertEqual(ok, rt:wait_until_capability_contains(Previous, {riak_kv, crdt}, [pncounter])), verify_counter_converge:set_allow_mult_true(Nodes), {LegacyPB, LegacyHttp} = get_clients(Legacy), @@ -63,7 +63,7 @@ confirm() -> PrevPB2 = rt:pbc(Legacy), - ?assertEqual(ok, rt:wait_until_capability(Previous, {riak_kv, crdt}, [pncounter,riak_dt_pncounter,riak_dt_orswot,riak_dt_map])), + ?assertEqual(ok, rt:wait_until_capability_contains(Previous, {riak_kv, crdt}, [pncounter,riak_dt_pncounter,riak_dt_orswot,riak_dt_map])), ?assertMatch(ok, rhc:counter_incr(LegacyHttp, ?BUCKET, ?KEY, 1)), ?assertMatch({ok, 5}, rhc:counter_val(LegacyHttp, ?BUCKET, ?KEY)), diff --git a/tests/verify_crdt_capability.erl b/tests/verify_crdt_capability.erl index 1bff1df4..e5d632ad 100644 --- a/tests/verify_crdt_capability.erl +++ b/tests/verify_crdt_capability.erl @@ -39,7 +39,7 @@ confirm() -> %% Get put on all nodes Config = [], [Previous, Current]=Nodes = rt:build_cluster([{previous, Config}, {current, Config}]), - ?assertEqual(ok, rt:wait_until_capability(Current, {riak_kv, crdt}, [pncounter,riak_dt_pncounter,riak_dt_orswot,riak_dt_map])), + ?assertEqual(ok, rt:wait_until_capability_contains(Current, {riak_kv, crdt}, [pncounter])), verify_counter_converge:set_allow_mult_true(Nodes), @@ -61,7 +61,7 @@ confirm() -> rt:upgrade(Previous, current), lager:info("Upgrayded!!"), - ?assertEqual(ok, rt:wait_until_capability(Current, {riak_kv, crdt}, [riak_dt_pncounter, riak_dt_orswot, riak_dt_map, pncounter])), + ?assertEqual(ok, rt:wait_until_capability_contains(Current, {riak_kv, crdt}, [riak_dt_pncounter, riak_dt_orswot, riak_dt_map, pncounter])), ?assertMatch(ok, rhc:counter_incr(PrevHttp, ?BUCKET, ?KEY, 1)), ?assertMatch({ok, 5}, rhc:counter_val(PrevHttp, ?BUCKET, ?KEY)),