How should I write a test suite which depends on an external server?

I'm in the process of writing a test suite for ElasticSearch.pm, but in order for it to run any tests, it requires access to an ElasticSearch cluster.

Currently, I just skip all tests unless $ENV{ES_SERVER} is set, but this requires manual installation / testing.

Alternatively, I could (if $ENV{ES_SERVER} isn't set) try to download and compile a test version, which requires git and java v 1.6 or higher. It doesn't take long to compile, but long enough so that user may not want to do it by default.

So I could ask them if they want the script to build a test server, but again, this requires manual installation.

It'd be nice to use the cpan testers to run the test suite on multiple platforms, which implies building a test cluster by default.

What would you do?

cpXXXan

Some of you will be aware of one of my projects that is driven off CPAN-testers data: the cpXXXan. Well, I'm in the process of extending it. Soon it will grow a cpNETBSDan tentacle, and likewise for some other OSes. Once I'm convinced that it works and is reasonably efficient, I'll probably make it so that you can filter by both OS and perl version, using hostnames such as irix.cp5.8.9an.barnyard.co.uk.

Dancer web framework 1.150 released

Version 1.150 of the Dancer web framework has just been released to CPAN.

Dancer is a simple and lightweight yet powerful web application framework which I recently discovered (and blogged about) when I was looking for a framework I'd actually enjoy using to write web apps.

A (very basic) Dancer web app can be as simple as:

#!/usr/bin/perl
use Dancer;

get '/hello/:name' => sub {
    return "Why, hello there " . params->{name};
};

dance;

Text::BibTeX 0.40 Released

I adopted Text::BibTeX a long time ago and had a lot of complaints about its installation mechanism. This was mainly due to the fact that Text::BibTeX depended on a C library that needed to be installed prior to the perl module. The C library installation was easy on generic Unix platforms but was a pain to compile under Windows.

After lot of work I managed to include the library C code in the Perl module (now Text::BibTeX has no dependencies on the library), and managed to include code to compile the library in Windows, using the Strawberry Perl distribution (that includes a mingw C compiler).

The package is needing heavy tests, but it seems usable for most users. Probably I will post on the details about its build system in a later post, as it involves Config::AutoConf methodology to detect a suitable method to compile a standalone C library.

Portuguese Perl Workshop 2010

The Portuguese Perl Workshop is back. This year's event will be held in the 4th and 5th of June in Porto. Check the official site for details.

Number::Phone::UK update

Number::Phone::UK no longer assumes that geographic numbers terminate on fixed lines - as VOIP services grow and grow, this assumption no longer makes sense. So as of version 1.7004 of Number-Phone, is_fixed_line() will return undef for geographic numbers and 0 for mobiles, the latter being the only type of number that we know doesn't terminate on a fixed line.

There are no significant code changes though, this is really just a database update, hence the tiny increase in the version number. Not, of course, that the size of the version increment tells you anything anyway.

Madrid.pm Social Meeting

Tomorrow Feb 18, at "El Rincon Guay"

Come an enjoy some beer and "pinchos" with us while we plan how to solve all the world problems using Perl.

The meeting details are here.

IDE

You find lots of information about Integrated Development Environments these days.
I have never got the point though (yet, etc, see below..).
My "IDE" is an instance of SciTe with sessions and some terminals to run the code in. SciTe sessions enable me to store projects and all their open listings. I then open the project I'm currently working on by choosing "Load Session".
Winning points: Super fast start, ultra flexible, quasi no overhead, very easy installation (just install SciTe and copy settings over to new install). And I like SciTe a lot for its folding - unfolding capabilities and its easy customization.

I don't want to start another war, beware!
I just thought it could be interesting to discuss a little how you organize your coding work and show off a tiny bit why this is the best way for you.

:m)

Perl API for ElasticSearch

I was about to start implementing the Sphinx full text search engine on our site when I saw that a new open source search engine ElasticSearch has just been released.

The overview shows off some of its many features but in summary, it:

  • is easy to setup
  • is designed to be distributed, and to scale from one node to hundreds
  • is real time
  • has a free search schema
  • is based on Lucene
  • speaks JSON over HTTP
  • supports multitenancy, which includes multiple indices, and multiple types per index, with the ability to query across any combination of the two

I liked the look of it so much that I've written a simple Perl API, which should be available on CPAN at : http://search.cpan.org/~drtech/ElasticSearch-0.01/

One nice thing that ElasticSearch.pm does is to retrieve a list of all available nodes in the ElasticSearch cluster, and tries to spread the load across nodes automatically.

More bad hardware developments

I was looking at buying a Nokia N900, as I like the Nokia telephones very much and have been a user of the Nokia Communicator 9300 and currently use an E71. The N900 could have been a great platform as it promises full userland programmatical access to all APIs. Except that the Maemo 5 platform is basically dead with the announcement of the MeeGo joint venture between Nokia and Intel. As MeeGo uses RPM instead of the Debian packaging format, it's highly unlikely that backports of applications or OS fixes will be available for any time longer than 1 year or so. And the software is a big part of the phone, as I don't want to write all software for my phone myself.

