2013-03-19

Garlic automated testing

Automated testing in a sec.

Jenkins is a great piece of software. Its a great in many dimensions, one of them is size and complexity. It also uses Java which makes it even greater, or should I say bigger and slower?

For devices like Raspberry Pi, or limited resources servers as virtual machines, using Jenkins can mean a third of your available memory. And to set it running spending some time setting up Tomcat or similar, Apache or similar, then setting all up, users.. And finally use it! Actually its not a lot of work, but for my taste overkill for simple automated testing.

So for those use cases that Jenkins is overkill, I present Garlic.

https://github.com/davidmoreno/garlic

Garlic uses the onion http C library, and it developed using C++. Its actually very few lines of code, and can be improved in many ways, but does the job. Currently it allows only one testing project (although that will be changed as needed) and it uses only an external executable as tests. This will be normally a shell script that runs whatever programs do the real testing, and if the shell scripts succeeds, then the tests pass.

5 Minutes Long Howto

After downloading it fro github and compiling all that garlic needs for running is an ini config file, as for example this one from onion:
# Garlic test config file. Check http://github.com/davidmoreno/garlic

[global]
#username=coralbits
#password=coralbits

name=Garlic test onion

[server]
port=1234
address=0.0.0.0

[scripts]
on_back_to_normal=mail -s "[Onion testing] is back to normal ✓" dmoreno@coralbits.com
on_error=mail -s "[Onion testing] error ✗" dmoreno@coralbits.com

check=git fetch && [ $( git diff origin/master | wc -l ) = 0 ]
update=git pull

test=./auto.sh
It has very simple sections. Global can set the password and username, as it can only can have one (maybe in the future I will add pam support, to use local users). Also here the user adds a name for the server.

At server the user can set up the server address and port to use for the server. Maybe in the future SSL support can be added quite easily.

Finally on the scripts section user sets up scripts to be executed when the different events happen, as errors, back to normal, check, update and finally the test. Some of these are not yet implemented (I look at you update), and maybe in the future the format will change to allow several tests, and even several proyects.

But this is the main format. Check the github site for more info on each parameter.

Automatic testing and running

To run the server the user must run garlic pointing to the ini file:

./garlic ~/onion/build/test/onion.ini

To do the automated testing, system facilities must be used, as cron, adding a line like:

*/5 * * * * ~/garlic/build/src/garlic ~/onion/build/test/onion.ini --check-and-run

The --check-and-run command line option runs the scripts/check script, and if success (exit code 0), then runs the tests.

Contributions appreciated

Source code is MPL licensed: just use it.

Current source code is at github: https://github.com/davidmoreno/garlic

It is simple and functional, but more features can be added, as multiple tests, use PAM authentication, HTTPS support... Even use less the Unicode smileys as they dont display properly on every browser.

No comments:

Post a Comment