New tests for retainer translation.

This commit is contained in:
Ryan Sandbach 2019-02-01 00:21:10 -05:00 committed by GitHub
parent 563e6529c0
commit 08f97b9e6f
1 changed files with 63 additions and 3 deletions

View File

@ -11,12 +11,15 @@ all() ->
groups() ->
[
{non_parallel_tests, [], [
coerce_configuration_data
coerce_configuration_data,
should_translate_amqp2mqtt_on_publish,
should_translate_amqp2mqtt_on_retention,
should_translate_amqp2mqtt_on_retention_search
]}
].
suite() ->
[{timetrap, {seconds, 60}}].
[{timetrap, {seconds, 600}}].
%% -------------------------------------------------------------------
%% Testsuite setup/teardown.
@ -88,4 +91,61 @@ expect_publishes(Topic, [Payload|Rest]) ->
{publish, Topic, Payload} -> expect_publishes(Topic, Rest)
after 500 ->
throw({publish_not_delivered, Payload})
end.
end.
%% -------------------------------------------------------------------
%% When a client is subscribed to TopicA/Device.Field and another
%% client publishes to TopicA/Device.Field the client should be
%% sent messages for the translated topic (TopicA/Device/Field)
%% -------------------------------------------------------------------
should_translate_amqp2mqtt_on_publish(Config) ->
P = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_mqtt),
{ok, C} = emqttc:start_link([{host, "localhost"},
{port, P},
{client_id, <<"simpleClientRetainer">>},
{proto_ver,3},
{logger, info},
{puback_timeout, 1}]),
emqttc:subscribe(C, <<"TopicA/Device.Field">>, qos1),
emqttc:publish(C,<<"TopicA/Device.Field">>, <<"Payload">>, [{retain,true}]),
expect_publishes(<<"TopicA/Device/Field">>, [<<"Payload">>]),
emqttc:disconnect(C),
ok.
%% -------------------------------------------------------------------
%% If a client is publishes a retained message to TopicA/Device.Field and another
%% client subscribes to TopicA/Device.Field the client should be
%% sent the retained message for the translated topic (TopicA/Device/Field)
%% -------------------------------------------------------------------
should_translate_amqp2mqtt_on_retention(Config) ->
P = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_mqtt),
{ok, C} = emqttc:start_link([{host, "localhost"},
{port, P},
{client_id, <<"simpleClientRetainer">>},
{proto_ver,3},
{logger, info},
{puback_timeout, 1}]),
emqttc:publish(C,<<"TopicA/Device.Field">>, <<"Payload">>, [{retain,true}]),
emqttc:subscribe(C, <<"TopicA/Device.Field">>, qos1),
expect_publishes(<<"TopicA/Device/Field">>, [<<"Payload">>]),
emqttc:disconnect(C),
ok.
%% -------------------------------------------------------------------
%% If a client is publishes a retained message to TopicA/Device.Field and another
%% client subscribes to TopicA/Device.Field the client should be
%% sent retained message for the translated topic (TopicA/Device/Field)
%% -------------------------------------------------------------------
should_translate_amqp2mqtt_on_retention_search(Config) ->
P = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_mqtt),
{ok, C} = emqttc:start_link([{host, "localhost"},
{port, P},
{client_id, <<"simpleClientRetainer">>},
{proto_ver,3},
{logger, info},
{puback_timeout, 1}]),
emqttc:publish(C,<<"TopicA/Device.Field">>, <<"Payload">>, [{retain,true}]),
emqttc:subscribe(C, <<"TopicA/Device/Field">>, qos1),
expect_publishes(<<"TopicA/Device/Field">>, [<<"Payload">>]),
emqttc:disconnect(C),
ok.