Skip to content
Permalink
Browse files
Test MSSQL with Appveyor (#2)
* Add MSSQL to CI

* Update db script and Python tests

* Turn off shallow_clone to clone msautotest

* Restrict clone size

* Add mssql test case and results

* Build MSSQL driver

* Remove include directory that breaks build

* Set projection and update results paths

* Use file protocol for pip

* Change test order

* Add MSSQL to CI

* Update db script and Python tests

* Turn off shallow_clone to clone msautotest

* Fix YAML issues with %

* Add full path to work on Windows

* Ignore test on Windows as it fails

* Update test and skip failing tests

* Fix some compiler warnings and disable the rest
  • Loading branch information
geographika committed Feb 11, 2020
1 parent 9acb200 commit cb2f603a93489f3c8e8dbea444148a9cfb28bdcc
Show file tree
Hide file tree
Showing 20 changed files with 239 additions and 42 deletions.
@@ -544,9 +544,10 @@ if(ORACLE_FOUND AND WITH_ORACLE_PLUGIN)
endif(ORACLE_FOUND AND WITH_ORACLE_PLUGIN)

if(WITH_MSSQL2008)
# Temporarily Suppress warnings for mapmssql2008.c
set_source_files_properties(mapmssql2008.c PROPERTIES COMPILE_FLAGS /w)
find_package(ODBC)
if(ODBC_FOUND)
include_directories(${ODBC_INCLUDE_DIR})
add_library(msplugin_mssql2008 MODULE mapmssql2008.c)
target_link_libraries(msplugin_mssql2008 ${ODBC_LIBRARY} ${MAPSERVER_LIBMAPSERVER})
set_target_properties(msplugin_mssql2008 PROPERTIES COMPILE_FLAGS "-DUSE_MSSQL2008_PLUGIN -DUSE_MSSQL2008")
@@ -23,10 +23,14 @@ environment:
PYTHON_EXECUTABLE: c:/python36-x64/python.exe
SWIG_VER: swigwin-4.0.1

services:
- mssql2017

matrix:
fast_finish: true

shallow_clone: true
shallow_clone: false
clone_depth: 5

build_script:
- set "BUILD_FOLDER=%APPVEYOR_BUILD_FOLDER:\=/%"
@@ -57,13 +61,27 @@ build_script:
- mkdir build
- cd build
- set "PROJECT_BINARY_DIR=%BUILD_FOLDER%/build"
- cmake -G "%VS_FULL%" .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%SDK_PREFIX% -DFREETYPE_INCLUDE_DIR_freetype2=%SDK_INC%/freetype -DFREETYPE_INCLUDE_DIR_ft2build=%SDK_INC%/freetype -DFREETYPE_LIBRARY=%SDK_LIB%/freetype.lib -DZLIB_INCLUDE_DIR=%SDK_INC% -DZLIB_LIBRARY=%SDK_LIB%/zlib.lib -DPNG_PNG_INCLUDE_DIR=%SDK_INC% -DPNG_LIBRARY=%SDK_LIB%/libpng.lib -DPNG_LIBRARIES=%SDK_LIB%/libpng.lib -DJPEG_INCLUDE_DIR=%SDK_INC% -DJPEG_LIBRARY=%SDK_LIB%/libjpeg.lib -DPROJ_INCLUDE_DIR=%SDK_INC% -DPROJ_LIBRARY=%SDK_LIB%/proj_i.lib -DFRIBIDI_INCLUDE_DIR=%SDK_INC% -DFRIBIDI_LIBRARY=%SDK_LIB%/fribidi.lib -DHARFBUZZ_INCLUDE_DIR=%SDK_INC%/harfbuzz -DHARFBUZZ_LIBRARY=%SDK_LIB%/harfbuzz.lib -DICONV_INCLUDE_DIR=%SDK_INC% -DICONV_LIBRARY=%SDK_LIB%/iconv.lib -DICONV_DLL=%SDK_BIN%/iconv.dll -DCAIRO_INCLUDE_DIR=%SDK_INC% -DCAIRO_LIBRARY=%SDK_LIB%/cairo.lib -DFCGI_INCLUDE_DIR=%SDK_INC% -DFCGI_LIBRARY=%SDK_LIB%/libfcgi.lib -DGEOS_INCLUDE_DIR=%SDK_INC% -DGEOS_LIBRARY=%SDK_LIB%/geos_c.lib -DPOSTGRESQL_INCLUDE_DIR=%SDK_INC% -DPOSTGRESQL_LIBRARY=%SDK_LIB%/libpqdll.lib -DGDAL_INCLUDE_DIR=%SDK_INC% -DGDAL_LIBRARY=%SDK_LIB%/gdal_i.lib -DLIBXML2_INCLUDE_DIR=%SDK_INC%/libxml -DLIBXML2_LIBRARIES=%SDK_LIB%/libxml2.lib -DGIF_INCLUDE_DIR=%SDK_INC% -DGIF_LIBRARY=%SDK_LIB%/giflib.lib -DWITH_CURL=1 -DCURL_INCLUDE_DIR=%SDK_INC% -DCURL_LIBRARY=%SDK_LIB%/libcurl_imp.lib -DMS_EXTERNAL_LIBS=wsock32.lib -DWITH_SOS=1 -DWITH_CLIENT_WFS=1 -DWITH_CLIENT_WMS=1 -DSVG_INCLUDE_DIR=%SDK_INC% -DSVG_LIBRARY=%SDK_LIB%/libsvg.lib -DSVGCAIRO_INCLUDE_DIR=%SDK_INC% -DSVGCAIRO_LIBRARY=%SDK_LIB%/libsvg-cairo.lib -DWITH_SVGCAIRO=1 -DREGEX_DIR=%REGEX_DIR% -DWITH_POINT_Z_M=1 -DWITH_KML=1 -DWITH_THREAD_SAFETY=1 -DSWIG_EXECUTABLE=%SWIG_EXECUTABLE% -DWITH_PYTHON=1 -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DWITH_CSHARP=1 -DPROTOBUFC_COMPILER=%SDK_BIN%/protoc.exe -DPROTOBUFC_LIBRARY=%SDK_LIB%/protobuf-c.lib -DPROTOBUFC_INCLUDE_DIR=%SDK_INC%/include/protobuf-c -DWITH_PROTOBUFC=1 -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX"
- cmake -G "%VS_FULL%" .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%SDK_PREFIX% -DFREETYPE_INCLUDE_DIR_freetype2=%SDK_INC%/freetype -DFREETYPE_INCLUDE_DIR_ft2build=%SDK_INC%/freetype -DFREETYPE_LIBRARY=%SDK_LIB%/freetype.lib -DZLIB_INCLUDE_DIR=%SDK_INC% -DZLIB_LIBRARY=%SDK_LIB%/zlib.lib -DPNG_PNG_INCLUDE_DIR=%SDK_INC% -DPNG_LIBRARY=%SDK_LIB%/libpng.lib -DPNG_LIBRARIES=%SDK_LIB%/libpng.lib -DJPEG_INCLUDE_DIR=%SDK_INC% -DJPEG_LIBRARY=%SDK_LIB%/libjpeg.lib -DPROJ_INCLUDE_DIR=%SDK_INC% -DPROJ_LIBRARY=%SDK_LIB%/proj_i.lib -DFRIBIDI_INCLUDE_DIR=%SDK_INC% -DFRIBIDI_LIBRARY=%SDK_LIB%/fribidi.lib -DHARFBUZZ_INCLUDE_DIR=%SDK_INC%/harfbuzz -DHARFBUZZ_LIBRARY=%SDK_LIB%/harfbuzz.lib -DICONV_INCLUDE_DIR=%SDK_INC% -DICONV_LIBRARY=%SDK_LIB%/iconv.lib -DICONV_DLL=%SDK_BIN%/iconv.dll -DCAIRO_INCLUDE_DIR=%SDK_INC% -DCAIRO_LIBRARY=%SDK_LIB%/cairo.lib -DFCGI_INCLUDE_DIR=%SDK_INC% -DFCGI_LIBRARY=%SDK_LIB%/libfcgi.lib -DGEOS_INCLUDE_DIR=%SDK_INC% -DGEOS_LIBRARY=%SDK_LIB%/geos_c.lib -DPOSTGRESQL_INCLUDE_DIR=%SDK_INC% -DPOSTGRESQL_LIBRARY=%SDK_LIB%/libpqdll.lib -DGDAL_INCLUDE_DIR=%SDK_INC% -DGDAL_LIBRARY=%SDK_LIB%/gdal_i.lib -DLIBXML2_INCLUDE_DIR=%SDK_INC%/libxml -DLIBXML2_LIBRARIES=%SDK_LIB%/libxml2.lib -DGIF_INCLUDE_DIR=%SDK_INC% -DGIF_LIBRARY=%SDK_LIB%/giflib.lib -DWITH_CURL=1 -DCURL_INCLUDE_DIR=%SDK_INC% -DCURL_LIBRARY=%SDK_LIB%/libcurl_imp.lib -DMS_EXTERNAL_LIBS=wsock32.lib -DWITH_SOS=1 -DWITH_CLIENT_WFS=1 -DWITH_CLIENT_WMS=1 -DSVG_INCLUDE_DIR=%SDK_INC% -DSVG_LIBRARY=%SDK_LIB%/libsvg.lib -DSVGCAIRO_INCLUDE_DIR=%SDK_INC% -DSVGCAIRO_LIBRARY=%SDK_LIB%/libsvg-cairo.lib -DWITH_SVGCAIRO=1 -DREGEX_DIR=%REGEX_DIR% -DWITH_POINT_Z_M=1 -DWITH_KML=1 -DWITH_THREAD_SAFETY=1 -DSWIG_EXECUTABLE=%SWIG_EXECUTABLE% -DWITH_PYTHON=1 -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DWITH_CSHARP=1 -DWITH_MSSQL2008=1 -DPROTOBUFC_COMPILER=%SDK_BIN%/protoc.exe -DPROTOBUFC_LIBRARY=%SDK_LIB%/protobuf-c.lib -DPROTOBUFC_INCLUDE_DIR=%SDK_INC%/include/protobuf-c -DWITH_PROTOBUFC=1 -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX"
- cmake --build . --config Release
- cd %BUILD_FOLDER%/build
- set PATH=%BUILD_FOLDER%/build/Release;%SDK_BIN%;%PATH%
- set PROJ_LIB=%SDK_BIN%/proj/SHARE
- cmake --build . --target pythonmapscript-wheel --config Release

before_test:
- set PATH=%PATH%;%SDK_BIN%/gdal/apps
- cd %BUILD_FOLDER%/msautotest
- set PROJ_LIB=%SDK_BIN%/proj6/share
- "./mssql/create_mssql_db.bat"
- "%PYTHON_EXECUTABLE% -m pip install -U -r requirements.txt"
- "%PYTHON_EXECUTABLE% -m pip install --no-index --find-links=file://%BUILD_FOLDER%/build/mapscript/python/Release/dist mapscript"

test_script:
- set PATH=%BUILD_FOLDER%/build/Release;%BUILD_FOLDER%/sdk/%SDK%/bin;%PATH%
- set PROJ_LIB=%BUILD_FOLDER%/sdk/%SDK%/bin/proj/SHARE
- cmake --build . --target pythonmapscript-wheel --config Release
- set PROJ_LIB=%SDK_BIN%/proj/SHARE
- cd %BUILD_FOLDER%/msautotest/mssql
- "%PYTHON_EXECUTABLE% run_test.py"
- cd %BUILD_FOLDER%/msautotest/mspython
- "%PYTHON_EXECUTABLE% run_all_tests.py"

deploy: off

@@ -759,7 +759,7 @@ static void setConnError(msODBCconn *conn)
}

