Add comments to test
This commit is contained in:
parent
71c2ad1292
commit
c26201c4bb
|
@ -322,6 +322,7 @@ stream_filtering(Config) ->
|
|||
Version = ?config(version, Config),
|
||||
Client = ?config(stomp_client, Config),
|
||||
Stream = atom_to_list(?FUNCTION_NAME) ++ "-" ++ integer_to_list(rand:uniform(10000)),
|
||||
%% subscription just to create the stream from STOMP
|
||||
SubDestination = "/topic/stream-queue-test",
|
||||
rabbit_stomp_client:send(
|
||||
Client, "SUBSCRIBE",
|
||||
|
@ -329,6 +330,7 @@ stream_filtering(Config) ->
|
|||
{"receipt", "foo"},
|
||||
{"x-queue-name", Stream},
|
||||
{"x-queue-type", "stream"},
|
||||
{?HEADER_X_STREAM_FILTER_SIZE_BYTES, "32"},
|
||||
{"durable", "true"},
|
||||
{"auto-delete", "false"},
|
||||
{"id", "1234"},
|
||||
|
@ -341,7 +343,12 @@ stream_filtering(Config) ->
|
|||
{"receipt", "bar"}]),
|
||||
{ok, Client2, _, _} = stomp_receive(Client1, "RECEIPT"),
|
||||
|
||||
%% we are going to publish several waves of messages with and without filter values.
|
||||
%% we will then create subscriptions with various filter options
|
||||
%% and make sure we receive only what we asked for and not all the messages.
|
||||
|
||||
StreamDestination = "/amq/queue/" ++ Stream,
|
||||
%% logic to publish a wave of messages with or without a filter value
|
||||
WaveCount = 1000,
|
||||
Publish =
|
||||
fun(C, FilterValue) ->
|
||||
|
@ -360,11 +367,14 @@ stream_filtering(Config) ->
|
|||
C1
|
||||
end, C, lists:seq(1, WaveCount))
|
||||
end,
|
||||
%% publishing messages with the "apple" filter value
|
||||
Client3 = Publish(Client2, "apple"),
|
||||
%% publishing messages with no filter value
|
||||
Client4 = Publish(Client3, undefined),
|
||||
%% publishing messages with the "orange" filter value
|
||||
Client5 = Publish(Client4, "orange"),
|
||||
|
||||
%% one filter
|
||||
%% filtering on "apple"
|
||||
rabbit_stomp_client:send(
|
||||
Client5, "SUBSCRIBE",
|
||||
[{"destination", StreamDestination},
|
||||
|
@ -374,11 +384,14 @@ stream_filtering(Config) ->
|
|||
{"x-stream-filter", "apple"},
|
||||
{"x-stream-offset", "first"}]),
|
||||
{Client6, AppleMessages} = stomp_receive_messages(Client5, Version),
|
||||
%% we should get less than all the waves combined
|
||||
?assert(length(AppleMessages) < WaveCount * 3),
|
||||
%% client-side filtering
|
||||
AppleFilteredMessages =
|
||||
lists:filter(fun(H) ->
|
||||
proplists:get_value("x-stream-filter-value", H) =:= "apple"
|
||||
end, AppleMessages),
|
||||
%% we should have only the "apple" messages
|
||||
?assert(length(AppleFilteredMessages) =:= WaveCount),
|
||||
rabbit_stomp_client:send(
|
||||
Client6, "UNSUBSCRIBE", [{"destination", StreamDestination},
|
||||
|
@ -386,7 +399,7 @@ stream_filtering(Config) ->
|
|||
{"receipt", "bar"}]),
|
||||
{ok, Client7, _, _} = stomp_receive(Client6, "RECEIPT"),
|
||||
|
||||
%% two filters
|
||||
%% filtering on "apple" and "orange"
|
||||
rabbit_stomp_client:send(
|
||||
Client7, "SUBSCRIBE",
|
||||
[{"destination", StreamDestination},
|
||||
|
@ -396,12 +409,15 @@ stream_filtering(Config) ->
|
|||
{"x-stream-filter", "apple,orange"},
|
||||
{"x-stream-offset", "first"}]),
|
||||
{Client8, AppleOrangeMessages} = stomp_receive_messages(Client7, Version),
|
||||
%% we should get less than all the waves combined
|
||||
?assert(length(AppleOrangeMessages) < WaveCount * 3),
|
||||
%% client-side filtering
|
||||
AppleOrangeFilteredMessages =
|
||||
lists:filter(fun(H) ->
|
||||
proplists:get_value("x-stream-filter-value", H) =:= "apple" orelse
|
||||
proplists:get_value("x-stream-filter-value", H) =:= "orange"
|
||||
end, AppleOrangeMessages),
|
||||
%% we should have only the "apple" and "orange" messages
|
||||
?assert(length(AppleOrangeFilteredMessages) =:= WaveCount * 2),
|
||||
rabbit_stomp_client:send(
|
||||
Client8, "UNSUBSCRIBE", [{"destination", StreamDestination},
|
||||
|
@ -409,7 +425,7 @@ stream_filtering(Config) ->
|
|||
{"receipt", "bar"}]),
|
||||
{ok, Client9, _, _} = stomp_receive(Client8, "RECEIPT"),
|
||||
|
||||
%% one filter and unfiltered
|
||||
%% filtering on "apple" and messages without a filter value
|
||||
rabbit_stomp_client:send(
|
||||
Client9, "SUBSCRIBE",
|
||||
[{"destination", StreamDestination},
|
||||
|
@ -420,12 +436,15 @@ stream_filtering(Config) ->
|
|||
{"x-stream-match-unfiltered", "true"},
|
||||
{"x-stream-offset", "first"}]),
|
||||
{Client10, AppleUnfilteredMessages} = stomp_receive_messages(Client9, Version),
|
||||
%% we should get less than all the waves combined
|
||||
?assert(length(AppleUnfilteredMessages) < WaveCount * 3),
|
||||
%% client-side filtering
|
||||
AppleUnfilteredFilteredMessages =
|
||||
lists:filter(fun(H) ->
|
||||
proplists:get_value("x-stream-filter-value", H) =:= "apple" orelse
|
||||
proplists:get_value("x-stream-filter-value", H) =:= undefined
|
||||
end, AppleUnfilteredMessages),
|
||||
%% we should have only the "apple" messages and messages without a filter value
|
||||
?assert(length(AppleUnfilteredFilteredMessages) =:= WaveCount * 2),
|
||||
rabbit_stomp_client:send(
|
||||
Client10, "UNSUBSCRIBE", [{"destination", StreamDestination},
|
||||
|
|
Loading…
Reference in New Issue