Functional Tests and Continuous Integration with Google App Engine

I recently decided to get serious about testing my Appswell App Engine project and set up tests to run from the command line with continuous intregration using Jenkins. I’d looked into running tests for App Engine from the command line in the past but inevitably gave it up as being either too brittle or too convoluted. This time I decided not to wuss out.

After a bit of struggle, I finally managed to get a dependable solution wired together using virtualenv and nosetests. There were three key parts to getting the functional tests running in Jenkins:

  • Pip requirements (for virtualenv)
  • Configuration file for nosetests
  • Jenkins build command

Here are the actual scripts for each of the configuration components above. They are provided as a general reference and broad reassurance against that hopeless feeling that others, like me, may have felt when confronting this problem. Of course, some of the details are particular to my environment and you’ll have to adapt them to your own circumstances.

requirements.pip

NoseGAE==0.2.0
WebOb==1.2.3
WebTest==2.0.5
argparse==1.2.1
nose==1.3.0
nose-exclude==0.1.9
six==1.3.0
waitress==0.8.3
wsgiref==0.1.2

nosegae-setup.cfg

[nosetests]
where=./appspot/project/test
tests=model,unit,functional
verbosity=2
exe=1

# nosegae
with-gae=1
without-sandbox=1
gae-application=./appspot
gae-lib-root=./google_appengine_sdk

# requires nose-exclude package
exclude-dir=./appspot/project/test/dev
    ./appspot/project/test/tools

Jenkins virtualenv builder

Note: this uses the Shining Panda plugin: https://wiki.jenkins-ci.org/display/JENKINS/ShiningPanda+Plugin

# vars ref: https://wiki.jenkins-ci.org/display/JENKINS/ShiningPanda+Plugin

# Install pip requirements
pip install -r requirements.pip

# Link Google SDK
rm -f ./google_appengine_sdk
ln -sv /home/klenwell/projects/google/appengine/google_appengine-1.7.6 ./google_appengine_sdk

# Set PYTHONPATH
export PYTHONPATH=./appspot:"$PYTHONPATH"

# Additional tweaks
if [ ! -f ./appspot/config/core.py ]; then
cp ./appspot/config/core.py-dist ./appspot/config/core.py
fi

# Run Tests
$VIRTUAL_ENV/bin/nosetests -c nose.cfg

One final note: I was getting the error mentioned in this nose-gae bug report (AttributeError: ‘module’ object has no attribute ‘BaseRequest’) until I upgraded from Google App Engine SDK 1.7.5 to 1.7.6.

Advertisements
Functional Tests and Continuous Integration with Google App Engine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s