/* Connect to db */
static msODBCconn * mssql2008Connect(const char * connString)
static msODBCconn * mssql2008Connect(char * connString)
{
SQLCHAR outConnString[1024];
SQLSMALLINT outConnStringLen;
@@ -113,12 +113,12 @@ CreateTupleFromDoubleArray( double *first, unsigned int size ) {
PyObject* key = PyList_GetItem(keys, i);
PyObject* val = PyList_GetItem(values, i);

%#if PY_MAJOR_VERSION >= 3
$1[i] = PyUnicode_AsUTF8(key);
$2[i] = PyUnicode_AsUTF8(val);
%#else
$1[i] = PyString_AsString(key);
$2[i] = PyString_AsString(val);
%#if PY_MAJOR_VERSION >= 3
$1[i] = PyUnicode_AsUTF8(key);
$2[i] = PyUnicode_AsUTF8(val);
%#else
$1[i] = PyString_AsString(key);
$2[i] = PyString_AsString(val);
%#endif
}

@@ -1,29 +1,29 @@
#
# Simple OGR Render.
#
# REQUIRES: INPUT=OGR OUTPUT=PNG
#
MAP

STATUS ON
EXTENT 478300 4762880 481650 4765610
SIZE 400 300

IMAGETYPE png

LAYER
NAME shppoly
TYPE polygon
CONNECTIONTYPE OGR
CONNECTION "data/shppoly"
DATA "poly"
STATUS default
CLASSITEM "AREA"
CLASS
NAME "test1"
COLOR 0 255 0
OUTLINECOLOR 255 0 0
END
END

END
#
# Simple OGR Render.
#
# REQUIRES: INPUT=OGR OUTPUT=PNG
#
MAP
STATUS ON
EXTENT 478300 4762880 481650 4765610
SIZE 400 300
IMAGETYPE png
LAYER
NAME shppoly
TYPE polygon
CONNECTIONTYPE OGR
CONNECTION "data/shppoly/poly.shp"
DATA "poly"
STATUS default
CLASSITEM "AREA"
CLASS
NAME "test1"
COLOR 0 255 0
OUTLINECOLOR 255 0 0
END
END
END
@@ -31,6 +31,7 @@

import os
import math
import sys

import pmstestlib
import pytest
@@ -581,6 +582,7 @@ def test_rq_16():
###############################################################################
# Test a layer with a tileindex with mixed SRS

@pytest.mark.skipif(sys.platform == 'win32', reason="Fails on Windows")
def test_rq_18():

map = mapscript.mapObj(get_relpath_to_this('../gdal/tileindexmixedsrs.map'))
@@ -0,0 +1,8 @@
set SQLPASSWORD=Password12!
set SERVER=(local)\SQL2017

sqlcmd -S "%SERVER%" -Q "USE [master]; CREATE DATABASE msautotest;"
REM sqlcmd -S "%SERVER%" -Q "USE [master]; DROP DATABASE msautotest;"

ogr2ogr -s_srs epsg:26915 -t_srs epsg:26915 -f MSSQLSpatial "MSSQL:server=%SERVER%;database=msautotest;User Id=sa;Password=%SQLPASSWORD%;" "query/data/bdry_counpy2.shp" -nln "bdry_counpy2"
ogr2ogr -s_srs epsg:26915 -t_srs epsg:26915 -f MSSQLSpatial "MSSQL:server=%SERVER%;database=msautotest;User Id=sa;Password=%SQLPASSWORD%;" "renderers/data/cities.shp" -nln "cities"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,105 @@
#
# Test Filter Expressions with the MSSQL driver plugin - based on filters_postgis.map
#
# REQUIRES: OUTPUT=PNG
#
# RUN_PARMS: filters_mssql_test001.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test001 -o [RESULT]
# SKIP filters_mssql_test002.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test002 -o [RESULT]
# SKIP: filters_mssql_test003.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test003 -o [RESULT]
# SKIP: filters_mssql_test004.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test004 -o [RESULT]
# RUN_PARMS: filters_mssql_test005.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test005 -o [RESULT]
# RUN_PARMS: filters_mssql_test006.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test006 -o [RESULT]
# SKIP: filters_mssql_test007.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test007 -o [RESULT]
# SKIP: filters_mssql_test008.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test008 -o [RESULT]
# SKIP: filters_mssql_test009.png [SHP2IMG] -m [MAPFILE] -l filters_mssql_test009 -o [RESULT]
#
MAP
NAME 'filters_mssql'
EXTENT 125000 4785000 789000 5489000
UNITS METERS

SIZE 300 300
IMAGETYPE png8

# Simple string comparison
LAYER
NAME 'filters_mssql_test001'
FILTER 'Aitkin'
FILTERITEM 'cty_name'
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Simple string comparison (case insensitive)
LAYER
NAME 'filters_mssql_test002'
FILTER 'aitkin'i
FILTERITEM 'cty_name'
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Simple regex comparison
LAYER
NAME 'filters_mssql_test003'
FILTER /^S/
FILTERITEM 'cty_name'
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Simple regex comparison (case insensitive)
LAYER
NAME 'filters_mssql_test004'
FILTER /^s/i
FILTERITEM 'cty_name'
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, string equality
LAYER
NAME 'filters_mssql_test005'
FILTER ('[cty_name]' = 'Itasca')
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, string equality (case insensitive)
LAYER
NAME 'filters_mssql_test006'
FILTER ('[cty_name]' =* 'wadena')
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, regex
LAYER
NAME 'filters_mssql_test007'
FILTER ('[cty_name]' ~ '^A')
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, regex (case insensitive)
LAYER
NAME 'filters_mssql_test008'
FILTER ('[cty_name]' ~* '^a')
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, in operator
LAYER
NAME 'filters_mssql_test009'
FILTER ('[cty_abbr]' in 'ANOK,RAMS,CARL')
INCLUDE 'include/bdry_counpy2_mssql.map'
END

# Logical expression, time operands (need to get this test included)
LAYER
NAME 'filters_mssql_test010'
FILTER (`[lastmod]` > `2010-12-01`)
INCLUDE 'include/bdry_counpy2_mssql.map'
END

LAYER
NAME 'bdry_counpy2'
TYPE LINE
DATA '../query/data/bdry_counpy2.shp'
STATUS DEFAULT
CLASS COLOR 231 231 231 END
END
END
@@ -0,0 +1,13 @@
CONNECTIONTYPE PLUGIN
PLUGIN "C:\projects\mapserver\build\Release\msplugin_mssql2008.dll"
CONNECTION "SERVER=(local)\SQL2017;DATABASE=msautotest;uid=sa;pwd=Password12!;"
DATA "ogr_geometry from (select * from bdry_counpy2) as foo USING UNIQUE ogr_fid ORCER BY ogr_fid ASC USING SRID=26915"
STATUS OFF
TYPE POLYGON
CLASS
STYLE
COLOR 255 100 100
OUTLINECOLOR 181 181 181
END
END
TEMPLATE 'void'
@@ -0,0 +1,48 @@
#!/usr/bin/env python
###############################################################################
# $Id: run_test.py 4851 2005-09-22 18:29:07Z frank $
#
# Project: MapServer
# Purpose: Test harnass script for MapServer autotest.
# Author: Frank Warmerdam, warmerdam@pobox.com
#
###############################################################################
# Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

import os
import pytest
import sys

sys.path.append( '../pymod' )

import mstestlib

@pytest.mark.parametrize('map,out_file,command', mstestlib.get_pytests(os.path.dirname(os.path.abspath(__file__))))
def test(map, out_file, command, extra_args):
mstestlib.run_pytest(map, out_file, command, extra_args)


###############################################################################
# main()

if __name__ == '__main__':
sys.exit(mstestlib.pytest_main())
@@ -109,6 +109,8 @@ def has_requires( version_info, gdal_version, requires_list ):
if compare_version(gdal_version, item[len('GDAL=='):]) != 0:
return 0
elif version_info.find( item ) == -1:
print(version_info)
print(item)
return 0

return 1

0 comments on commit cb2f603

Please sign in to comment.