]> review.fuel-infra Code Review - packages/trusty/rabbitmq-server.git/blob
37a28dad5c1f4e90ca074b49e067029c4ac53c41
[packages/trusty/rabbitmq-server.git] /
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/
5 %%
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.
10 %%
11 %% The Original Code is RabbitMQ Federation.
12 %%
13 %% The Initial Developer of the Original Code is VMware, Inc.
14 %% Copyright (c) 2007-2013 VMware, Inc.  All rights reserved.
15 %%
16
17 -module(rabbit_exchange_type_recent_history_test_util).
18
19 -include_lib("eunit/include/eunit.hrl").
20 -include_lib("amqp_client/include/amqp_client.hrl").
21
22 -compile(export_all).
23
24 start_other_node({Name, Port}) ->
25     start_other_node({Name, Port}, "rabbit-" ++ Name).
26
27 start_other_node({Name, Port}, Config) ->
28     start_other_node({Name, Port}, Config,
29                      os:getenv("RABBITMQ_ENABLED_PLUGINS_FILE")).
30
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 ++
36          " start-other-node"),
37     timer:sleep(1000).
38
39 stop_other_node({Name, _Port}) ->
40     make(" OTHER_NODE=" ++ Name ++
41          " stop-other-node"),
42     timer:sleep(1000).
43
44 reset_other_node({Name, _Port}) ->
45     make(" OTHER_NODE=" ++ Name ++
46          " reset-other-node"),
47     timer:sleep(1000).
48
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"),
53     timer:sleep(1000).
54
55 rabbitmqctl(Args) ->
56     execute(os:getenv("RABBITMQCTL") ++ " " ++ Args),
57     timer:sleep(100).
58
59 make(Args) ->
60     Make = case os:getenv("MAKE") of
61         false -> "make";
62         M     -> M
63     end,
64     execute(Make ++ " " ++ Args).
65
66 execute(Cmd) ->
67     Res = os:cmd(Cmd ++ " ; echo $?"),
68     case lists:reverse(string:tokens(Res, "\n")) of
69         ["0" | _] -> ok;
70         _         -> exit({command_failed, Cmd, Res})
71     end.
72
73 plugin_dir() ->
74     {ok, [[File]]} = init:get_argument(config),
75     filename:dirname(filename:dirname(File)).
76
77 n(Nodename) ->
78     {_, NodeHost} = rabbit_nodes:parts(node()),
79     rabbit_nodes:make({Nodename, NodeHost}).