|
@@ -53,6 +53,7 @@ sasl_only_tests() ->
|
|
|
%% tests that do not need to be run on all groups
|
|
%% tests that do not need to be run on all groups
|
|
|
only_once_tests() ->
|
|
only_once_tests() ->
|
|
|
[
|
|
[
|
|
|
|
|
+ t_begin_offset_earliest,
|
|
|
t_bridge_rule_action_source,
|
|
t_bridge_rule_action_source,
|
|
|
t_cluster_group,
|
|
t_cluster_group,
|
|
|
t_node_joins_existing_cluster,
|
|
t_node_joins_existing_cluster,
|
|
@@ -585,7 +586,7 @@ kafka_config(TestCase, _KafkaType, Config) ->
|
|
|
" max_rejoin_attempts = 5\n"
|
|
" max_rejoin_attempts = 5\n"
|
|
|
" offset_commit_interval_seconds = 3\n"
|
|
" offset_commit_interval_seconds = 3\n"
|
|
|
%% todo: matrix this
|
|
%% todo: matrix this
|
|
|
- " offset_reset_policy = reset_to_latest\n"
|
|
|
|
|
|
|
+ " offset_reset_policy = latest\n"
|
|
|
" }\n"
|
|
" }\n"
|
|
|
"~s"
|
|
"~s"
|
|
|
" key_encoding_mode = none\n"
|
|
" key_encoding_mode = none\n"
|
|
@@ -1926,3 +1927,57 @@ t_cluster_node_down(Config) ->
|
|
|
end
|
|
end
|
|
|
),
|
|
),
|
|
|
ok.
|
|
ok.
|
|
|
|
|
+
|
|
|
|
|
+t_begin_offset_earliest(Config) ->
|
|
|
|
|
+ MQTTTopic = ?config(mqtt_topic, Config),
|
|
|
|
|
+ ResourceId = resource_id(Config),
|
|
|
|
|
+ Payload = emqx_guid:to_hexstr(emqx_guid:gen()),
|
|
|
|
|
+ {ok, C} = emqtt:start_link([{proto_ver, v5}]),
|
|
|
|
|
+ on_exit(fun() -> emqtt:stop(C) end),
|
|
|
|
|
+ {ok, _} = emqtt:connect(C),
|
|
|
|
|
+ {ok, _, [2]} = emqtt:subscribe(C, MQTTTopic, 2),
|
|
|
|
|
+
|
|
|
|
|
+ ?check_trace(
|
|
|
|
|
+ begin
|
|
|
|
|
+ %% publish a message before the bridge is started.
|
|
|
|
|
+ NumMessages = 5,
|
|
|
|
|
+ lists:foreach(
|
|
|
|
|
+ fun(N) ->
|
|
|
|
|
+ publish(Config, [
|
|
|
|
|
+ #{
|
|
|
|
|
+ key => <<"mykey", (integer_to_binary(N))/binary>>,
|
|
|
|
|
+ value => Payload,
|
|
|
|
|
+ headers => [{<<"hkey">>, <<"hvalue">>}]
|
|
|
|
|
+ }
|
|
|
|
|
+ ])
|
|
|
|
|
+ end,
|
|
|
|
|
+ lists:seq(1, NumMessages)
|
|
|
|
|
+ ),
|
|
|
|
|
+
|
|
|
|
|
+ {ok, _} = create_bridge(Config, #{
|
|
|
|
|
+ <<"kafka">> => #{<<"offset_reset_policy">> => <<"earliest">>}
|
|
|
|
|
+ }),
|
|
|
|
|
+
|
|
|
|
|
+ #{num_published => NumMessages}
|
|
|
|
|
+ end,
|
|
|
|
|
+ fun(Res, _Trace) ->
|
|
|
|
|
+ #{num_published := NumMessages} = Res,
|
|
|
|
|
+ %% we should receive messages published before starting
|
|
|
|
|
+ %% the consumers
|
|
|
|
|
+ Published = receive_published(#{n => NumMessages}),
|
|
|
|
|
+ Payloads = lists:map(
|
|
|
|
|
+ fun(#{payload := P}) -> emqx_json:decode(P, [return_maps]) end,
|
|
|
|
|
+ Published
|
|
|
|
|
+ ),
|
|
|
|
|
+ ?assert(
|
|
|
|
|
+ lists:all(
|
|
|
|
|
+ fun(#{<<"value">> := V}) -> V =:= Payload end,
|
|
|
|
|
+ Payloads
|
|
|
|
|
+ ),
|
|
|
|
|
+ #{payloads => Payloads}
|
|
|
|
|
+ ),
|
|
|
|
|
+ ?assertEqual(NumMessages, emqx_resource_metrics:received_get(ResourceId)),
|
|
|
|
|
+ ok
|
|
|
|
|
+ end
|
|
|
|
|
+ ),
|
|
|
|
|
+ ok.
|