From 9bbbe9e7c151df3502500ee504e8578a98c36a97 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Mon, 11 Jun 2018 14:47:39 +0200 Subject: [PATCH 1/2] Make POSTGIS_VERSION detection automatic --- run_tests.sh | 2 +- run_tests_docker.sh | 2 +- test/acceptance/aggregation.js | 2 +- test/acceptance/buffer-size-format.js | 4 ++-- test/acceptance/mvt-regressions.js | 2 +- test/acceptance/mvt.js | 2 +- test/acceptance/user-database-timeout-limit.js | 2 +- test/acceptance/vector-layergroup.js | 2 +- test/support/prepare_db.sh | 14 ++++++++++++++ 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index f26cad6d..e0756ad0 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -135,7 +135,7 @@ fi echo "Preparing the environment" cd ${BASEDIR}/test/support -sh prepare_db.sh ${PREPARE_DB_OPTS} || die "database preparation failure" +source prepare_db.sh ${PREPARE_DB_OPTS} || die "database preparation failure" cd - PATH=node_modules/.bin/:$PATH diff --git a/run_tests_docker.sh b/run_tests_docker.sh index 4a6b142a..87b3e2fb 100644 --- a/run_tests_docker.sh +++ b/run_tests_docker.sh @@ -6,4 +6,4 @@ npm install -g yarn@0.27.5 yarn # run tests -POSTGIS_VERSION=2.4 npm test +npm test diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 96401f15..b674bb2d 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -9,7 +9,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'mvt (postgis)', usePostGIS: true diff --git a/test/acceptance/buffer-size-format.js b/test/acceptance/buffer-size-format.js index ba8955e7..74e6288c 100644 --- a/test/acceptance/buffer-size-format.js +++ b/test/acceptance/buffer-size-format.js @@ -152,7 +152,7 @@ describe('buffer size per format', function () { }); }); }; - if (process.env.POSTGIS_VERSION === '2.4' && test.format === 'mvt'){ + if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){ testFn(true); } testFn(false); @@ -465,7 +465,7 @@ describe('buffer size per format for named maps w/o placeholders', function () { }); }); }; - if (process.env.POSTGIS_VERSION === '2.4' && test.format === 'mvt'){ + if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){ testFn(true); } testFn(false); diff --git a/test/acceptance/mvt-regressions.js b/test/acceptance/mvt-regressions.js index 7f5b6658..e8cab0a2 100644 --- a/test/acceptance/mvt-regressions.js +++ b/test/acceptance/mvt-regressions.js @@ -9,7 +9,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'postgis', usePostGIS: true diff --git a/test/acceptance/mvt.js b/test/acceptance/mvt.js index 065de37a..1d8dd15a 100644 --- a/test/acceptance/mvt.js +++ b/test/acceptance/mvt.js @@ -20,7 +20,7 @@ function createMapConfig(sql = TestClient.SQL.ONE_POINT) { } describe('mvt (mapnik)', mvt(false)); -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { describe('mvt (postgis)', mvt(true)); } diff --git a/test/acceptance/user-database-timeout-limit.js b/test/acceptance/user-database-timeout-limit.js index 6e5423e1..d65f6583 100644 --- a/test/acceptance/user-database-timeout-limit.js +++ b/test/acceptance/user-database-timeout-limit.js @@ -440,7 +440,7 @@ describe('user database timeout limit', function () { }); }); - if (process.env.POSTGIS_VERSION === '2.4') { + if (process.env.POSTGIS_VERSION >= '20400') { describe('fetching vector tiles via PostGIS renderer', function() { const usePostGIS = true; const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS; diff --git a/test/acceptance/vector-layergroup.js b/test/acceptance/vector-layergroup.js index 0778453e..d27fd874 100644 --- a/test/acceptance/vector-layergroup.js +++ b/test/acceptance/vector-layergroup.js @@ -72,7 +72,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'mvt (postgis)', usePostGIS: true diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index f2121147..7c5ab8d6 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -70,6 +70,20 @@ echo "PUBLICPASS: ${PUBLICPASS}" echo "TESTUSER: ${TESTUSER}" echo "TESTPASS: ${TESTPASS}" +# Sets the env variable POSTGIS_VERSION as Major * 10000 + Minor * 100 + Patch +# For example, for 2.4.5 ~> 20405 +auto_postgis_version() { + local POSTGIS_STR=$(psql -c "Select default_version from pg_available_extensions WHERE name = 'postgis';" -t); + local pg_version=$(echo $POSTGIS_STR | awk -F '.' '{print $1 * 10000 + $2 * 100 + $3}') + + echo $pg_version +} + +if [ -z "$POSTGIS_VERSION" ]; then + export POSTGIS_VERSION=$(auto_postgis_version) + echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" +fi + if test x"$PREPARE_PGSQL" = xyes; then echo "preparing postgres..." From 50cf5e5c7ae7770fc361758bea90cd2b875769c1 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Mon, 11 Jun 2018 16:01:29 +0200 Subject: [PATCH 2/2] Avoid infinite loop --- run_tests.sh | 2 +- test/support/prepare_db.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index e0756ad0..b409db83 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -135,7 +135,7 @@ fi echo "Preparing the environment" cd ${BASEDIR}/test/support -source prepare_db.sh ${PREPARE_DB_OPTS} || die "database preparation failure" +source prepare_db.sh "${PREPARE_DB_OPTS}" || die "database preparation failure" cd - PATH=node_modules/.bin/:$PATH diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index 7c5ab8d6..95e031f7 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -25,6 +25,8 @@ while [ -n "$1" ]; do elif test "$1" = "--no-sql-download"; then DOWNLOAD_SQL_FILES=no shift; continue + else + shift; continue; fi done