Thursday, November 14, 2013

Day 4: Jenkins continuous integration server, Selenium Grid, PHPUnit and Error 404

Day 4: Google Delight edition

The day is nearly half over and it's turning out to be a real bust.  Trying to struggle my way through the Typo3 / Jenkins / Selenium / PHPUnit tutorial with a lot of difficulty in - wait for it - setting up the environment.  Selenium Grid needs to be downloaded and I'm trying for the third time to do this; the rest of the day has been spent trying to find out how to basically configure Jenkins and start working with it, talking about this to some people who work with the thing, and the entire morning watching presentations that were interesting, but not helpful for what I'm trying to do. I'm getting anxious and discouraged about not having the environment ready yet so that I can start programming.

At last, the Selenium standalone jar file is finally downloaded and I can call it from the terminal:

As a hub with default arguments:
java -jar selenium-server-standalone-2.37.0.jar -role hub

As a node with default arguments:
java -jar selenium-server-standalone-2.37.0.jar -role node -hub http://localhost:4444/grid/register

You can view the status of the hub by opening a browser window and navigating to:
http://localhost:4444/grid/console

This is the first thing that worked today, and it helped me feel a lot better. I copied the code from the tutorial for a PHPUnit test for Selenium and called it from the command line as instructed:

phpunit selenium-tests.php

Fail! I mean, success, it ran!  But it ran and failed.  Which is OK!  It took a while to figure out what the error meant but after some help from one of the organisers and my friend Google, we found out that it had to do with the port, which needed to be changed in the code (and was not mentioned in the tutorial). In other words, in the unit test you need to not only set a variable to the browser name and host url (localhost), but also the port to which the Selenium Grid hub rePORTS (ha!) as listening to, namely 5555.

Success!  Running - and with success - my first PHPUnit test!  I refresh the Selenium Grid in Jenkins to see a long list of nodes and I'm on my way to completing the tutorial (albeit in a modified form - without virtual machines).  The organiser gave me a tip about how I could set up the virtual machines as instructed in the tutorial, in that instead of using "localhost" as the Jenkins host, I use the IP of my computer, which I can find from the command line by typing

ifconfig

I'm now ready to start configuring Jenkins to run the PHPUnit tests as a Job, rather from the command line.  Baby steps, baby steps.

Hours later...

OK, I finally found the solution to why my Typo3 introduction site wasn't working, but it wasn't thanks to any help (I got none) from the TYPO3 forum!  After much experimentation, googling, and a long pause to read about PHPUnit testing, configuring Jenkins, and continuous deployment, I found that in the apache2/sites_available/default file, the tags for the web docroot directory need to include "AllowOveride All", like so:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

Now it works - but it's pretty slow. Maybe I'll go on over the the Typo3 forum and see if anyone feels like dealing with me, or if it's a question, once again, of endless googling.

In any case, I feel like the first week on board the Hackership was a success: I set up Typo3, a Jenkins continuous integration server, a Selenium Grid testing environment, and wrote my first PHPUnit tests. In four days I accomplished more than I have in months and months while I was working full time, taking online courses, and going to technology meetups galore.

It's time to demo!

No comments:

Post a Comment

Play nicely!