Archive

Archive for the ‘Open Source’ Category

PreparedEval

October 6th, 2009 Josh Graham No comments

Announcing PreparedEval, prepared statements for generating JavaScript (and the like) from Java. It prepares Java strings for JavaScript evaluation, similar to SQL prepared statements. Saves you from quote escape nightmares! Great for Selenium tests and Rhino JavaScript.

As a follow-up to my post on escaped, quoted strings, Taking the idea of using a different encoding scheme further (and not being super happy about the need to pump the string through unescape()) I thought about interpolation and wondered about prepared statements in SQL. Some quick research turned nothing up, but while chatting with Ola Bini he also mentioned prepared statements, so this convinced me to knock something together that might be useful.

More information is at http://wiki.github.com/delitescere/PreparedEval.

There’s no runtime dependencies so it’s nice and tiny if you just want the JAR.

Let me know if you use if to help with CSS / XPath selectors for Selenium or if you have any suggestions on improving the API.

Categories: Coding, Open Source Tags:

Azure + Red = Purple: .NET Services for Ruby from ThoughtWorks

October 31st, 2008 Josh Graham No comments

If you want to develop Ruby applications that use the services in the Microsoft® .NET Services cloud, then this SDK is for you:

http://www.dotnetservicesruby.com/

Categories: Architecture, Open Source Tags:

ThoughtWorks Anthology

March 23rd, 2008 Josh Graham No comments

My CTO, Rebecca Parsons, announced the publication of the ThoughtWorks Anthology a few days ago:

I am thrilled to announce that the ThoughtWorks Anthology is now ON SALE!

http://www.pragprog.com/titles/twa

There are essays by Roy and Michael Robinson, Martin, Neal Ford, Tiffany Lentz, Stelios Pantazopoulos, Ian Robinson, Erik Doernenburg, Kristan Vingrys and James Bull, as well as ex-TWers Dave Farley, Jeff Bay and Julian Simpson. (And of course your’s truly made her own contribution). Mike Aguilar wrote the introduction.

Some comments that appear in the book:

Jim Fischer writes, “The anthology provides a peek into the diversity of views and perspectives held by a company that dares to take on the long-accepted tenet of the IT industry that custom software is too hard and too costly.”

Big Dave Thomas writes, “Software is in many ways a team sport, and the leaders shape the software culture. Often successful organizations don’t take the time to document them, and hence others don’t benefit from them. This interesting collection of personal essays gives a glimpse into the culture of ThoughtWorks through some of its leaders.”

I’m really excited that this project has come to fruition and I hope you all enjoy what you see.

Rebecca

I was lucky enough to review the content earlier this year. It’s a keeper.

UPDATE: Some press… http://www.sys-con.com/read/541124.htm

Jamming for Inveneo

February 29th, 2008 Josh Graham 1 comment

After a meeting of the office of the CTO, most of us stayed around in our San Francisco office for a few days to do some podcasts and to participate in a Code Jam for Inveneo, a not-for-profit who provide computers and connectivity to developing countries (especially their schools, hospitals, and poorer villages).

They install a server in, say, a hospital with a few lower-powered, custom desktops (almost iMac in configuration). These, as well as the servers, can run off solar panels for power.

We were presented with a worthwhile problem with a number of interesting constraints:

  • Low-power server running Ubuntu, with two small SATA hard disks in a Linux software RAID-1 array
  • VMWare images of the servers for testing
  • Python, bash, mdadm, and beep as our “programming languages”

When a RAID array fails, we need to alert any (if any) humans who are near the server. This can be interesting as the only things nearby might be the tree it is mounted in with a long-range WiFi, or the goat who uses it as a heat source at night. This means that any alert should be sufficiently frequent and annoying for the locals to contact someone who can let the support technician know. The conflict is that it also might be the nurses in their office at the hospital who have work to do and don’t want to be disturbed.

The solution was to use the PC speaker to beep. We can control the pitch and duration of the beep. Some combinations sounded too much like an ECG machine so that was no good. In the end, we chose a simple rising scale that would sound odd in any environment (except, perhaps, in a Mike Oldfield recording). This is repeated by default every 30 minutes.

We also had to send an email to the support technician. This doesn’t work when the server doesn’t actually have any connectivity (as some are used only as a local communications hub), or when connectivity is unreliable. Even then, many of the technicians are hours or even days away from the servers.

As many of the technicians aren’t particularly technical, we also had help by identifying which of the two disks had failed and allow them to simply change the one labelled “Disk 1″ or “Disk 2″. Serial numbers are good for this but VM hard disks don’t have serial numbers (I think that’s a feature request to both VMWare and Parallels).

We had Jeff Wishnie from Inveneo as the customer, Anda Abramovici as IM, Jonny Leroy as BA, Paul Hammant and Chad Wathington as QA, and the star developer crew of Drew Olson, Sammy Zahabi, Ola Bini, Erik Doernenburg and your’s truly. We quickly learned the following:

  • The skills we needed (and had, just a little rusty) were more along the lines of Unix devices, shell, ASCII control characters, and simulation
  • Python sucks (a bad tradesman blames his tools? perhaps – but it still sucks)

