fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Testing fabfiles


From: Ahsan Rabbani
Subject: Re: [Fab-user] Testing fabfiles
Date: Sat, 22 Oct 2011 01:00:26 -0400

Another reason to look forward to 1.3!

On Fri, Oct 21, 2011 at 2:18 PM, Jeff Forcier <address@hidden> wrote:
> On Fri, Oct 21, 2011 at 11:17 AM, Ahsan Rabbani <address@hidden> wrote:
>
> So for example, if I call a
> task that is decorated with @hosts (and has multiple hosts defined) it would
> be nice if it got invoked once for each host defined.

After 1.3 is released (any day now) you'll be able to use the
execute() function for this purpose, so replacing your task object
with a Mock, decorating it with @hosts, and throwing it into
execute(), should behave the way you need it to.


> Afterwards, ironfroggy said:
>
> I admit, I don't test them. Not with unit tests, and I'm guessing most
> people don't. The fabfile.py seems outside of "real code" and escapes
> the expectation of testing, sadly. I think this should be corrected.
> One thing I"m trying to do more is create temporary test servers with
> vagrant to do local operations on and test this stuff out better.

Fabric actually ships with a somewhat crude fake SSH server leveraging
Paramiko's server-side code, and we use it widely in our own test
suite. There are vague plans to try and clean this up and release it
as its own library, but for now, you may still find it useful to check
out.

At the moment it can only do simple input/response, e.g.
@server({'this command should': ('return this stdout', 'this stderr,
and return code', 3)}) -- there's no state or any attempt at
implementing "real" unix commands. But this would probably get many
folks 80% of the way there re: testing fabfiles.

For complex fabfiles, using something like Vagrant is always a good
option, if slightly more time-consuming (i.e. it's not a great fit for
CI or rapid test iteration.)

Best,
Jeff

--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]