使用erlang通用测试进行分布式测试

时间:2015-03-20 02:15:21

标签: erlang distributed common-test

现在我正在使用Erlang,我认为我应该使用通用测试框架进行一些分布式测试。我读了一些关于此的文章。但我无法使用ct_master在多个节点上运行我自己的应用程序。困扰我很多天 - 奴隶节点不能包含我自己的应用程序。你能告诉我一些关于这个的事吗?

dir tree:

$ tree
.
├── logs
├── src
│   ├── aaa.app.src
│   ├── aaa_app.erl
│   └── aaa_sup.erl
└── test
    ├── aaa_SUITE.erl
    ├── dist.spec
    └── spec

测试套件是:

-module(aaa_SUITE).
-include_lib("common_test/include/ct.hrl").

-compile(export_all).
suite() -> [{timetrap, {seconds, 20}}].
groups() -> [].
all() ->
    [ {exports, Functions} | _ ] = ?MODULE:module_info(),
    [ FName || {FName, _} <- lists:filter(
                               fun ({module_info,_}) -> false;
                                   ({all,_}) -> false;
                                   ({init_per_suite,1}) -> false;
                                   ({end_per_suite,1}) -> false;
                                   ({_,1}) -> true;
                                   ({_,_}) -> false
                               end, Functions)].
init_per_suite(Config) ->
    Config.
end_per_suite(_Config) ->
    ok.
init_per_group(_group, Config) ->
    Config.
end_per_group(_group, Config) ->
    Config.
init_per_testcase(TestCase, Config) ->
    Config.
end_per_testcase(TestCase, Config) ->
    Config.

test_aaa(_Config) ->
    ok = application:start(aaa).

spec文件是:

{node, a_1, 'a1@localhost'}.

{include, [a_1], ["../ebin"]}.
{init, [a_1], [{node_start, [{monitor_master, true}]}, {erl_flags, "-pa ../ebin"}]}.

{logdir, all_nodes, "../logs/"}.
{logdir, master, "../logs/"}.

{alias, aaa, "./"}.
{suites, [a_1], aaa, all}.

我只是运行erl -name ct@localhost,然后在erlang shell中运行ct_master:run("test/dist.spec")

常见测试始终以消息{badmatch,{error,{"no such file or directory","aaa.app"}}}退出。

1 个答案:

答案 0 :(得分:0)

我肯定会认为这是一个黑客,但这样的事情可能会有所帮助:

%% Run the app locally
{ok, _MasterApps} = application:ensure_all_started(my_app),
%% Adding our local code paths to the remote node to ensure
%% proper path resolution
ok = rpc:call(Slave, code, add_pathsz, [code:get_path()]),
%% Start the application remotely
{ok, _SlaveApps} = rpc:call(Slave, application, ensure_all_started, [my_app]).
相关问题