rebar3 and CT's main node

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

rebar3 and CT's main node

Roberto Ostinelli
All,
When I manually run CT with:

ct_run -dir test -pa ebin

and print out the node the tests are running on with a simple:

ct:pal("node = ~p", [node()]).

I get something similar to:

'ct@robertos-mac'


However, when I run CT with rebar3 by issuing:

rebar3 ct

Then the same command prints:

'nonode@nohost'

This is ok for most tests, but since I'm testing distributed nodes with ct_slave [1] this impedes a slave to be started, as the main node is a 'nonode@nohost' and hence the slave node cannot connect to this 'nonode'.

If anyone wants to try this just run Syn's suite, it will fail when using rebar3 here:

With a {{badmatch,{error,not_alive,nonode@nohost}}.

Any ideas?

Thank you,
r.



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Fred Hebert-2

If the default mode isn't enough, the easiest solution is always:

    ct_run -dir test -pa `rebar3 path`

Which makes your whole app available to the tests. You can bypass rebar3 for the run, but still use it for the rest.

You may want to try:

    rebar3 shell --sname=mynode
     ...
    r3:do(ct).

To run tests from the interactive shell with a named node, but I have never tried that and don't know how it would go.

On Mar 19, 2016 5:07 AM, "Roberto Ostinelli" <[hidden email]> wrote:
All,
When I manually run CT with:

ct_run -dir test -pa ebin

and print out the node the tests are running on with a simple:

ct:pal("node = ~p", [node()]).

I get something similar to:

'ct@robertos-mac'


However, when I run CT with rebar3 by issuing:

rebar3 ct

Then the same command prints:

'nonode@nohost'

This is ok for most tests, but since I'm testing distributed nodes with ct_slave [1] this impedes a slave to be started, as the main node is a 'nonode@nohost' and hence the slave node cannot connect to this 'nonode'.

If anyone wants to try this just run Syn's suite, it will fail when using rebar3 here:

With a {{badmatch,{error,not_alive,nonode@nohost}}.

Any ideas?

Thank you,
r.



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Tristan Sloughter-4
Additionally if you use `rebar3 local install` you are able to set the os var $REBAR3_ERL_ARGS which you can set to `-sname mynode`.
 
--
Tristan Sloughter
 
 
 
On Sat, Mar 19, 2016, at 07:14 AM, Fred Hebert wrote:

If the default mode isn't enough, the easiest solution is always:

    ct_run -dir test -pa `rebar3 path`

Which makes your whole app available to the tests. You can bypass rebar3 for the run, but still use it for the rest.

You may want to try:

    rebar3 shell --sname=mynode
     ...
    r3:do(ct).

To run tests from the interactive shell with a named node, but I have never tried that and don't know how it would go.

On Mar 19, 2016 5:07 AM, "Roberto Ostinelli" <[hidden email]> wrote:
All,
When I manually run CT with:
 
ct_run -dir test -pa ebin
 
and print out the node the tests are running on with a simple:
 
ct:pal("node = ~p", [node()]).
 
I get something similar to:
 
'ct@robertos-mac'
 
 
However, when I run CT with rebar3 by issuing:
 
rebar3 ct
 
Then the same command prints:
 
'nonode@nohost'
 
This is ok for most tests, but since I'm testing distributed nodes with ct_slave [1] this impedes a slave to be started, as the main node is a 'nonode@nohost' and hence the slave node cannot connect to this 'nonode'.
 
If anyone wants to try this just run Syn's suite, it will fail when using rebar3 here:
 
With a {{badmatch,{error,not_alive,nonode@nohost}}.
 
Any ideas?
 
Thank you,
r.
 
 
 
_______________________________________________
erlang-questions mailing list
 
_______________________________________________
erlang-questions mailing list
 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Roberto Ostinelli
In reply to this post by Fred Hebert-2
Thank you for the help.

On Sat, Mar 19, 2016 at 1:14 PM, Fred Hebert <[hidden email]> wrote:

If the default mode isn't enough, the easiest solution is always:

    ct_run -dir test -pa `rebar3 path`

Which makes your whole app available to the tests. You can bypass rebar3 for the run, but still use it for the rest.


This fixes the node naming issue, but unfortunately this not enough to make it work.

Long story short: in my tests I define some callback functions that need to be called for the tests to pass.
However, I need to specify the path to the test directory too, because otherwise my slave node doesn't have these functions defined.

This is how I do the trick now:

SO: is there a way to have rebar copy the test directory to:
syn/_build/default/lib/syn/test

?

You may want to try:

    rebar3 shell --sname=mynode
     ...
    r3:do(ct).

To run tests from the interactive shell with a named node, but I have never tried that and don't know how it would go.

This actually works, though I see an "experimental" warning on top and I cannot really automate it in a script, as there's no `--eval` option in `rebar shell`.

So I've tried adding a test.escript file:

%%%%%%%%%%%%%%%%%%%
#!/usr/bin/env escript

main(_) ->
    r3:do(ct),
    init:stop().
%%%%%%%%%%%%%%%%%%%


But:


$ rebar3 shell --sname=mynode --script test.escript
===> Verifying dependencies...
===> Compiling syn
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Eshell V7.3  (abort with ^G)
(mynode@robertos-neato)1> ===> Couldn't run shell escript "/Users/roberto/workspace/syn/test.escript" - exit:{noproc,
                                                                                               {gen_server,
                                                                                                call,
                                                                                                [rebar_agent,
                                                                                                 {cmd,
                                                                                                  ct},
                                                                                                 infinity]}}
Stack: [{gen_server,call,3,[{file,"gen_server.erl"},{line,212}]},
        {test_escript__escript__1458__464329__444078__2,main,1,
            [{file,"/Users/roberto/workspace/syn/test.escript"},{line,5}]},



And I'm stuck.

Any ideas?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Roberto Ostinelli


On Sun, Mar 20, 2016 at 10:07 AM, Roberto Ostinelli <[hidden email]> wrote:

Long story short: in my tests I define some callback functions that need to be called for the tests to pass.
However, I need to specify the path to the test directory too, because otherwise my slave node doesn't have these functions defined.

This is how I do the trick now:

SO: is there a way to have rebar copy the test directory to:
syn/_build/default/lib/syn/test

?

Found an alternative to this, leaving it here for anyone interested. I start the slave node with:

start_slave(NodeShortName) ->
    CodePath = code:get_path(),
    {ok, Node} = ct_slave:start(NodeShortName, [{boot_timeout, 10}]),
    true = rpc:call(Node, code, set_path, [CodePath]),
    {ok, Node}.

Hence I do not need to "rebuild" the directories.

Fred, Tristan, thank you for your help I can consider this matter closed.

Best,
r.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Roberto Ostinelli
One question I need to ask though: why does `rebar ct` not set the node? This is actually set by CT itself, so why does it get removed?

Thanks,
r.

On Sun, Mar 20, 2016 at 10:22 AM, Roberto Ostinelli <[hidden email]> wrote:


On Sun, Mar 20, 2016 at 10:07 AM, Roberto Ostinelli <[hidden email]> wrote:

Long story short: in my tests I define some callback functions that need to be called for the tests to pass.
However, I need to specify the path to the test directory too, because otherwise my slave node doesn't have these functions defined.

This is how I do the trick now:

SO: is there a way to have rebar copy the test directory to:
syn/_build/default/lib/syn/test

?

Found an alternative to this, leaving it here for anyone interested. I start the slave node with:

start_slave(NodeShortName) ->
    CodePath = code:get_path(),
    {ok, Node} = ct_slave:start(NodeShortName, [{boot_timeout, 10}]),
    true = rpc:call(Node, code, set_path, [CodePath]),
    {ok, Node}.

Hence I do not need to "rebuild" the directories.

Fred, Tristan, thank you for your help I can consider this matter closed.

Best,
r.



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Fred Hebert-2
On 03/20, Roberto Ostinelli wrote:
>One question I need to ask though: why does `rebar ct` not set the node?
>This is actually set by CT itself, so why does it get removed?
>

I don't think we ever had a conscious decision to do it. When `rebar3
ct` was implemented, we switched away from rebar 2.x's shelling out to
'ct_run', since that had the nasty habit of leaving behind a named node
you couldn't interrupt and had to call 'kill -9' on to be able to run
further tests.

When switching to the direct erlang API for 'ct', the node naming
feature was probably just lost by accident. Incidentally it now lets
people run more than one test run at a time on a given system, which may
not be all that bad.

One tricky aspect of distributed Erlang with escripts is that it still
relies on epmd, but if epmd is not running yet, the escript/net_kernel
will not boot the process for you; we'd have to shell out to it manually
and hope it doesn't get taken down when the escript is done running (if
any other system started relying on it at the tiem). I never felt super
comfortable with that, and so far 'rebar3 shell' just displays a warning
asking you to boot epmd and ignores distributed mode when that happens.

That's probably the road I'd go for with `rebar3 ct` too: make in an
explicit option, but don't lock up a node name (and possibly boot epmd)
by default if the user hasn't asked for it? Currently it's just plain
unsupported though.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and CT's main node

Roberto Ostinelli
Thank you Fred for clarifying.

I guess that for tests that require distributed node, devs can just use the shell (assuming they are using a test profile):

ct_run -dir test -pa `rebar3 as test path`

Best,
r.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions