summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Fedotov <fedotov.danil@gmail.com>2017-06-12 16:35:46 +0100
committerDaniil Fedotov <fedotov.danil@gmail.com>2017-06-12 16:35:46 +0100
commit681ee865ec5f8ee57e1bbc2a8b1d5bcaa6f55288 (patch)
tree385de3a46e0bf27184da5471e4dfa36e15b4b917
parent245e3c73031f2a7c27d32daa802dd03ec5b8aec2 (diff)
parenta23338ad6fa3d0b7b2e9613ba0e84fff12078d82 (diff)
downloadrabbitmq-server-git-681ee865ec5f8ee57e1bbc2a8b1d5bcaa6f55288.tar.gz
Merge branch 'stable'
-rw-r--r--src/rabbit_queue_index.erl2
-rw-r--r--src/term_to_binary_compat.erl32
-rw-r--r--test/backing_queue_SUITE.erl2
-rw-r--r--test/cluster_SUITE.erl2
-rw-r--r--test/term_to_binary_compat_prop_SUITE.erl62
-rw-r--r--test/unit_inbroker_parallel_SUITE.erl2
6 files changed, 98 insertions, 4 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index a71eaf1ff4..123bfaba25 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -691,7 +691,7 @@ recover_message(false, _, no_del, RelSeq, {Segment, DirtyCount}) ->
DirtyCount + 2}.
queue_name_to_dir_name(Name = #resource { kind = queue }) ->
- <<Num:128>> = erlang:md5(term_to_binary(Name)),
+ <<Num:128>> = erlang:md5(term_to_binary_compat:queue_name_to_binary(Name)),
rabbit_misc:format("~.36B", [Num]).
queues_base_dir() ->
diff --git a/src/term_to_binary_compat.erl b/src/term_to_binary_compat.erl
new file mode 100644
index 0000000000..a3e1045623
--- /dev/null
+++ b/src/term_to_binary_compat.erl
@@ -0,0 +1,32 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is GoPivotal, Inc.
+%% Copyright (c) 2017 Pivotal Software, Inc. All rights reserved.
+%%
+
+-module(term_to_binary_compat).
+
+-include("rabbit.hrl").
+
+-export([queue_name_to_binary/1]).
+
+queue_name_to_binary(#resource{kind = queue} = {resource, VHost, queue, Name}) ->
+ VHostBSize = byte_size(VHost),
+ NameBSize = byte_size(Name),
+ <<131, %% Binary format "version"
+ 104, 4, %% 4-element tuple
+ 100, 0, 8, "resource", %% `resource` atom
+ 109, VHostBSize:32, VHost/binary, %% Vhost binary
+ 100, 0, 5, "queue", %% `queue` atom
+ 109, NameBSize:32, Name/binary>>. %% Name binary
+
diff --git a/test/backing_queue_SUITE.erl b/test/backing_queue_SUITE.erl
index 3ff215f497..60f86e0542 100644
--- a/test/backing_queue_SUITE.erl
+++ b/test/backing_queue_SUITE.erl
@@ -1256,7 +1256,7 @@ make_publish_delivered(IsPersistent, PayloadFun, PropFun, N) ->
PropFun(N, #message_properties{size = 10})}.
queue_name(Config, Name) ->
- Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name),
+ Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)),
queue_name(Name1).
queue_name(Name) ->
diff --git a/test/cluster_SUITE.erl b/test/cluster_SUITE.erl
index bc442ecba7..3dba65ae1f 100644
--- a/test/cluster_SUITE.erl
+++ b/test/cluster_SUITE.erl
@@ -355,7 +355,7 @@ test_spawn_remote() ->
end.
queue_name(Config, Name) ->
- Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name),
+ Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)),
queue_name(Name1).
queue_name(Name) ->
diff --git a/test/term_to_binary_compat_prop_SUITE.erl b/test/term_to_binary_compat_prop_SUITE.erl
new file mode 100644
index 0000000000..d09b23c9ea
--- /dev/null
+++ b/test/term_to_binary_compat_prop_SUITE.erl
@@ -0,0 +1,62 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is GoPivotal, Inc.
+%% Copyright (c) 2017 Pivotal Software, Inc. All rights reserved.
+%%
+
+
+-module(term_to_binary_compat_prop_SUITE).
+
+-compile(export_all).
+
+-include("rabbit.hrl").
+-include_lib("common_test/include/ct.hrl").
+-include_lib("proper/include/proper.hrl").
+
+all() ->
+ %% The test should run on OTP < 20 (erts < 9)
+ case erts_gt_8() of
+ true ->
+ [];
+ false ->
+ [queue_name_to_binary]
+ end.
+
+erts_gt_8() ->
+ Vsn = erlang:system_info(version),
+ [Maj|_] = string:tokens(Vsn, "."),
+ list_to_integer(Maj) > 8.
+
+init_per_suite(Config) ->
+ rabbit_ct_helpers:log_environment(),
+ rabbit_ct_helpers:run_setup_steps(Config).
+
+end_per_suite(Config) ->
+ rabbit_ct_helpers:run_teardown_steps(Config).
+
+init_per_testcase(Testcase, Config) ->
+ rabbit_ct_helpers:testcase_started(Config, Testcase).
+
+queue_name_to_binary(Config) ->
+ Fun = fun () -> prop_queue_name_to_binary(Config) end,
+ rabbit_ct_proper_helpers:run_proper(Fun, [], 10000).
+
+
+prop_queue_name_to_binary(_Config) ->
+ ?FORALL({Vhost, QName}, {binary(), binary()},
+ begin
+ Resource = rabbit_misc:r(Vhost, queue, QName),
+ Legacy = term_to_binary_compat:queue_name_to_binary(Resource),
+ Current = term_to_binary(Resource),
+ Current =:= Legacy
+ end). \ No newline at end of file
diff --git a/test/unit_inbroker_parallel_SUITE.erl b/test/unit_inbroker_parallel_SUITE.erl
index f9cfd58eaa..9c274ab525 100644
--- a/test/unit_inbroker_parallel_SUITE.erl
+++ b/test/unit_inbroker_parallel_SUITE.erl
@@ -146,7 +146,7 @@ on_disk_stop(Pid) ->
end.
queue_name(Config, Name) ->
- Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name),
+ Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)),
queue_name(Name1).
queue_name(Name) ->