Skip to content

Commit 26efdb8

Browse files
committed
MB-67857: Ensure cbauth_many_notify_t actually works
The test doesn't actually fail when the assertion is reached, as the meck:wait can return successfully even when the function body fails. To avoid this, just send the Port to the test process, for it to run the assertion directly. Change-Id: Iee47e4d2052a9214340ada9a00544dce07943e4f Reviewed-on: https://review.couchbase.org/c/ns_server/+/232542 Tested-by: Peter Searby <[email protected]> Reviewed-by: Neelima Premsankar <[email protected]> Well-Formed: Restriction Checker Well-Formed: Build Bot <[email protected]>
1 parent 90f66d5 commit 26efdb8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/menelaus_cbauth.erl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,13 @@ cbauth_many_notify_t() ->
795795
meck:wait(N, menelaus_cbauth_worker, notify, ['_', '_'],
796796
?LONG_TIMEOUT)
797797
end, [2, 3, 4]),
798+
Parent = self(),
798799
%% Extract value from next update
799800
meck:expect(json_rpc_connection, perform_call,
800801
fun (_, "AuthCacheSvc.UpdateDB", {Info}, _) ->
801802
[{Node}] = proplists:get_value(nodes, Info, []),
802803
[undefined, Port] = proplists:get_value(ports, Node),
803-
%% Expect the last value, not the stale value
804-
?assertEqual(4, Port),
804+
Parent ! {port_sent, Port},
805805
{ok, true};
806806
(_Label, _Call, _EJsonArg, _Opts) ->
807807
{ok, true}
@@ -811,7 +811,14 @@ cbauth_many_notify_t() ->
811811
WorkerPid ! return_from_call,
812812
%% Wait for both the stuck and final call to return
813813
meck:wait(3, json_rpc_connection, perform_call,
814-
['_', "AuthCacheSvc.UpdateDB", '_', '_'], ?LONG_TIMEOUT).
814+
['_', "AuthCacheSvc.UpdateDB", '_', '_'], ?LONG_TIMEOUT),
815+
receive
816+
{port_sent, Port} ->
817+
%% Expect the last value, not the stale value
818+
?assertEqual(4, Port)
819+
after ?LONG_TIMEOUT ->
820+
error(timeout)
821+
end.
815822

816823
trigger_notification(ns_node_disco_events) ->
817824
%% To avoid needing to trick ns_node_disco into recognising fake nodes, just

0 commit comments

Comments
 (0)