Anyway, we got most of what we wanted done in the time, and given the context, more than we anticipated. But we all would have liked to get a lot more done and would have if we were using our tools of choice (which are chosen for very good reasons).

Nonetheless, we’re doing it for the kids and it was great!

What a buzz. Super Agile. Super Fun. Go Inveneo, you rock!!

JRuby 1.1 RC2

February 17th, 2008 Josh Graham No comments

Charles Nutter has just written up a nice summary of the things in Thomas Enebo’s announcement of RC2 of JRuby 1.1

He talks in general about the astoundingly improved performance characteristics, particularly when compared to the Ruby 1.8.6 and 1.9 native interpreters, as well as the better use of JVM resources. Let alone the 260 bug fixes since RC1.

There’ll be more from me soon about our commercial experiences with JRuby and hopefully give you some fuel for introducing Ruby into your large, conservative corporate environment. I have to say, going back 2 years and thinking about the “enterprise readiness” of Ruby, things have changed a lot – almost exclusively due to the work done on JRuby. The pace at which the JRuby team work to address issues and improve the platform is outstanding, and puts commercial software vendors (particularly those hawking development tools) to shame. Things also have a long way to go – there are many, many solutions that would still be recommended around a recent version C# / .NET or Java implementation and that doesn’t look like changing for some time. The team behind JRuby is multi-skilled and very aware of innovations in other languages and platforms and I think this is one of their key success factors.

If you are evenly remotely interested in working on an OSS project, I encourage you to contribute to JRuby, even if it’s just to identify a problem to be fixed – it’s fun, it’s a great community, you’ll learn a lot about Ruby and the JVM, and you’ll work with some of the best guys in the business.

Categories: Architecture, Coding, Open Source Tags:

Ruby.NET is dead?

February 5th, 2008 Josh Graham No comments

I suppose we Aussies might give up too easily, Ola :-(

Antonio Cangiano let everyone else who isn’t on the list know the disappointing news from earlier this afternoon.

Categories: Architecture, Coding, Open Source Tags:

Dynamically defined Smoke Test Suites for Java

September 11th, 2007 Josh Graham 2 comments

Most of my ThoughtWorks colleagues love tests. We love writing tests and watching them fail, and we love writing the code that then makes them pass. We love tests so much that most of the time taken in building the software is in the running of the tests to make sure we haven’t done something dotty to break the software.

We hate when the time taken to run all those tests takes more than a few minutes, and this causes a lot of discussion internally as well as on our blogs. My strategic preference is to make the application smaller and thus the builds quicker, by building the software as discrete components (built and deployed independently) that are composed into an application. But before that, there’s a long list of things to make the builds and tests quicker. The list is never long enough, though.

We regularly discuss/concoct innovations in testing at the Sydney TW office. A few weeks ago Stacy Curl started a discussion on an idea he’s had for a while around optimising acceptance tests. During this discussion, we talked about various techniques, including profiling and coverage, which then prompted thoughts around knowing which code each test covered.

This then blossomed into a requirement which was to instrument the code that is covered by each test such that when that code is changed, the tests that cover it are known. This then lets us run only the tests that “need” to be run when we change some code. I say “need” because there are always things below or outside the code that may alter behaviour, so a full test suite still has to be run at some point, just not in a way that delays feedback on the most likely problems.

In essence, we wanted a tool that defines the smoke tests (pre-commit build, initial CruiseControl pipeline build) dynamically. The “changed” code could be based on file system modified times, Subversion status, CruiseControl modificationset, etc.

Unfortunately, the context provided by tools like Clover, Emma and Cobertura isn’t sufficient to indicate which test is running (no stack is available in the metrics). The upshot was I went off and looked at using AspectJ aspects to trace the code during a test run. Gianny Damour helped with early optimisations of my advices and gave me the introduction to “cflow” which allowed me to remove my own stack-peeking logic. I was going to call it TestThis! (as in this.method()) but because of the annoyance in lowercase called it TestMe instead (no throwback to VB intended), with the almost obligatory “J” prefix for Java. Josh Price rightly pointed out that the resultant name “JTestMe” is lame – another reason to merge with ProTest (see below).

Only the source file name is tracked. While we could instrument to the method level, we felt that this was too granular and that any change to the source file should trigger all tests that touch any of that class’ logic. It also works for superclasses, inner classes and called classes – that is, the tests may not call the code directly, but because the code is within their control flow, they’re all tracked.

public aspect TestCoveringAClassObserver {
    pointcut allTestMethods(TestCase test):
        target(test) &&                                                   // capture the TestCase
        execution(public void TestCase+.test*())                          // and advise execution of any JUnit test methods
    ;

    before(TestCase test):
        cflow(allTestMethods(test)) &&                                    // within the control flow of the allTestMethods advice
        (execution(!private * *(*)) || execution(!private * *())) &&      // when executing any non-private method
        (execution(* !TestCase+.*()) || execution(* !TestCase+.*(*))) &&  // that is not in the test case class
        within (!com.thoughtworks.testme..*)                              // and not within any JTestMe class
        {
            recordLink(thisJoinPointStaticPart.getSourceLocation(), test);
        }
    ;
}

Even with the extra guards to avoid recursive advice explosions and to ignore instrumenting the test code itself, you can see that the core piece of code is a ridiculously few lines of AspectJ. The “database” updated by the recordLink() method is a fat ugly (but very fast) object de/serializer that I haven’t bothered cleaning up much.

To allow you to easily run your code with or without instrumentation (you may be nervous that AspectJ has subtly altered behaviour), I’ve used the AspectJ Load Time Weaving (from the AspectWorkz merge). It also means you can continue to use your own custom JUnit test runners. Instrumented – use aj5’s java --javaagent). Normal – use java.

