Automated WMS Testing with Python

date:

2012-06-23 17:53

author:

admin

category:

mapserver, python, wms

tags:

automation, ogc, PIL, python, wms

slug:

automated-wms-testing-with-python

status:

published

image0 <http://geographika.co.uk/archive/images/wms_testing/snake.jpg>`__This post and associated script details how to automate testing WMS (Web Mapping Service) layers. When you’ve set up several MapServer or GeoServer instances with 100s of layers, its nice to be able to make sure everything continues to run smoothly.

The automation makes maintenance proactive, rather than reacting to client’s emails wondering where their data has gone, and it beats pasting long obfuscated URLS into a browser and repeatedly pressing F5..

This script combines three of my current favourite Python libraries.

  • OWSLib a Python OGC Web Service utility library

  • PIL - The Python Imaging Library (PIL) used for image processing

  • Requests - a Python library to make web requests - “HTTP for Humans”

The PIL site handily contains Windows installers for nearly every version of Python. OWSLib and Requests can be added to your Python installation with easy_install, or PIP. I’m currently sticking with Python 2.6 as many scripts and packages I’m writing need to work with ArcGIS, which requires this version, and also on Windows, which puts me very much in the minority in the Python world outside of ESRI users.

In summary the script does the following:

  1. Connects to the WMS Server to retrieve a list of all the WMS layers.

  2. For each layer it finds the maximum extent of the layer and its projection code.

  3. A GetMap request is made to the WMS server for the layer at the maximum extent.

  4. Any errors getting the image can be reported. If an image is returned it is analysed to check if it is empty or blank.

I then adapted the sample script to work with Python’s unittest module so I could get a nice list of passes and fails for each map layer, and for a variety of issues such as HTTP failures or removed layers. It is then a simple step to set up a Windows Task Schedule to do a daily check that all WMS servers are up and running and returning data.

orphan:


Comments

http://www.gravatar.com/avatar/66a954812cb9b8e0277798daa43d325d?s=55&d=identicon&r=g

1. Antonio Santiago **

A write a similar post some time ago: http://acuriousanimal.orggeo.net/?q=node/16

It is nice to see how “nice” online applications can help us documenting :)

Reply
http://www.gravatar.com/avatar/ec399a4765f732e1a2acd5ca7edd0fd5?s=55&d=identicon&r=g

2. geographika **

Anything to make documentation get read!
Your `Balloon

Project <http://acuriousanimal.orggeo.net/?q=content/balloon-project>`__ looks interesting. Its easy to forget NASA Whirlwind when Google Earth gets all the publicity.

Reply
http://www.gravatar.com/avatar/48f28dc74ffa851aab0ebcbf2afe1302?s=55&d=identicon&r=g

3. Sean Gillies **

You wouldn’t believe the work I put into those ASCII class diagrams ;) It’s definitely kitsch from a bygone age.

Reply
Add Comment