1 %% The contents of this file are subject to the Mozilla Public License
2 %% Version 1.1 (the "License"); you may not use this file except in
3 %% compliance with the License. You may obtain a copy of the License
4 %% at http://www.mozilla.org/MPL/
6 %% Software distributed under the License is distributed on an "AS IS"
7 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8 %% the License for the specific language governing rights and
9 %% limitations under the License.
11 %% The Original Code is RabbitMQ Federation.
13 %% The Initial Developer of the Original Code is VMware, Inc.
14 %% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
17 -module(rabbit_exchange_type_recent_history_test_util).
19 -include_lib("eunit/include/eunit.hrl").
20 -include_lib("amqp_client/include/amqp_client.hrl").
24 start_other_node({Name, Port}) ->
25 start_other_node({Name, Port}, "rabbit-" ++ Name).
27 start_other_node({Name, Port}, Config) ->
28 start_other_node({Name, Port}, Config,
29 os:getenv("RABBITMQ_ENABLED_PLUGINS_FILE")).
31 start_other_node({Name, Port}, Config, PluginsFile) ->
32 make(" OTHER_NODE=" ++ Name ++
33 " OTHER_PORT=" ++ integer_to_list(Port) ++
34 " OTHER_CONFIG=" ++ Config ++
35 " OTHER_PLUGINS=" ++ PluginsFile ++
39 stop_other_node({Name, _Port}) ->
40 make(" OTHER_NODE=" ++ Name ++
44 reset_other_node({Name, _Port}) ->
45 make(" OTHER_NODE=" ++ Name ++
49 cluster_other_node({Name, _Port}, {MainName, _Port2}) ->
50 make(" OTHER_NODE=" ++ Name ++
51 " MAIN_NODE=" ++ atom_to_list(n(MainName)) ++
52 " cluster-other-node"),
56 execute(os:getenv("RABBITMQCTL") ++ " " ++ Args),
60 Make = case os:getenv("MAKE") of
64 execute(Make ++ " " ++ Args).
67 Res = os:cmd(Cmd ++ " ; echo $?"),
68 case lists:reverse(string:tokens(Res, "\n")) of
70 _ -> exit({command_failed, Cmd, Res})
74 {ok, [[File]]} = init:get_argument(config),
75 filename:dirname(filename:dirname(File)).
78 {_, NodeHost} = rabbit_nodes:parts(node()),
79 rabbit_nodes:make({Nodename, NodeHost}).