At CITCONF in Sydney a few weeks back, where I gave this a quick demo, the crowd were very encouraging and the Atlassian Clover (nee-Cenqua) guys, who demonstrated a tops new version, were academically interested in the neat and tidy use of aspects (they can’t use them for a reason I can’t remember?? Will find out next meetup).

There’s a long to-do list, the first of which are make it more “one-click” to use and explore a merge into ProTest (a test prioritising tool – and I figure the tests that JTestMe identifies are just another way to prioritise tests). Others are SVN integration and Ant task, and a filter for the excellent Continuous Testing tool (which also allows for prioritising tests).

It’s just been accepted into the Codehaus so have a peek and let me know. The usage is clunky (change the JTESTME_HOME values and the aj5 java agent path and test cases in the Windows cmd files) but it works for HelloWorld demonstration purposes (no automatic file modification detection yet).

Categories: Agile / Lean, Coding, Open Source Tags:

JUnit 4 can’t tell the test its name!

May 22nd, 2007 Josh Graham 2 comments

TestCase.getName() was useful from time to time. I recently used it on a project where the name of the test was used as the “client application” name in the database connection properties. This was good for tracking what tests were doing in the database when they made use of stored procedures (by using SQLSleuth for example).

JUnit 4 does not have any out-of-the-box mechanism for a test case to get it’s own name (including during setup and teardown).

JUnit 4 has some interesting architectural changes under-the-covers (some of which we’ll touch on shortly), but the main change to the outside world was the use of annotations to drive the testing framework.

Previously, we used framework-imposed conventions — like test cases must be public void methods whose name starts with “test” in a class that extends a subclass of TestCase, and de facto conventions — like tests are in the “test” source tree and, if a unit test, have the name of the class they’re testing with the suffix (or prefix) “Test”.

The TestCase base class came with some nice properties, like getting the name of the current test case.

<siderant>
Is the new API so much more fabulous than the old? As Jason Yip asked me, “Does it make you write your tests any better?”. For my piece of the apple pie, I don’t think so.
<\siderant>

So, as JUnit 4 does not use inheritence from TestCase, you lose the properties the base class provided, and that includes getName(). So how does my test case know it’s name?

Before you reach for your Throwable, it’s no good just looking at the stack because @Before and @After methods may want to know the test case name too, and their method name isn’t it.

It turns out that this little gem was not included in the gift-wrapped functionality of JUnit 4. I had a little hunt around and found a posting by Gabriel Cooper that held the key. I set about testing it and making sure the global mutable state the technique requires was at least thread-safe.

Here’s the result. Hopefully something of it’s like appears in the default runner sometime soon (and it could do it in it’s run() method without messing around with listeners).

Visit the ThoughtWorks Sydney GeekNight code repository to have a look at the full Eclipse project with multi-threading tests (also has some nice use of Futures to assist in testing for thread-safety).

Categories: Agile / Lean, Coding, Open Source Tags:

Crowdsourcing

June 27th, 2006 Josh Graham 1 comment

My erstwhile colleague, JR, has dropped me a note that his new company has just launched their website http://www.cambrianhouse.com/ Check it out for yourself and you can chase Her Majesty around their office.

I wonder if Cambrian House will be sending ThoughtWorks an elephant full of Coke?

Categories: Cyberspace, Open Source Tags:

The good, the bad, the ugly

June 12th, 2005 Josh Graham No comments

A long weekend in Sydney spend trawling the net, checked out TSS and looked again at JSR-170 (Content Repository). While there started branching off to various other sites, which leads me to the title of this entry.

The good: http://www.jetbrains.com/company/people/Smirnova_Olesya.html. Olesya Smirnova. I like the tool, really like the namesake Vodka, and really really like the biography (her picture ain’t too shabby either, grrrrarrrr).

The bad: JSR-170. Why in the name of all that’s holy do we let the same vendors who write aweful software anywhere near the standards related to that software?

The ugly: BileBlog http://www.jroller.com/page/fate/ Hani Suleiman. Would be easy to take offence if it wasn’t coming from someone involved in writing OpenSymphony. ROFLMAO.

Categories: Open Source Tags: