Tuesday, September 15, 2009

Colon full of cookie

Launchpad does translations. You can register a project on Launchpad and use Launchpad to translate your software into a zillion other languages. We've even got funky tools to take the translations that people do on the web and commit them straight to your branch.

As an ignorant Anglophonic monoglot, I've never really looked into Launchpad Translations. Software is already written in my language, and I can't help translate it into my language. There has been no reason for me to look at it... until today.

Barry Warsaw, hacker extraordinaire, has started a project called I have a colon full of cookie. This project aims to translate the phrase "I have a colon full of cookie" into as many languages as possible. Note here that "colon" is the organ, not the punctuation mark.

OK, time to bust out my Latin lexicon.

Monday, September 14, 2009

Layers are terrible

When I talk about testing frameworks, I often mention Zope layers and say they are terrible. Some people have asked me for details on their terror and for justification of my opinion.

Here's all I've got. It's based on my experiences using layers with Zope 3.2 in Launchpad.

1. Layers have unnecessary magic

A layer can subclass another layer, which is fine. Subclassing means that your new, derived layer rests on top of the old, base layer.

When you define a derived layer though, you don't call the base layer's methods yourself, like you would for any other Python subclass. Why not? Because zope.testing magically up-calls the base layer's methods for you.

Yuck.

The upshot is that you write non-standard Python that confuses people not familiar with zope.testing. Also, you have no way of not calling the base methods, which is unfairly restrictive.

2. Layers are combined through inheritance

Each unit test is in a single layer. If you want a unit test to have the set up and tear down provided by layer A and the set up and tear down of layer B, you have to define a wholly new layer C that subclasses both A and B.

The layer C doesn't really mean anything other than "A and B". It doesn't really deserve a name, but it has to have one, since it has to be a new class.

Since layers are often used to share expensive resources between tests, you end up with a binary explosion of layer subclasses, as you move toward needing one for every subset of available resources.

This adds code and thus maintenance work, and is actually less clear than simply declaring that a test uses layers A and B.

3. Layers are implemented badly

Layers are all about changing the way a test is run. They supplement the run with extra work to establish a known base state for the test.

If you think about it, the stuff that's required to run a test is a property of the test.

Python's unittest module recognizes this. One of the few public methods of a TestCase object is its run() method. run() is also a method of TestSuite. This means that if you want to customize the way a test or a group of tests is run, you should override / re-implement the run() method.

Layers don't do this. Instead they change the way tests are gathered, the way they are reported and the way they are run. This means tests that rely on layers can only be run with the Zope test runner, and not with nose or trial or what have you.

4. Layers solve too many problems

Layers are not simply a way of sharing expensive resources between tests, they are also a way of using resources that cannot be torn down.

The implementation does this by detecting that a layer cannot be torn down, then spawning a new process to run the rest of the tests in.

It kind of sucks to have things that cannot be torn down in process, and it definitely sucks to conflate resource sharing with odd subprocess management.

5. Layers are not Zopish

As far as I can tell, one of the themes of Zope 3 is small, interchangeable pieces loosely joined together.

Layers seem to be something that could have been done much better using the Zope component architecture. Perhaps they could give getUtility some practical purpose in life.

What then?

As much as I hate to say so, I don't think there's much hope for layers as a concept. One is probably better served by replacing one's existing layers with testresources. It looks like it takes quite a lot of work to do so.

That's it. Five reasons and a lot of paragraphs. Please let me know if I've made mistakes, or if newer versions of zope.testing are better. Also, please gently correct me if I've left the path of civility and common courtesy.

Saturday, September 5, 2009

Launchpad on Karmic!

Thanks almost entirely to maxb & wgrant, I can now hack on Launchpad in Karmic.

This is great news for me, since it means I can ditch the chroot I was using. Check out the dev wiki for more details.

Friday, September 4, 2009

Active reviews, again

You might remember I was really excited about the first version of the active reviews page, since it let me see at a glance the code reviews I needed to do, the ones I was waiting on, and reviews I could do if I felt like it. At the time, this was really important, since it's the first time I've seen a code collaboration tool orient itself towards me actually doing things. It's certainly a first for Launchpad.

Tim has recently landed a few changes to the page that aren't quite as revolutionary, but follow the same lines of thinking.

The one I want to mention is putting all the branches that are approved for landing onto the active reviews page. Every branch that's approved to land and hasn't yet landed is actually waste, it's an improvement that's sitting around gathering dust and waiting for someone to push a button. It's like a winning lottery ticket stuck to your fridge because you're too lazy to cash it in. We think it's so important that we've put these at the top of the list.

You can take a look at the active reviews pages for:
Now if you'll excuse me, I have branches to land.

Tuesday, September 1, 2009

Slow tests

Robert Collins of Bazaar, recently blogged about the cost of slow tests. I couldn't agree more.

Launchpad has a very slow test suite. It takes upwards of five hours to get a change into our "known good" branch. It's been a source of pain for the team for years, and now that Launchpad is Free Software, it's becoming a pain to new contributors.

We've tried a few things to deal with it, none of them great. First up, we've got a tool for running the test suite on EC2 instances. It's nice, but it's still too slow. I've written a "faster tests" spec outlining some of the options we have; but specs never got software written. Likewise, there are a bunch of bugs flagged as build-infrastructure, many of which address the slow test sped. We also have a rotating "Build Engineer" position within the team to address those bugs.

It's probably not enough though. From watching Rob's blog posts, and the emails to the Bazaar mailing list, I think that what Launchpad really needs is someone with a passion for solving the problem (i.e. making Launchpad hacking fun) who is willing to lead the way, and a full commitment from the rest of the team for getting the runtime down and keeping it there.

More on this later.