Skip to content

Commit c26201c

Browse files
committed
Add comments to test
1 parent 71c2ad1 commit c26201c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

deps/rabbitmq_stomp/test/system_SUITE.erl

+22-3
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,15 @@ stream_filtering(Config) ->
322322
Version = ?config(version, Config),
323323
Client = ?config(stomp_client, Config),
324324
Stream = atom_to_list(?FUNCTION_NAME) ++ "-" ++ integer_to_list(rand:uniform(10000)),
325+
%% subscription just to create the stream from STOMP
325326
SubDestination = "/topic/stream-queue-test",
326327
rabbit_stomp_client:send(
327328
Client, "SUBSCRIBE",
328329
[{"destination", SubDestination},
329330
{"receipt", "foo"},
330331
{"x-queue-name", Stream},
331332
{"x-queue-type", "stream"},
333+
{?HEADER_X_STREAM_FILTER_SIZE_BYTES, "32"},
332334
{"durable", "true"},
333335
{"auto-delete", "false"},
334336
{"id", "1234"},
@@ -341,7 +343,12 @@ stream_filtering(Config) ->
341343
{"receipt", "bar"}]),
342344
{ok, Client2, _, _} = stomp_receive(Client1, "RECEIPT"),
343345

346+
%% we are going to publish several waves of messages with and without filter values.
347+
%% we will then create subscriptions with various filter options
348+
%% and make sure we receive only what we asked for and not all the messages.
349+
344350
StreamDestination = "/amq/queue/" ++ Stream,
351+
%% logic to publish a wave of messages with or without a filter value
345352
WaveCount = 1000,
346353
Publish =
347354
fun(C, FilterValue) ->
@@ -360,11 +367,14 @@ stream_filtering(Config) ->
360367
C1
361368
end, C, lists:seq(1, WaveCount))
362369
end,
370+
%% publishing messages with the "apple" filter value
363371
Client3 = Publish(Client2, "apple"),
372+
%% publishing messages with no filter value
364373
Client4 = Publish(Client3, undefined),
374+
%% publishing messages with the "orange" filter value
365375
Client5 = Publish(Client4, "orange"),
366376

367-
%% one filter
377+
%% filtering on "apple"
368378
rabbit_stomp_client:send(
369379
Client5, "SUBSCRIBE",
370380
[{"destination", StreamDestination},
@@ -374,19 +384,22 @@ stream_filtering(Config) ->
374384
{"x-stream-filter", "apple"},
375385
{"x-stream-offset", "first"}]),
376386
{Client6, AppleMessages} = stomp_receive_messages(Client5, Version),
387+
%% we should get less than all the waves combined
377388
?assert(length(AppleMessages) < WaveCount * 3),
389+
%% client-side filtering
378390
AppleFilteredMessages =
379391
lists:filter(fun(H) ->
380392
proplists:get_value("x-stream-filter-value", H) =:= "apple"
381393
end, AppleMessages),
394+
%% we should have only the "apple" messages
382395
?assert(length(AppleFilteredMessages) =:= WaveCount),
383396
rabbit_stomp_client:send(
384397
Client6, "UNSUBSCRIBE", [{"destination", StreamDestination},
385398
{"id", "0"},
386399
{"receipt", "bar"}]),
387400
{ok, Client7, _, _} = stomp_receive(Client6, "RECEIPT"),
388401

389-
%% two filters
402+
%% filtering on "apple" and "orange"
390403
rabbit_stomp_client:send(
391404
Client7, "SUBSCRIBE",
392405
[{"destination", StreamDestination},
@@ -396,20 +409,23 @@ stream_filtering(Config) ->
396409
{"x-stream-filter", "apple,orange"},
397410
{"x-stream-offset", "first"}]),
398411
{Client8, AppleOrangeMessages} = stomp_receive_messages(Client7, Version),
412+
%% we should get less than all the waves combined
399413
?assert(length(AppleOrangeMessages) < WaveCount * 3),
414+
%% client-side filtering
400415
AppleOrangeFilteredMessages =
401416
lists:filter(fun(H) ->
402417
proplists:get_value("x-stream-filter-value", H) =:= "apple" orelse
403418
proplists:get_value("x-stream-filter-value", H) =:= "orange"
404419
end, AppleOrangeMessages),
420+
%% we should have only the "apple" and "orange" messages
405421
?assert(length(AppleOrangeFilteredMessages) =:= WaveCount * 2),
406422
rabbit_stomp_client:send(
407423
Client8, "UNSUBSCRIBE", [{"destination", StreamDestination},
408424
{"id", "0"},
409425
{"receipt", "bar"}]),
410426
{ok, Client9, _, _} = stomp_receive(Client8, "RECEIPT"),
411427

412-
%% one filter and unfiltered
428+
%% filtering on "apple" and messages without a filter value
413429
rabbit_stomp_client:send(
414430
Client9, "SUBSCRIBE",
415431
[{"destination", StreamDestination},
@@ -420,12 +436,15 @@ stream_filtering(Config) ->
420436
{"x-stream-match-unfiltered", "true"},
421437
{"x-stream-offset", "first"}]),
422438
{Client10, AppleUnfilteredMessages} = stomp_receive_messages(Client9, Version),
439+
%% we should get less than all the waves combined
423440
?assert(length(AppleUnfilteredMessages) < WaveCount * 3),
441+
%% client-side filtering
424442
AppleUnfilteredFilteredMessages =
425443
lists:filter(fun(H) ->
426444
proplists:get_value("x-stream-filter-value", H) =:= "apple" orelse
427445
proplists:get_value("x-stream-filter-value", H) =:= undefined
428446
end, AppleUnfilteredMessages),
447+
%% we should have only the "apple" messages and messages without a filter value
429448
?assert(length(AppleUnfilteredFilteredMessages) =:= WaveCount * 2),
430449
rabbit_stomp_client:send(
431450
Client10, "UNSUBSCRIBE", [{"destination", StreamDestination},

0 commit comments

Comments
 (0)