[erlang-questions] Struggling with ct_master and ssh
Fred Hebert
mononcqc@REDACTED
Fri Jul 19 14:31:12 CEST 2013
Answers inline.
On 07/18, Sylvain Benner wrote:
> I'm currently learning Common Test via the great LYSE book and I am not
> able to make the distributed tests work.
>
Glad you like it! Let's see for the CT stuff.
> %%
> ------------------------------------------------------------------------------
> {node, a, 'a@REDACTED'}.
> {node, b, 'b@REDACTED'}.
< [...]
> ------------------------------------------------------------------------------
>
> 1) If I create manually the nodes a and b, the spec runs flawlessly.
> 2) If I don't than I've got boot_timeout errors:
>
> %%
> ------------------------------------------------------------------------------
> (ct@REDACTED)13> ct_master:run("dist.spec").
> === Master Logdir ===
First problem is right here! You started a node with a short name
(-sname) but the spec mentions nodes with long names (-name, using a '.'
in their name elevates them to FQDN). Start the master node with
erl -name ct@REDACTED ...
And it should probably fix it. It's not possible for a short name node
to discuss with a long-name node.
>
> I dug into ct_slave.erl and replicated the ssh commands of
> spawn_remote_node/3 in a shell:
>
> %%
> ------------------------------------------------------------------------------
> (testssh@REDACTED)5> {ok, SSHConnRef} =
> ssh:connect("localhost.local", 22, []).
> ssh password:
> ...
> (testssh@REDACTED)9> net_adm:ping('node_from_ssh@REDACTED').
> pong
> %%
> ------------------------------------------------------------------------------
>
> It works.
>
And I would expect so given your node name tells me this one is actually
using a long name to connect! That sounds like a confirmation for the
soliution.
> So here are the questions:
>
> 1) Do you have any idea about the ssh_connection:setenv failure ?
No specific idea, but I'm guessing it's the name of the nodes that is
your first issue. Once that's cleared, you can check and try over again.
> 2) Do I need ct_master to test a protocol ? What is the erlang way for
> testing protocols between 2 nodes ?
To test between two nodes it can make sense to have two nodes. I like to
try and find ways to avoid that, although it's not necessarily easy. For
most TCP-based protocols, I try to just have the test code have a
'trusted' side and spawn a server, my test behaving as the client, or
the other way around. It helps to test some behaivour, but not all of
it.
If you've got more time and want to make sure the protocol stands on its
own, I would look into Quickcheck or PropEr as a way to model everything
and do fancier testing. It's considerably trickier to get things right
in there if you haven't done it before, though.
Regards,
Fred.
More information about the erlang-questions
mailing list