[gdal-dev] Easier testing of drivers using HTTP APIs

Even Rouault even.rouault at spatialys.com
Thu Apr 23 07:08:04 PDT 2015


Hi,

This will be of interest mainly for GDAL driver developers of drivers using 
HTTP APIs.

Writing autotests for such drivers isn't always easy, or reliable, since you 
have to connect to a server that may be temporarily unavailable (or definitely  
after some time), or there might be issues with credentials needed, etc...

I've recently experimented a simple trick for the new PLMosaic & PLScenes 
drivers, as well as when doing recent improvements in the WFS driver.

Basically CPLHTTPFetch() now accepts a "URL" that is a /vsimem/ path. So you 
can do things like:

gdal.FileFromMemBuffer('/vsimem/my_fake_url?param1=val1&param2=val2',
content_of_the_file)

CPLHTTPFetch() will only accept such /vsimem/ URLs if the config. option 
CPL_CURL_ENABLE_VSIMEM is set to YES (provision for potential security 
issues). You might also have to do small adjustments to your operational code 
to accept /vsimem/ in addition to http:// or https://

Another big advantage is that you can also more easily simulate errors that 
might be returned by a server, or resilience of your code to unexpected output 
from the server, which can help increasingly the line code coverage.

For real world examples:
http://svn.osgeo.org/gdal/trunk/autotest/gdrivers/plmosaic.py
http://svn.osgeo.org/gdal/trunk/autotest/ogr/ogr_plscenes.py
http://svn.osgeo.org/gdal/trunk/autotest/ogr/ogr_wfs.py

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list