Skip to content

Commit a5e149c

Browse files
committed
test: use client_authentication_failed tracepoint
1 parent 8e057af commit a5e149c

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/gen_rpc_client.erl

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -297,24 +297,14 @@ handle_continue({connect, Node, Port, Key}, #state{driver_mod = DriverMod, drive
297297
{stop, {shutdown, Error}, State}
298298
end;
299299
{error, ReasonTuple} ->
300-
case ReasonTuple of
301-
{badrpc, invalid_cookie} ->
302-
?tp(error, gen_rpc_client_authentication_bad_cookie, #{
303-
driver => Driver,
304-
node => Node,
305-
port => Port,
306-
key => Key,
307-
domain => ?D_CLIENT
308-
});
309-
_ ->
310-
ok
311-
end,
312-
?log(error, "client_authentication_failed",
313-
#{driver => Driver,
314-
node => Node,
315-
port => Port,
316-
key => Key,
317-
cause => ReasonTuple}),
300+
?tp(error, client_authentication_failed, #{
301+
driver => Driver,
302+
node => Node,
303+
port => Port,
304+
key => Key,
305+
cause => ReasonTuple,
306+
domain => ?D_CLIENT
307+
}),
318308
{stop, {shutdown, ReasonTuple}, State};
319309
{unreachable, Reason} ->
320310
%% This should be badtcp but to conform with

test/auth_SUITE.erl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ t_auth_server_fail(Config) ->
139139
)
140140
end,
141141
[ fun ?MODULE:prop_canary/1
142-
, fun ?MODULE:prop_invalid_cookie_error_trace/1
142+
, fun ?MODULE:prop_client_authentication_failed_trace/1
143143
]).
144144

145145
%% In this testcase we don't test auth, but the rest of the gen_rpc library.
@@ -293,8 +293,20 @@ canary() ->
293293
prop_canary(Trace) ->
294294
?assertMatch([], ?of_kind(gen_rpc_canary, Trace)).
295295

296-
prop_invalid_cookie_error_trace(Trace) ->
297-
?assertMatch([_ | _], ?of_kind(gen_rpc_client_authentication_bad_cookie, Trace)).
296+
prop_client_authentication_failed_trace(Trace) ->
297+
Events = ?of_kind(client_authentication_failed, Trace),
298+
?assertMatch([_ | _], Events),
299+
?assert(
300+
lists:any(
301+
fun
302+
(#{cause := {badrpc, invalid_cookie}}) ->
303+
true;
304+
(_) ->
305+
false
306+
end,
307+
Events
308+
)
309+
).
298310

299311
prop_no_fallback(Trace) ->
300312
?assertMatch([], ?of_kind([gen_rpc_insecure_fallback, gen_rpc_auth_cr_v1_fallback], Trace)).

0 commit comments

Comments
 (0)