8. Tests de conformité OGC

The Open Geospatial Consortium (OGC) provides tests which can be run free of charge to make sure a server is compliant with a certain specification. This chapter provides a quick tutorial to setup the WMS and OGC API Features tests on an Ubuntu system. A detailed documentation can be found at the OGC website.

8.1. pyogctest

pyogctest est un outil Python dédié à l’exécution facile de tests OGC. L’installation peut se faire dans un environnement virtuel :

git clone https://github.com/pblottiere/pyogctest
virtualenv venv
source venv/bin/activate
pip install -e pyogctest/

8.2. WMS 1.3.0 test suite

To run the WMS 1.3.0 test suite with success, a specific test dataset is needed. It can be downloaded using pyogctest:

./pyogctest.py -s wms130 --download

Après le téléchargement, un projet teamengine_wms_130.qgs est disponible dans le nouveau répertoire data. Ce projet doit être enregistré comme projet par défaut pour QGIS Server grâce à la variable d’environnement QGIS_SERVER_PROJECT_FILE. De cette façon, nous n’avons pas besoin de définir explicitement le paramètre MAP du fournisseur QGIS Server.

Une configuration spécifique est également nécessaire pour se conformer aux tests de métadonnées. En effet, certaines métadonnées sont disponibles dans le répertoire data/metadata et doivent être disponibles pour le cadre de test de OGC grâce à une URL. L’option la plus simple est de configurer votre serveur web pour qu’il puisse y accéder par le biais d’une adresse du type http://XXX.XXX.XXX.XXX/metadata/Autos.xml. Ces URL de métadonnées sont définies dans le projet et insérées dans le document WMS GetCapabilities. Le projet doit donc être mis à jour en fonction de votre environnement de test pour permettre au logiciel QGIS Server de générer un document XML valide :

./pyogctest.py -s wms130 -m http://XXX.XXX.XXX.XXX/metadata

Maintenant que tout est correctement configuré, nous pouvons lancer la suite de tests WMS 1.3.0 :

./pyogctest.py -s wms130 -u http://XXX.XXX.XXX.XXX/qgisserver
========================== OGC test session starts ============================
testsuite: WMS 1.3.0
collected 184 items

data-independent::basic_elements::version-negotiation::negotiate-no-version .
data-independent::basic_elements::version-negotiation::negotiate-basic_elements-version .
data-independent::basic_elements::version-negotiation::negotiate-higher-version .
...
...
...

=========================== 184 passed in 40 seconds ===========================

8.3. OGC API Features test suite

To run the OGC API Features 1.0 test suite, a test dataset is needed. Considering that the underlying QGIS project doesn’t need specific configuration for this test suite, we can use the .qgs file provided in the training repository:

git clone https://github.com/qgis/QGIS-Training-Data
ls QGIS-Training-Data/exercise_data/qgis-server-tutorial-data/world.qgs

After the download, a world.qgs project is available in the qgis-server-tutorial sub directory. This project has to be registered as the default project for QGIS Server thanks to the QGIS_SERVER_PROJECT_FILE environment variable. This way, we don’t need to explicitly set the MAP vendor-parameter of QGIS Server.

Now that everything is properly configured, we can run the OGC API Features 1.0 test suite:

./pyogctest.py -s ogcapif -u http://XXX.XXX.XXX.XXX/qgisserver

=========================== OGC test session starts ============================
collected 56 items

collections::FeatureCollections::retrieveApiModel .
collections::FeatureCollections::noOfCollections .
collections::FeatureCollections::requirementClasses .
...
...
...

=========================== 56 passed in 24 seconds ============================