So, another EUR 450 saved to spend on other toys. Maybe Debian decides to support the N900 on their own, as it's an ARM platform. That would then make me interested again, as the Nokia hardware was good enough so far.

More bash completion help for perldoc

Yesterday’s posting got a fair bit of response. Among other feedback, I had some feature requests from Offer Kaye in my email today.

So now perldoc-complete will complete built-in Perl functions if you’ve typed perldoc -f (try it with eg. perldoc -f ch<Tab>) and it will also complete Perl’s documentation pages – although for uncluttering’s sake, it will hide the list if you’ve merely typed perldoc <Tab>.

Share and enjoy.

Perl Stand at Fosdem 2010

Fosdem: Brussels-based open source event during 2 days with +5000 visitors.

Perl was there too.

Here some pictures I took. Have a look at the perl-patched p*p and mr Perl Sees You. :-)

Cf. also Gabor's blog

Cheers.

ddn123456

Spot the Test::Class Bug!

If you run prove on this code, it will fail. Why? Click "Continue Reading" for the answer.

package Check;

use Test::Class::Most parent => 'Test::Class';

use Readonly;
Readonly my $CONSTANT => 4;
INIT { Test::Class->runtests }

sub checkit : Tests(1) {
    is $CONSTANT, 4, 'Constant should be set';
}

1;

Tips on perl.org

Why does perl.org dis on other languages?

"Perl -- It's like Java, only it lets you deliver on time and under budget."

Are you kidding me? Is that what we're about?

Instead, why don't we be critical about ourselves?

Did anyone notice that perl.org is just now looking like a site designed in the 90's?**

I hope the marketing committee takes their role seriously. Perl needs an identity that can carry it into the future. It's as if nobody wants to admit that a 5k - 15k grant to a GOOD designer to redesign a handful of our sites will do more for perl than half of the grant proposals currently out there. Instead of being passive and waiting for someone to propose a redesign we should have gone out and FOUND someone to do this years ago.

And what's the deal with the Camel all over the home page? Seriously! Is that not O'Reilly's symbol for perl? I'd much rather see 3 onions on the home page than an O'Reilly brand awareness campaign.

A bash completion helper for perldoc

A month ago, Yanick Champoux wrote a note about helpers for browsing the POD in your your local perl install.

His first script is for firing up a browser pointed at a local POD web server, including starting one up if it’s not already running – not that useful to me, since I haven’t found myself actually using these servers very much, because of the console↔browser flipping that they entail. Plain old perldoc on a console just feels faster to juggle.

However, he also includes another script: a completion helper for bash. This allows you to type something like perldoc Cata<tab> and have bash turn it into perldoc Catalyst for you. I used this script for mere hours before I realised it’s exactly the one thing I have always missed in Perl: a way to quickly and efficiently browse my local module library – the thing that all the POD web servers promised to give me, but couldn’t deliver in a convenient enough fashion for me to use routinely.

Locked out of my own hardware

No, this is not a post about the iPad. I don't own one.

Today's task - RPMs!

Haven't messed with RPMs for a long while (at Yahoo! we had folks whose job it was to provide the prebuilt system tools in the Y! format - among them, Mike Schilli of Log4perl fame who was our Perl packager), but today I'm building Perl 5.10.1 RPMS for our CentOS 5 systems.

I was able to take a 5.10.0 and adapt it pretty easily, with a few tweaks. First, because of the way CentOS lays out its include files, you need to patch IO.xs:

Perl QA Hackathon: Last call for applications for sponsorship

The phase for applications for sponsorship ends on Friday, 2010-02-12. We then shall deliberate over the weekend and announce the result afterwards so that travel arrangements can be made ASAP.

If you're considering coming to Vienna, and want to apply for sponsored travel/hotel, add yourself to the wiki now. The more you tell us about your plans, the better!

Easier Test Debugging

The vast majority of the time when I run the debugger on a test, I get frustrated because I have to wait for the test to load, then type '{l' (always list next window of lines before the debugger prompt) and then 'c' (continue to breakpoint -- because I've almost always set one at this point).

So I dropped this into my $HOME/.perldb file:

sub afterinit { 
    push @DB::typeahead, "{l", "c"
        if $ENV{DEBUGGING_TESTS};
} 

And in my vim config (where you put it will vary depending on your setup), I have this:

    noremap <buffer> <leader>D :!DEBUGGING_TESTS=1 perl -d -Ilib %<cr>

Introducing SimpleDB::Class

I've been working on a suite of modules for the past couple of months to make building applications on top of Amazon's SimpleDB as easy as building applications on DBIx::Class. It's called SimpleDB::Class.

It gives you an object relational mapper style interface to SimpleDB, which is heavily borrowed from DBIx::Class. It uses Memcached to speed up queries, increase capacity, and get around most of the stickiest problems with eventual consistency.

SimpleDB::Class also hides all of the things that most new developers find difficult about SimpleDB, things like cascading retries, next tokens, and the pseudo rest-like protocol for interfacing with SimpleDB. Not to mention handling searchable/sortable dates and numbers. As a developer, you simply give it some data or ask it for some data, and all those things just happen automatically behind the scenes.

There are even many nice utility functions like max and min, which are posted in questions to the SimpleDB forums all too often.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.