Using Xvnc to create headless CI builds for Flex and AIR applications

Brian LeGros | December 20th, 2009 | programming  

Over the last year or so, I’ve worked to integrate xvfb into the projects I work with at the office and in the community to allow the execution of truly headless builds for Flex-based applications. Since the Flash Player and AIR require a windowing environment and typically unit and integration tests require this environment to be executed, integrating Flex into a CI process on Linux gets pretty hairy without having X-Windows support. Recently I’ve found myself switching from xvfb to Xvnc to more easily support headless builds in Flex. VNC server packages are pretty ubiquitous for most Linux distros, so getting something installed is pretty simple. What took me a couple of steps was getting setup based on the configuration of my CI server. In an effort to make searching a little simpler, here are the steps for using the Xvnc-plugin with Hudson on Ubuntu Desktop 8.10 with the default Tomcat 6 installation:

  1. Install the vnc4server package (i.e. – “apt-get install vnc4server”).
  2. Assuming the Ubuntu installation came with Tomcat 6 and is setup to run as the tomcat6 system user, do the following:
    1. Execute vncpassword as any user, following the prompts to set a password to be used by the “vncserver” command. This will create the “~/.vnc/password” file needed to run the vncserver command.
    2. Copy the file at ~/.vnc/password to /usr/shared/tomcat6/.vnc/password which is the default home directory for the tomcat6 user on the standard install of Ubuntu Desktop.
    3. Change the ownership rights on the “password” file to be owned and created by the “tomcat6″ user (i.e. – chown tomcat6:tomcat6 /usr/shared/.vnc/password)
    4. Edit /etc/init.d/tomcat6, adding a line to set the HOME environment variable to “/usr/shared/tomcat6″ (i.e. – export HOME=/usr/shared/tomcat6). Since “tomcat6″ is setup as a system user, from what I can tell, this environment variable is not set by default when a process is running as this user. The “vncserver” command will need this variable to determine where the “password” file is located to launch its process.
  3. If Tomcat is running as a standard user, execute the “vncserver” command using any display number (e.g. – vncserver :99) as the user. The command will force a prompt to enter a password to use for the server which will create the “~/.vnc/password” file with the appropriate ownership rights in the appropriate home directory.
  4. In Hudson, install the Xvnc-plugin for Hudson (http://wiki.hudson-ci.org/display/HUDSON/Xvnc+Plugin)
  5. OPTIONAL: In Hudson, under “Manage Hudson” -> “Configure system” -> “Xvnc”, set the “Base display number” field to 99. This is the base display number xvfb-run uses and I’m partial to reusing this setting.
  6. Under the configuration for you CI build, check the box labeled Run Xvnc during build.
  7. If all goes as expected, then your build should kick off the “vncserver :99″ command, set the DISPLAY environment variable to 99, execute your build to completion, and then execute “vncserver -kill :99″ to kill the Xvnc process.

Based on these steps, I’m am currently building Xvnc support into the FlexUnit4 Ant task for those who don’t use Hudson and can’t take advantage of the Xvnc-plugin. The Xvnc support is a basic mirror of what the plugin for Hudson aims to provide. Hopefully someone will find this footwork useful and save some time. I’m by no means a Linux guru, so if anyone has more insight, please feel free to share so others can benefit from your knowledge as well.

Happy building!

UPDATE: I’ve now tested and deployed the Xvnc support for the FlexUnit Ant task. Hopefully this will help anyone who’s not using Hudson but wants to take advantage of headless FlexUnit test executions using Xvnc.

FlashCamp Orlando 2009 Early Bird Extended!

Brian LeGros | May 11th, 2009 | news  

The early bird price (~$35) for registration to FlashCamp Orlando 2009 has been extended until May 15, 2009! Let’s face it, in this economy, every little bit helps. If you weren’t able to make it out to 360|Flex or cf.objective this year, or you can spare a Friday out of the office, come out to support a local developer event sponsored by Adobe and Universal Mind. Lunch, parking, door prizes, great sessions, and lots of great networking opportunities come with the registration price. The best part of it all is at the end of the day, you can drive home instead of staying in a dank motel like you do with most events. Tampa and Melbourne are still what I consider within driving distance, but you may still elect for the motel/hotel.

If you haven’t seen it yet, an interview has been posted with Adogo’s very own Jason Madsen about his session at FlashCamp. Hope you can make it out!

FlashCamp Orlando 2009 Registration Open

Brian LeGros | May 3rd, 2009 | news  

A little belated, but registration for FlashCamp Orlando 2009 opened this weekend with early bird expiring on May 1st at $35. Fear not though, the standard registration price is a mere ~$50 which, IMO, is a significantly small fee to attend a one day event.

FlashCamp (formerly FlexCamp) is a one-event day sponsored by Universal Mind and Adobe in which developers and designers can take a deep dive into topics ranging from introductory to advanced from the Flex world. This year Adogo’s very own Maxim Porges and Jason Madsen will be presenting along side Greg Wilson, of Adobe, as well as David Tucker, Andrew Powell, and Christian Saylor, of Universal Mind, and Carl Smith from nGenWorks. The event will take place on May 29th from 8:30 AM to 5:30 PM. Registration includes free parking, lunch, door prizes and lots of great networking.

If you have the time available, I definitely suggest signing up for a spot, availability is limited. I won’t be able to attend, or speak at, the event since we’ll be welcoming our 1st child into the world this month, but I would definitely be there otherwise. Hope you can make it out!

New FlexUnit … what?

Brian LeGros | May 3rd, 2009 | news  

Mike Labriola today announced on the Fluint Discussion group the big news a few in the Fluint team have been sitting for months now. The Fluint team is leading an OSS initiative to create the next version of the FlexUnit product. What’s great about this initiative (as Mike outlines on the mailing list) is that the new version of Fluint has been designed to mimic a lot of the conventions found in JUnit 4 while still addressing all of the problems Fluint solves for us in the Flex world. I know, for me, this means being more productive when writing tests and finally having better tooling when working with Flex. Here are some of the features listed from Mike’s email:

  • Metadata based Test and Suite identification (no more need to extend testcase or testsuite)
  • Hamcrest matchers courtesy of the hamcrest-as3 project.
  • Theories, DataPoints and Assumptions
  • Ignorable tests
  • Enhanced Sorting and Filtering
  • Custom runner integration

Probably one of the coolest part of this entire framework thus far is that last item. The Fluint team has already been able to successfully run legacy unit tests from the current versions of FlexUnit and Fluint. This means that you can have hybrid suites of tests in the new FlexUnit (e.g. -FlexUnit, Fluint, FUnit, asunit, etc) making migration between frameworks relatively simple.

We’re going to be launching a public alpha release in the near future, but we are still continuing work on Fluint at least as far as release 1.2 (1.1.1 was release yesterday). Please keep in mind however, the goal is for FlexUnit to become what would have been Fluint 2.0. Look for more details in the coming weeks.

Here’s to better testing!

Fluint 1.1.1 ready to be released

Brian LeGros | April 29th, 2009 | programming  

After a busy couple of months, I’ve finally gotten off of my ass and decided to do the integration for Fluint 1.1.1 and created the new branch for Fluint 1.2. We’re in the process of getting the artifacts into Google Code, but the release tag is in Subversion now for those who are interested. In this release we had a couple small fixes:

  • Issue #34 – Assets are not located in net/digitalprimates/fluint folder
  • Issue #35 – Can’t find TestResponder
  • Issue #37 – Air Test Runner needs better error handling
  • Added new target to ant build for building the airtestrunner as an .airi file (target => “airtestrunner-intermediary”)
  • Added flex builder metadata files to the samples project

I’ve already added my stubs for HTTPService and RemoteObject to the 1.2 branch for those who want to play around with them. Matt Hughes’ sequence improvements will also be included in 1.2 once I figure out where they ended up. For 1.2 I’m hoping to add some documentation for the wiki to address some really early issues as well as #28. In terms of bug fixes and new features, I’m hoping to tackle issues 32, 38, 41, 42, 44, 45, and 46 (#44 being the highest priority).

With a new baby coming in May, I’m unsure of my schedule, but I’m gonna do my best to get what I can ready (=who knows). In the mean time, kick the tires for us and let us know if there are any issues with 1.1.1.

FlexCamp Miami Wrap-up

Brian LeGros | March 6th, 2009 | conferences  

For a one day event, FlexCamp Miami had tons of information packed into its 8 sessions. Greg Wilson started us out with a great intro to some of the new features coming in Gumbo (Flex 4) followed by David Tucker digging down into the persistence side of AIR, along with some new 1.5 features. After the break, Max blew away the crowd with loom and some AS3 internals followed by Andrew Powell and some awesome examples of using Merapi to bring some deeper OS interaction to AIR. We broke for lunch and then Christian Saylor gave a really motivating presentation on the importance of UX for developers. I had to follow him with my CI presentation, which didn’t even compare and ran long, but then Jeremy Grelle swooped back in and kept everyone’s attention with Milestone 2 of the new Spring/BlazeDS integration (released this last Wednesday). Laura Arguello finished out the day with a cool introduction to Mate. Universal Mind did a great job with the event, lunch was good, and my brain is full.

I should have my code available on the Adogo SVN server this week, I’d just like to add an integration testing example before I commit it. Look for Max and my code/presentations there soon. Hopefully we can convince UM to have another one of these a little further North … say Orlando? I think I know a few Central Florida user groups that could help promote it.

NOTE: If you ever make your way down to Coral Gables, give Titanic Restaurant and Brewery a try. They’ve got some really tasty microbrews and even more delicious food. I recommend the Captain Smith’s Rye Ale, super great. For food, I had the Shrimp Po-boy which came with 6 huge tailed shrimp and a nice remoulade. Thanks to Greg for the great meal!

Fluint 1.1.0 Released!

Brian LeGros | February 12th, 2009 | programming  

Over the last few months, I’ve been working with Michael Labriola on the next minor version release of Fluint. Well, this evening Michael and I put the finishing touches on release 1.1.0. This release brought all of the changes I made to get Fluint working at the office for our CI process to the community. There are a couple of cool little gems that I think will be helpful for some:

  • Separation of failures and errors in test reporting (visual and XML).
  • XML compliant output with most CI servers as well as the JUnitReport task in Ant and the Surefire Reporting plugin in Maven.
  • Support in the Ant task for truly headless executions of the AIR Test Runner via xvfb-run.
  • Support for relative paths in the Ant task and AIR Test Runner.
  • Better error handling for non-compliant modules loaded into the AIR Test Runner.
  • LogBook integration for debugging
  • A big folder re-organization and Ant scripts to support developers when they need specialty builds.
  • Agreed upon a branching and tagging strategy so the community can have stable snapshots of source to build.

We probably should put together a ChangeLog wiki page, so that may be available soon. We did a few updates to the wiki, so stop by the Google Code site and check out the changes. Also, provide feedback on the discussion list, if there are features you’d like to see implemented, bugs that you find, or just general questions you need help with. People are great about helping on the list, so don’t feel discouraged.

This is my first major release of an OSS project that I’ve had code go into, so thanks to everyone who helped with the release, especially my wife for putting up with a lot of late nights. There is a lot more to come with Fluint over the next year that is going to be really exciting. Look for announcements during my presentation at FlexCamp Miami and on the discussion mailing list. Hope you enjoy the new release!

Getting AIR to run headless for Continuous Integration

Brian LeGros | January 7th, 2009 | programming  

Here’s the thing about proof-of-concept projects, they always get the high risk technology questions out of the way, but they never manage to expose the stupid gotchas that are coming down the line when you go to make them into a reality. Case in point, unit testing in Flex and continuous integration. In my last post, I spoke about how I got flex-mojos, ant, fluint, and Hudson all playing nice together. Please preface the following with the fact that I’m a terrible server admin, so there may be work arounds for the roadblocks I ran into, I’m just not aware of them.

So when our team went to deploy the PoC, we decided to use Windows. Our hope was that with the lack of headless support in AIR, Windows would provide us access to a windowing system even when a user isn’t authenticated thanks to the dreaded LocalSystem account. As expected, I was able to get Hudson up and running and the AIR test runner was working without issue while running as LocalSystem. I then needed to integrate a series of CI builds which we put together to automatically release our components. All of sudden, I had the need for user specific settings to interact with putty, plink, and SVN, then LocalSystem failed me. I setup a special user to run the service hosting Hudson and placed that user into the Administrator group to start; I figured once I had it working again, I’d restrict its rights … <crickets chirping>. So when I had finally gotten the automatic release builds working with the new user, I re-ran one of my previous CI builds only to find that the build would hang when the AIR runner for Fluint was executed. After hours of pouring over a solution (I even tried this registry hack for the service with no success), I decided that Windows just wasn’t going to work.

I decided to give Linux a shot and I have to say I had much better results; I chose Ubuntu for my PoC due to its simplicity for guys like me. As a nice plus, all of the SSH/SVN woes I experienced disappeared because I had a native SSH client and integration was just easy. I still had the issue however of needing to run AIR in a truly headless mode. I started with some tips I found on the Fluint mailing list and was able to get Xvfb up and running as a service. Integration with the Fluint Ant Task didn’t pan out easily though, so I again looked for another solution. I did some digging and as it turns out a lot of the Java/Swing folks had to solve the same problems we’re having to solve now before Java gained the ability to run Swing apps headlessly. I found this post on xvfb-run and it did the trick. In fact it worked out so well, that I went ahead and integrated it into the Fluint Ant task as an option. Effectively I just had it execute the AIR application with the “-a” flag so sysadmins who are picky about how xvfb-run is used may not like the lack of granularity I’ve built in, but it’s working for us. I know that FlexUnit has a similar issue since the Flash Player can’t be run in a headless-mode either, so this may be a good feature to add to the FlexUnit Ant task eventually too. On a side note, my changes to Fluint are being reviewed right now and it looks like I may get my branch merged into the next release fairly soon for anyone who is interested in finding binaries.

We’re still working to deploy on a different Linux distro at the moment, but I think we’ve finally managed to mitigate the risk of running a Flex build on a CI server for the different variations we’ve thrown together. If you see another post from me really soon, you’ll know the edge of the PoC sword got me again … stupid sneaky sword.

More updates about the new Brevard user group

Brian LeGros | July 20th, 2008 | programming  

Well, after some searching, I’ve decided to give House of Joe on 192 next to the Melbourne mall a shot for the first meeting of the Brevard user group I’m trying to start. It’s open until 11:00 PM on weekdays and has free wifi, so hopefully it’ll work out. Thanks to Sebastian for the suggestion.

I’ve been doing some thinking about the focus on the group. I’ve decided that rather than focusing exclusively on Adobe technologies, I’d like to shift the focus to rich internet technologies (RIA) including Flex, AIR, AJAX, and possibly Silverlight. I’ve been messing a lot with jQuery recently, and just like the rest of the masses, I can’t get enough of it; I’m sure there are others that feel the same way too. There are other cool APIs that’d I’d like to mess with including the spread over at Google (Data, Charts, Maps, etc.) that can fall under the umbrella of the RIA buzzword as well.

Based on the audience I’ve seen in Brevard and the types of jobs I see advertised on the job boards, I think this type of group will have a better chance at growth than just an Adobe focused group. My next goal is to pick a day and time that we can meet, then the first meeting’s topic, then a hopefully a domain and website. Initially I’m going to focus on just meeting up with people and hacking away at code, but if we get more people joining us, then maybe we can start doing presentations too.

Keep a look out for more info as I continually try to get my act together, and fail at doing so. ;)

Presenting at the Adogo in April

Brian LeGros | March 18th, 2008 | news  

It’s been a while since I’ve presented at the Adogo, so I figure I owe the group a couple of presentations. Based on the feedback we’ve been getting from the mailing list, I’m going to take a little bit of a different approach to this month’s meeting. We’re going to do 2, 30 minute presentations, one focusing on the conceptual and one focusing on the practical. The topics this month will be “The Mechanics of BlazeDS” (conceptual) and “RPC and Messaging Using BlazeDS” (practical). For those of you who are interested in seeing how Java will integrate with Flex, I will be showing off how to integrate POJO’s for use with RPC.

Hopefully I can keep the presentations short and the content simple and interesting. If anyone decides to stop by, make sure to hold me to that goal during the meeting. Primers should be posted soon. See you on April 1st, same time and place as always.