Merge pull request #1670 from lonvia/bdd-tests
Introduce behaviour-driven testing for integration testsHEAD
commit
4066b2ea8e
|
@ -26,7 +26,9 @@ runs:
|
|||
postgresql-${POSTGRESQL_VERSION}-postgis-${POSTGIS_VERSION}-scripts \
|
||||
postgresql-client postgresql-contrib-${POSTGRESQL_VERSION} \
|
||||
python3-psycopg2 \
|
||||
python3-setuptools \
|
||||
zlib1g-dev
|
||||
pip3 install behave
|
||||
if [ "$CC" = clang-8 ]; then sudo apt-get install -yq --no-install-suggests --no-install-recommends clang-8; fi
|
||||
shell: bash
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@ runs:
|
|||
- name: Install packages
|
||||
run: vcpkg install bzip2:x64-windows expat:x64-windows zlib:x64-windows proj4:x64-windows boost-system:x64-windows boost-filesystem:x64-windows boost-property-tree:x64-windows lua:x64-windows libpq:x64-windows
|
||||
shell: bash
|
||||
- name: Install psycopg2
|
||||
run: python -m pip install psycopg2
|
||||
- name: Install psycopg2 and beahve
|
||||
run: python -m pip install psycopg2 behave
|
||||
shell: bash
|
||||
|
|
|
@ -13,7 +13,7 @@ jobs:
|
|||
- name: Install prerequisites
|
||||
run: |
|
||||
brew install lua boost postgis pandoc
|
||||
pip3 install psycopg2
|
||||
pip3 install psycopg2 behave
|
||||
pg_ctl -D /usr/local/var/postgres start
|
||||
shell: bash
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@ build
|
|||
docs/html
|
||||
docs/latex
|
||||
|
||||
tests/__pycache__
|
||||
__pycache__
|
||||
|
|
|
@ -85,12 +85,6 @@ The code comes with a suite of tests. They are only compiled and run when
|
|||
Tests are executed by calling `ctest`. You can call `ctest` with `-L NoDB` to
|
||||
only run tests that don't need a database.
|
||||
|
||||
Regression tests require python and psycopg to be installed. On Ubuntu run:
|
||||
|
||||
```sh
|
||||
sudo apt-get install python3-psycopg2
|
||||
```
|
||||
|
||||
Most of these tests depend on being able to set up a database and run osm2pgsql
|
||||
against it. This is most easily done using `pg_virtualenv`. Just run
|
||||
|
||||
|
@ -131,6 +125,53 @@ database created by `pg_virtualenv`.
|
|||
If performance testing with a full planet import is required, indicate what
|
||||
needs testing in a pull request.
|
||||
|
||||
### BDD testing
|
||||
|
||||
Tests in the `tests/bdd` directory use [behave](https://github.com/behave/behave),
|
||||
a Python implementation of a behaviour-driven test framework. To run the
|
||||
BDD tests you need to have behave and psycopg2 installed. On Ubuntu run:
|
||||
|
||||
```sh
|
||||
sudo apt-get install python3-psycopg2 python3-behave
|
||||
```
|
||||
|
||||
There are ctest directives to run the tests. If you want to run the tests
|
||||
manually, for example to run single tests during development, you can
|
||||
switch to the bdd test directory and run behave directly from there:
|
||||
|
||||
```sh
|
||||
cd osm2pgsql/tests/bdd
|
||||
behave -DBINARY=<your build directory>/osm2pgsql
|
||||
```
|
||||
|
||||
Per default, behave assumes that the build directory is under `osm2pgsql/build`.
|
||||
If your setup works like that, you can leave out the -D parameter.
|
||||
|
||||
To run a single test, simply add the name of the test file, followed by a
|
||||
column and the line number of the test:
|
||||
|
||||
```sh
|
||||
behave flex/area.feature:71
|
||||
```
|
||||
|
||||
If you need to inspect the database that a test produces, you can add
|
||||
`-DKEEP_TEST_DB` and behave won't remove the database after the test is
|
||||
finished. This makes of course only sense, when running a single test.
|
||||
When running under pg_virtualenv, don't forget to keep the virtual environment
|
||||
as well. You can use the handy `-s` switch:
|
||||
|
||||
```sh
|
||||
pg_virtualenv -s behave -DKEEP_TEST_DB flex/area.feature:71
|
||||
```
|
||||
|
||||
It drops you into a shell when the behave test fails, where you can use
|
||||
psql to look at the database. Or start a shell in the virtual environment
|
||||
with `pg_virtualenv bash` and run behave from there.
|
||||
|
||||
The BDDs automatically detect if osm2pgsql was compiled with Lua and
|
||||
proj support and skip tests accordingly. They also check for the test
|
||||
tablespace `tablespacetest` for tests that need tablespaces.
|
||||
|
||||
## Coverage reports
|
||||
|
||||
To create coverage reports, set `BUILD_COVERAGE` in the CMake config to `ON`,
|
||||
|
|
|
@ -73,7 +73,6 @@ set_test(test-wkb LABELS NoDB)
|
|||
# these tests require LUA support
|
||||
if (WITH_LUA)
|
||||
set_test(test-output-flex)
|
||||
set_test(test-output-flex-area)
|
||||
set_test(test-output-flex-attr)
|
||||
set_test(test-output-flex-bbox)
|
||||
set_test(test-output-flex-cluster)
|
||||
|
@ -122,21 +121,20 @@ if (NOT WIN32)
|
|||
endif()
|
||||
|
||||
|
||||
find_package(PythonInterp 3)
|
||||
find_program(BEHAVE_BIN NAMES behave)
|
||||
|
||||
if (PYTHONINTERP_FOUND)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/regression-test.py.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/regression-test.py)
|
||||
if (BEHAVE_BIN)
|
||||
foreach(BDD_TEST IN ITEMS regression flex command-line)
|
||||
add_test(NAME bdd-${BDD_TEST}
|
||||
COMMAND behave -DBINARY=$<TARGET_FILE:osm2pgsql> ${BDD_TEST}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bdd)
|
||||
message(STATUS "Added test: bdd-${BDD_TEST}")
|
||||
endforeach(BDD_TEST)
|
||||
|
||||
add_test(NAME regression-test-pbf
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/regression-test.py -v)
|
||||
set_tests_properties(regression-test-pbf PROPERTIES TIMEOUT ${TESTING_TIMEOUT})
|
||||
set_tests_properties(regression-test-pbf
|
||||
set_tests_properties(bdd-regression
|
||||
PROPERTIES FIXTURES_REQUIRED Tablespace)
|
||||
set_tests_properties(regression-test-pbf PROPERTIES ENVIRONMENT OSM2PGSQL_BINARY=$<TARGET_FILE:osm2pgsql>)
|
||||
message(STATUS "Added test: regression-test-pbf (needs Python with psycopg2 module)")
|
||||
else()
|
||||
message(WARNING "Can not find python, regression test disabled")
|
||||
message(WARNING "Cannot find behave, BDD tests disabled")
|
||||
endif()
|
||||
|
||||
if (WITH_LUA)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[behave]
|
||||
show_skipped=False
|
||||
default_tags=~@Fail
|
|
@ -0,0 +1,20 @@
|
|||
Feature: Tests for various DB connection parameters
|
||||
|
||||
Scenario Outline:
|
||||
Given the OSM data
|
||||
"""
|
||||
n34 Tamenity=restaurant x77 y45.3
|
||||
"""
|
||||
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| -d |
|
||||
| <connection_parameter> |
|
||||
|
||||
Then table planet_osm_point has 1 row
|
||||
|
||||
Examples:
|
||||
| connection_parameter |
|
||||
| {TEST_DB} |
|
||||
| dbname={TEST_DB} |
|
||||
| postgresql:///{TEST_DB} |
|
||||
| postgres:///{TEST_DB} |
|
|
@ -0,0 +1,15 @@
|
|||
Feature: Errors for invalid command line parameter combinations
|
||||
|
||||
Background:
|
||||
Given the OSM data
|
||||
"""
|
||||
n1 Tamenity=restaurant,name=Home x=23 y5.6
|
||||
"""
|
||||
|
||||
Scenario: create and append cannot be used together
|
||||
Then running osm2pgsql pgsql with parameters fails
|
||||
| -c | -a |
|
||||
And the error output contains
|
||||
"""
|
||||
--append and --create options can not be used at the same time
|
||||
"""
|
|
@ -0,0 +1,13 @@
|
|||
Feature: Importing data into different DB schemas
|
||||
|
||||
Scenario: Using a different schema for pgsql output tables
|
||||
Given the OSM data
|
||||
"""
|
||||
n3948 Thighway=bus_stop,name=Bus x22.45 y-20.1444
|
||||
"""
|
||||
Given the database schema osm
|
||||
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --output-pgsql-schema=osm |
|
||||
|
||||
Then table osm.planet_osm_point has 1 row
|
|
@ -0,0 +1,127 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# This file is part of osm2pgsql (https://osm2pgsql.org/).
|
||||
#
|
||||
# Copyright (C) 2022 by the osm2pgsql developer community.
|
||||
# For a full list of authors see the git log.
|
||||
from contextlib import closing
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from behave import *
|
||||
import psycopg2
|
||||
from psycopg2 import sql
|
||||
|
||||
from steps.geometry_factory import GeometryFactory
|
||||
|
||||
TEST_BASE_DIR = (Path(__file__) / '..' / '..').resolve()
|
||||
|
||||
# The following parameters can be changed on the command line using
|
||||
# the -D parameter. Example:
|
||||
#
|
||||
# behave -DBINARY=/tmp/my-builddir/osm2pgsql -DKEEP_TEST_DB
|
||||
USER_CONFIG = {
|
||||
'BINARY': (TEST_BASE_DIR / '..' / 'build' / 'osm2pgsql').resolve(),
|
||||
'TEST_DATA_DIR': TEST_BASE_DIR / 'data',
|
||||
'SRC_DIR': (TEST_BASE_DIR / '..').resolve(),
|
||||
'KEEP_TEST_DB': False,
|
||||
'TEST_DB': 'osm2pgsql-test',
|
||||
'HAVE_TABLESPACE': True,
|
||||
'HAVE_LUA': True,
|
||||
'HAVE_PROJ': True
|
||||
}
|
||||
|
||||
use_step_matcher('re')
|
||||
|
||||
def _connect_db(context, dbname):
|
||||
""" Connect to the given database and return the connection
|
||||
object as a context manager that automatically closes.
|
||||
Note that the connection does not commit automatically.
|
||||
"""
|
||||
return closing(psycopg2.connect(dbname=dbname))
|
||||
|
||||
|
||||
def _drop_db(context, dbname, recreate_immediately=False):
|
||||
""" Drop the database with the given name if it exists.
|
||||
"""
|
||||
with _connect_db(context, 'postgres') as conn:
|
||||
conn.set_isolation_level(0)
|
||||
with conn.cursor() as cur:
|
||||
db = sql.Identifier(dbname)
|
||||
cur.execute(sql.SQL('DROP DATABASE IF EXISTS {}').format(db))
|
||||
if recreate_immediately:
|
||||
cur.execute(sql.SQL('CREATE DATABASE {}').format(db))
|
||||
|
||||
|
||||
def before_all(context):
|
||||
# logging setup
|
||||
context.config.setup_logging()
|
||||
# set up -D options
|
||||
for k,v in USER_CONFIG.items():
|
||||
context.config.userdata.setdefault(k, v)
|
||||
|
||||
if context.config.userdata['HAVE_TABLESPACE']:
|
||||
with _connect_db(context, 'postgres') as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""SELECT spcname FROM pg_tablespace
|
||||
WHERE spcname = 'tablespacetest'""")
|
||||
context.config.userdata['HAVE_TABLESPACE'] = cur.rowcount > 0
|
||||
|
||||
# Get the osm2pgsql configuration
|
||||
proc = subprocess.Popen([str(context.config.userdata['BINARY']), '--version'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
_, serr = proc.communicate()
|
||||
ver_info = serr.decode('utf-8')
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError('Cannot run osm2pgsql')
|
||||
|
||||
if context.config.userdata['HAVE_LUA']:
|
||||
context.config.userdata['HAVE_LUA'] = 'Lua support not included' not in ver_info
|
||||
|
||||
if context.config.userdata['HAVE_PROJ']:
|
||||
context.config.userdata['HAVE_PROJ'] = 'Proj [disabled]' not in ver_info
|
||||
|
||||
context.test_data_dir = Path(context.config.userdata['TEST_DATA_DIR']).resolve()
|
||||
context.default_data_dir = Path(context.config.userdata['SRC_DIR']).resolve()
|
||||
|
||||
|
||||
def before_scenario(context, scenario):
|
||||
""" Set up a fresh, empty test database.
|
||||
"""
|
||||
if 'config.have_proj' in scenario.tags and not context.config.userdata['HAVE_PROJ']:
|
||||
scenario.skip("Generic proj library not configured.")
|
||||
|
||||
if 'config.have_lua' in scenario.tags and not context.config.userdata['HAVE_LUA']:
|
||||
scenario.skip("Lua support not compiled in.")
|
||||
|
||||
context.db = use_fixture(test_db, context)
|
||||
context.import_file = None
|
||||
context.import_data = {'n': [], 'w': [], 'r': []}
|
||||
context.osm2pgsql_params = []
|
||||
context.workdir = use_fixture(working_directory, context)
|
||||
context.geometry_factory = GeometryFactory()
|
||||
|
||||
|
||||
@fixture
|
||||
def test_db(context, **kwargs):
|
||||
dbname = context.config.userdata['TEST_DB']
|
||||
_drop_db(context, dbname, recreate_immediately=True)
|
||||
|
||||
with _connect_db(context, dbname) as conn:
|
||||
conn.autocommit = True
|
||||
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('CREATE EXTENSION postgis')
|
||||
cur.execute('CREATE EXTENSION hstore')
|
||||
|
||||
yield conn
|
||||
|
||||
if not context.config.userdata['KEEP_TEST_DB']:
|
||||
_drop_db(context, dbname)
|
||||
|
||||
|
||||
@fixture
|
||||
def working_directory(context, **kwargs):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
yield Path(tmpdir)
|
|
@ -0,0 +1,71 @@
|
|||
Feature: Tests for area column type
|
||||
|
||||
Scenario Outline:
|
||||
Given the 0.1 grid with origin 9.0 50.3
|
||||
| | | 7 | | | 8 |
|
||||
| | | | 11 | 12 | |
|
||||
| 3 | 4 | | 9 | 10 | |
|
||||
| 1 | 2 | 5 | | | 6 |
|
||||
And the OSM data
|
||||
"""
|
||||
w1 Tnatural=water,name=poly Nn1,n2,n4,n3,n1
|
||||
w2 Nn5,n6,n8,n7,n5
|
||||
w3 Nn9,n10,n12,n11,n9
|
||||
r1 Tnatural=water,name=multi Mw2@,w3@
|
||||
"""
|
||||
And the lua style
|
||||
"""
|
||||
local polygons = osm2pgsql.define_table{
|
||||
name = 'osm2pgsql_test_polygon',
|
||||
ids = { type = 'area', id_column = 'osm_id' },
|
||||
columns = {
|
||||
{ column = 'name', type = 'text' },
|
||||
{ column = 'geom', type = 'geometry', projection = <geom proj> },
|
||||
{ column = 'area', type = 'area', projection = <area proj> },
|
||||
}
|
||||
}
|
||||
|
||||
function is_empty(some_table)
|
||||
return next(some_table) == nil
|
||||
end
|
||||
|
||||
function osm2pgsql.process_way(object)
|
||||
if is_empty(object.tags) then
|
||||
return
|
||||
end
|
||||
|
||||
polygons:add_row({
|
||||
name = object.tags.name,
|
||||
geom = { create = 'area' }
|
||||
})
|
||||
end
|
||||
|
||||
function osm2pgsql.process_relation(object)
|
||||
polygons:add_row({
|
||||
name = object.tags.name,
|
||||
geom = { create = 'area', split_at = 'multi' }
|
||||
})
|
||||
end
|
||||
"""
|
||||
When running osm2pgsql flex
|
||||
Then table osm2pgsql_test_polygon contains
|
||||
| name | ST_Area(geom) | area | ST_Area(ST_Transform(geom, 4326)) |
|
||||
| poly | <st_area poly> | <area poly> | 0.01 |
|
||||
| multi | <st_area multi>| <area multi> | 0.08 |
|
||||
|
||||
Examples:
|
||||
| geom proj | area proj | st_area poly | area poly | st_area multi | area multi |
|
||||
| 4326 | 4326 | 0.01 | 0.01 | 0.08 | 0.08 |
|
||||
| 4326 | 3857 | 0.01 | 192987010.0 | 0.08 | 1547130000.0 |
|
||||
| 3857 | 4326 | 192987010.0 | 0.01 | 1547130000.0 | 0.08 |
|
||||
| 3857 | 3857 | 192987010.0 | 192987010.0 | 1547130000.0 | 1547130000.0 |
|
||||
|
||||
@config.have_proj
|
||||
Examples: Generic projection
|
||||
| geom proj | area proj | st_area poly | area poly | st_area multi | area multi |
|
||||
| 4326 | 25832 | 0.01 | 79600737.537 | 0.08 | 635499542.954 |
|
||||
| 3857 | 25832 | 192987010.0 | 79600737.537 | 1547130000.0 | 635499542.954 |
|
||||
| 25832 | 4326 | 79600737.537 | 0.01 | 635499542.954 | 0.08 |
|
||||
| 25832 | 3857 | 79600737.537 | 192987010.0 | 635499542.954 | 1547130000.0 |
|
||||
| 25832 | 25832 | 79600737.537 | 79600737.537 | 635499542.954 | 635499542.954 |
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
Feature: Test forward propagation of changes
|
||||
|
||||
Background:
|
||||
Given the OSM data
|
||||
"""
|
||||
n10 v1 x1.0 y1.0
|
||||
n11 v1 x1.0 y2.0
|
||||
n12 v1 x2.0 y2.0 Tnatural=tree
|
||||
n13 v1 x3.0 y3.0
|
||||
n14 v1 x3.1 y3.1
|
||||
n15 v1 x0.0 y0.0
|
||||
n16 v1 x0.0 y0.1
|
||||
n17 v1 x0.1 y0.1
|
||||
w20 v1 Nn10,n11,n12,n10 Tlanduse=forest
|
||||
w21 v1 Nn13,n14 Thighway=primary
|
||||
w22 v1 Nn15,n16
|
||||
w23 v1 Nn16,n17,n15
|
||||
r30 v1 Mw22@,w23@ Ttype=multipolygon,natural=water
|
||||
"""
|
||||
|
||||
Scenario: Node changes are forwarded to ways and relations by default
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | --latlong |
|
||||
Given the OSM data
|
||||
"""
|
||||
n13 v2 x3.1 y3.0
|
||||
w23 v2 Nn16,n17
|
||||
"""
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -a | --latlong |
|
||||
|
||||
Then table planet_osm_point has 1 row
|
||||
Then table planet_osm_line has 1 row
|
||||
Then table planet_osm_line has 0 rows with condition
|
||||
"""
|
||||
abs(ST_X(ST_StartPoint(way)) - 3.0) < 0.0001
|
||||
"""
|
||||
Then table planet_osm_line has 1 row with condition
|
||||
"""
|
||||
abs(ST_X(ST_StartPoint(way)) - 3.1) < 0.0001
|
||||
"""
|
||||
Then table planet_osm_roads has 1 row
|
||||
Then table planet_osm_polygon has 1 row
|
||||
|
||||
|
||||
Scenario: Node changes are not forwarded when forwarding is disabled
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | --latlong |
|
||||
Given the OSM data
|
||||
"""
|
||||
n13 v2 x3.1 y3.0
|
||||
w23 v2 Nn16,n17
|
||||
"""
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -a | --latlong | --with-forward-dependencies=false |
|
||||
|
||||
Then table planet_osm_point has 1 row
|
||||
Then table planet_osm_line has 1 row
|
||||
Then table planet_osm_line has 1 row with condition
|
||||
"""
|
||||
abs(ST_X(ST_StartPoint(way)) - 3.0) < 0.0001
|
||||
"""
|
||||
Then table planet_osm_line has 0 rows with condition
|
||||
"""
|
||||
abs(ST_X(ST_StartPoint(way)) - 3.1) < 0.0001
|
||||
"""
|
||||
Then table planet_osm_roads has 1 row
|
||||
Then table planet_osm_polygon has 2 rows
|
|
@ -0,0 +1,60 @@
|
|||
Feature: Basic tests of the gazetter output
|
||||
|
||||
Background:
|
||||
Given the input file 'liechtenstein-2013-08-03.osm.pbf'
|
||||
And the style file 'gazetteer-test.style'
|
||||
|
||||
Scenario:
|
||||
When running osm2pgsql gazetteer with parameters
|
||||
| --slim|
|
||||
|
||||
Then table place has 2836 rows
|
||||
And table place has 759 rows with condition
|
||||
"""
|
||||
osm_type = 'N'
|
||||
"""
|
||||
And table place has 2059 rows with condition
|
||||
"""
|
||||
osm_type = 'W'
|
||||
"""
|
||||
And table place has 18 rows with condition
|
||||
"""
|
||||
osm_type = 'R'
|
||||
"""
|
||||
And table place has 199 rows with condition
|
||||
"""
|
||||
address ? 'housenumber'
|
||||
"""
|
||||
And table place has 319 rows with condition
|
||||
"""
|
||||
address is not null
|
||||
"""
|
||||
|
||||
Given the input file '000466354.osc.gz'
|
||||
When running osm2pgsql gazetteer with parameters
|
||||
| -a |
|
||||
| --slim|
|
||||
|
||||
|
||||
Then table place has 2877 rows
|
||||
And table place has 764 rows with condition
|
||||
"""
|
||||
osm_type = 'N'
|
||||
"""
|
||||
And table place has 2095 rows with condition
|
||||
"""
|
||||
osm_type = 'W'
|
||||
"""
|
||||
And table place has 18 rows with condition
|
||||
"""
|
||||
osm_type = 'R'
|
||||
"""
|
||||
And table place has 199 rows with condition
|
||||
"""
|
||||
address ? 'housenumber'
|
||||
"""
|
||||
And table place has 319 rows with condition
|
||||
"""
|
||||
address is not null
|
||||
"""
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
Feature: Imports of the test database
|
||||
|
||||
Background:
|
||||
Given the input file 'liechtenstein-2013-08-03.osm.pbf'
|
||||
|
||||
Scenario: Import non-slim
|
||||
When running osm2pgsql pgsql
|
||||
|
||||
Then table planet_osm_point has 1342 rows
|
||||
And table planet_osm_line has 3231 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4130 rows
|
||||
|
||||
Then the sum of 'cast(ST_Area(way) as numeric)' in table planet_osm_polygon is 1247245186
|
||||
And the sum of 'cast(way_area as numeric)' in table planet_osm_polygon is 1247245413
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_line is 4211350
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_roads is 2032023
|
||||
|
||||
And there are no tables planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
|
||||
Scenario: Import non-slim in WGS84
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| -l |
|
||||
|
||||
Then table planet_osm_point has 1342 rows
|
||||
And table planet_osm_line has 3229 rows
|
||||
And table planet_osm_roads has 374 rows
|
||||
And table planet_osm_polygon has 4130 rows
|
||||
|
||||
And there are no tables planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
|
||||
Scenario Outline: Import slim
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| <drop> |
|
||||
|
||||
Then table planet_osm_point has 1342 rows
|
||||
And table planet_osm_line has 3231 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4130 rows
|
||||
|
||||
Then the sum of 'cast(ST_Area(way) as numeric)' in table planet_osm_polygon is 1247245186
|
||||
And the sum of 'cast(way_area as numeric)' in table planet_osm_polygon is 1247245413
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_line is 4211350
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_roads is 2032023
|
||||
|
||||
And there are <have table> planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
Examples:
|
||||
| drop | have table |
|
||||
| | tables |
|
||||
| --drop | no tables |
|
||||
|
||||
|
||||
Scenario Outline: Import with Lua tagtransform
|
||||
Given the default lua tagtransform
|
||||
When running osm2pgsql pgsql
|
||||
| --create |
|
||||
| <slim> |
|
||||
|
||||
Then table planet_osm_point has 1342 rows
|
||||
And table planet_osm_line has 3231 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4136 rows
|
||||
|
||||
Then the sum of 'cast(ST_Area(way) as numeric)' in table planet_osm_polygon is 1272140688
|
||||
And the sum of 'cast(way_area as numeric)' in table planet_osm_polygon is 1272140891
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_line is 4211350
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_roads is 2032023
|
||||
|
||||
And there are <have table> planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
Examples:
|
||||
| slim | have table |
|
||||
| --slim | tables |
|
||||
| | no tables |
|
||||
|
||||
Scenario Outline: Import slim with hstore
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
| <param3> |
|
||||
|
||||
Then table planet_osm_point has 1360 rows
|
||||
And table planet_osm_line has 3254 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4131 rows
|
||||
|
||||
And there are <has tables> planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
Examples:
|
||||
| param1 | param2 | param3 | has tables |
|
||||
| --hstore | --hstore-add-index | --drop | no tables |
|
||||
| -k | | | tables |
|
||||
| --hstore | --hstore-add-index | | tables |
|
||||
|
||||
|
||||
Scenario: Import slim with hstore all
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -j |
|
||||
|
||||
Then table planet_osm_point has 1360 rows
|
||||
And table planet_osm_line has 3254 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4131 rows
|
||||
|
||||
Then the sum of 'array_length(akeys(tags),1)' in table planet_osm_point is 4228
|
||||
And the sum of 'array_length(akeys(tags),1)' in table planet_osm_roads is 2317
|
||||
And the sum of 'array_length(akeys(tags),1)' in table planet_osm_line is 10387
|
||||
And the sum of 'array_length(akeys(tags),1)' in table planet_osm_polygon is 9538
|
||||
|
||||
|
||||
Scenario Outline: Import slim with various tweaks
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| -s |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
| <param3> |
|
||||
|
||||
Then table planet_osm_point has 1342 rows
|
||||
And table planet_osm_line has 3231 rows
|
||||
And table planet_osm_roads has 375 rows
|
||||
And table planet_osm_polygon has 4130 rows
|
||||
|
||||
Then the sum of 'cast(ST_Area(way) as numeric)' in table planet_osm_polygon is 1247245186
|
||||
And the sum of 'cast(way_area as numeric)' in table planet_osm_polygon is 1247245413
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_line is 4211350
|
||||
And the sum of 'ST_Length(way)' in table planet_osm_roads is 2032023
|
||||
|
||||
And there are tables planet_osm_nodes, planet_osm_ways, planet_osm_rels
|
||||
|
||||
Examples:
|
||||
| param1 | param2 | param3 |
|
||||
| --number-processes | 16 | |
|
||||
| --number-processes | 8 | -C1 |
|
||||
| -C0 | | |
|
||||
| -z | name: | |
|
||||
| --hstore-match-only | -k | |
|
||||
| --hstore-match-only | -x | -k |
|
||||
|
||||
Examples: Tablespaces
|
||||
| param1 | param2 | param3 |
|
||||
| --tablespace-main-data | tablespacetest | |
|
||||
| --tablespace-main-index| tablespacetest | |
|
||||
| --tablespace-slim-data | tablespacetest | |
|
||||
| --tablespace-slim-index| tablespacetest | |
|
||||
|
||||
|
||||
Scenario: Import slim with hstore and extra tags
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -j | -x |
|
||||
|
||||
Then table planet_osm_point has 1360 rows with condition
|
||||
"""
|
||||
tags ? 'osm_user' AND
|
||||
tags ? 'osm_version' AND
|
||||
tags ? 'osm_uid' AND
|
||||
tags ? 'osm_changeset'
|
||||
"""
|
||||
And table planet_osm_line has 3254 rows with condition
|
||||
"""
|
||||
tags ? 'osm_user' AND
|
||||
tags ? 'osm_version' AND
|
||||
tags ? 'osm_uid' AND
|
||||
tags ? 'osm_changeset'
|
||||
"""
|
||||
And table planet_osm_roads has 375 rows with condition
|
||||
"""
|
||||
tags ? 'osm_user' AND
|
||||
tags ? 'osm_version' AND
|
||||
tags ? 'osm_uid' AND
|
||||
tags ? 'osm_changeset'
|
||||
"""
|
||||
And table planet_osm_polygon has 4131 rows with condition
|
||||
"""
|
||||
tags ? 'osm_user' AND
|
||||
tags ? 'osm_version' AND
|
||||
tags ? 'osm_uid' AND
|
||||
tags ? 'osm_changeset'
|
||||
"""
|
|
@ -0,0 +1,14 @@
|
|||
Feature: Tests for bad input data
|
||||
|
||||
Scenario: Overly large relations are ignored
|
||||
Given the python-formatted OSM data
|
||||
"""
|
||||
n1 x45 y34
|
||||
r1 Ttype=multipolygon M{','.join('n' + str(i) + '@' for i in range(33000))}
|
||||
"""
|
||||
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
|
||||
Then table planet_osm_nodes has 1 row
|
||||
Then table planet_osm_rels has 0 rows
|
|
@ -0,0 +1,173 @@
|
|||
Feature: Import and update of multipolygon areas
|
||||
|
||||
Background:
|
||||
Given the input file 'test_multipolygon.osm'
|
||||
|
||||
Scenario Outline: Import and update slim
|
||||
Given <lua> lua tagtransform
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| <param1> |
|
||||
|
||||
Then there are tables planet_osm_nodes
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | round(ST_Area(way)) |
|
||||
| -1 | residential | Name_rel | 12895 |
|
||||
| 4 | farmland | Name_way3 | 3144 |
|
||||
| -8 | residential | Name_rel2 | 12894 |
|
||||
| 5 | farmland | Name_way4 | 3144 |
|
||||
| -14 | residential | Name_way5 | 12894 |
|
||||
| -11 | residential | Name_rel6 | 11529 |
|
||||
| -3 | residential | Name_rel11| 9286 |
|
||||
| 83 | farmland | NULL | 24859 |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | "natural" | round(ST_Area(way)) |
|
||||
| -24 | water | 18501 |
|
||||
| 102 | water | 12994 |
|
||||
|
||||
Then table planet_osm_line contains
|
||||
| osm_id | highway | name | round(ST_Length(way)) |
|
||||
| 6 | residential | Name_way6 | 228 |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | ST_NumInteriorRing(way) |
|
||||
| -3 | residential | Name_rel11 | 2 |
|
||||
|
||||
Then SELECT osm_id, round(sum(ST_Area(way))), round(sum(way_area::numeric)) FROM planet_osm_polygon GROUP BY osm_id
|
||||
| osm_id | area | way_area |
|
||||
| -13 | 17581 | 17581 |
|
||||
| -7 | 16169 | 16169 |
|
||||
| -29 | 68494 | 68494 |
|
||||
| -39 | 10377 | 10378 |
|
||||
| -40 | 12397 | 12397 |
|
||||
|
||||
Then SELECT osm_id, count(*) FROM planet_osm_polygon GROUP BY osm_id
|
||||
| osm_id | count |
|
||||
| -25 | 1 |
|
||||
| 113 | 1 |
|
||||
| 118 | 1 |
|
||||
| 114 | 1 |
|
||||
| 107 | 1 |
|
||||
| 102 | 1 |
|
||||
| 138 | 1 |
|
||||
| 140 | 1 |
|
||||
|
||||
Then table planet_osm_polygon has 0 rows with condition
|
||||
"""
|
||||
osm_id IN (109, 104)
|
||||
"""
|
||||
|
||||
Then table planet_osm_polygon has 0 rows with condition
|
||||
"""
|
||||
osm_id = -33 and "natural" = 'water'
|
||||
"""
|
||||
|
||||
Then SELECT osm_id, CASE WHEN '<param1>' = '-G' THEN min(ST_NumGeometries(way)) ELSE count(*) END FROM planet_osm_polygon GROUP BY osm_id
|
||||
| osm_id | count |
|
||||
| -13 | 2 |
|
||||
| -7 | 2 |
|
||||
|
||||
|
||||
Given the input file 'test_multipolygon_diff.osc'
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| -a |
|
||||
| <param1> |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | round(ST_Area(way)) |
|
||||
| -1 | residential | Name_rel | 13949 |
|
||||
| 4 | farmland | Name_way3 | 3144 |
|
||||
| -8 | residential | Name_rel2 | 12894 |
|
||||
| 5 | farmland | Name_way4 | 3144 |
|
||||
| -14 | residential | Name_way5 | 12894 |
|
||||
| -11 | residential | Name_rel6 | 11529 |
|
||||
| -3 | residential | Name_rel11| 9286 |
|
||||
| 83 | farmland | NULL | 24859 |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | "natural" | round(ST_Area(way)) |
|
||||
| -24 | water | 18501 |
|
||||
| 102 | water | 12994 |
|
||||
|
||||
Then table planet_osm_line contains
|
||||
| osm_id | highway | name | round(ST_Length(way)) |
|
||||
| 6 | residential | Name_way6 | 228 |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | ST_NumInteriorRing(way) |
|
||||
| -3 | residential | Name_rel11 | 2 |
|
||||
|
||||
Then SELECT osm_id, round(sum(ST_Area(way))), round(sum(way_area::numeric)) FROM planet_osm_polygon GROUP BY osm_id
|
||||
| osm_id | area | way_area |
|
||||
| -13 | 17581 | 17581 |
|
||||
| -7 | 16169 | 16169 |
|
||||
| -29 | 29155 | 29155 |
|
||||
| -39 | 10377 | 10378 |
|
||||
| -40 | 12397 | 12397 |
|
||||
|
||||
Then SELECT osm_id, count(*) FROM planet_osm_polygon GROUP BY osm_id
|
||||
| osm_id | count |
|
||||
| 113 | 1 |
|
||||
| 118 | 1 |
|
||||
| 114 | 1 |
|
||||
| 107 | 1 |
|
||||
| 102 | 1 |
|
||||
| 138 | 1 |
|
||||
| 140 | 1 |
|
||||
|
||||
Then table planet_osm_polygon has 0 rows with condition
|
||||
"""
|
||||
osm_id IN (-25, 109, 104)
|
||||
"""
|
||||
|
||||
Then table planet_osm_polygon has 0 rows with condition
|
||||
"""
|
||||
osm_id = -33 and "natural" = 'water'
|
||||
"""
|
||||
|
||||
Examples:
|
||||
| param1 | lua |
|
||||
| | no |
|
||||
| -G | no |
|
||||
| -k | no |
|
||||
| | the default |
|
||||
| -k | the default |
|
||||
|
||||
|
||||
Scenario: Import and update with flat-node option
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -F | flat.store |
|
||||
|
||||
Then there is no table planet_osm_nodes
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | round(ST_Area(way)) |
|
||||
| -1 | residential | Name_rel | 12895 |
|
||||
| 4 | farmland | Name_way3 | 3144 |
|
||||
| -8 | residential | Name_rel2 | 12894 |
|
||||
| 5 | farmland | Name_way4 | 3144 |
|
||||
| -14 | residential | Name_way5 | 12894 |
|
||||
| -11 | residential | Name_rel6 | 11529 |
|
||||
| -3 | residential | Name_rel11| 9286 |
|
||||
| 83 | farmland | NULL | 24859 |
|
||||
|
||||
|
||||
Given the input file 'test_multipolygon_diff.osc'
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim | -a | -F | flat.store |
|
||||
|
||||
Then table planet_osm_polygon contains
|
||||
| osm_id | landuse | name | round(ST_Area(way)) |
|
||||
| -1 | residential | Name_rel | 13949 |
|
||||
| 4 | farmland | Name_way3 | 3144 |
|
||||
| -8 | residential | Name_rel2 | 12894 |
|
||||
| 5 | farmland | Name_way4 | 3144 |
|
||||
| -14 | residential | Name_way5 | 12894 |
|
||||
| -11 | residential | Name_rel6 | 11529 |
|
||||
| -3 | residential | Name_rel11| 9286 |
|
||||
| 83 | farmland | NULL | 24859 |
|
||||
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
Feature: Updates to the test database
|
||||
|
||||
Background:
|
||||
Given the input file 'liechtenstein-2013-08-03.osm.pbf'
|
||||
|
||||
Scenario Outline: Simple updates with various parameters
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
| <param3> |
|
||||
|
||||
Given the input file '000466354.osc.gz'
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| -a |
|
||||
| --slim |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
| <param3> |
|
||||
|
||||
Then table planet_osm_point has 1457 rows
|
||||
And table planet_osm_line has 3274 rows
|
||||
And table planet_osm_roads has 380 rows
|
||||
And table planet_osm_polygon has 4277 rows
|
||||
|
||||
Examples:
|
||||
| param1 | param2 | param3 |
|
||||
| | | |
|
||||
| --number-processes | 15 | |
|
||||
| --number-processes | 8 | -C1 |
|
||||
| -C0 | | |
|
||||
| -z | name: | |
|
||||
| --hstore-match-only| -k | |
|
||||
| --hstore-match-only| -k | -x |
|
||||
|
||||
Examples: with tablespaces
|
||||
| param1 | param2 | param3 |
|
||||
| --tablespace-main-data | tablespacetest | |
|
||||
| --tablespace-main-index| tablespacetest | |
|
||||
| --tablespace-slim-data | tablespacetest | |
|
||||
| --tablespace-slim-index| tablespacetest | |
|
||||
|
||||
|
||||
Scenario Outline: Simple updates with hstore
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
|
||||
Given the input file '000466354.osc.gz'
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| -a |
|
||||
| --slim |
|
||||
| <param1> |
|
||||
| <param2> |
|
||||
|
||||
Then table planet_osm_point has 1475 rows
|
||||
And table planet_osm_line has 3297 rows
|
||||
And table planet_osm_roads has 380 rows
|
||||
And table planet_osm_polygon has 4278 rows
|
||||
|
||||
Examples:
|
||||
| param1 | param2 |
|
||||
| -k | |
|
||||
| -j | |
|
||||
| -j | -x |
|
||||
| --hstore-add-index | --hstore |
|
||||
|
||||
|
||||
Scenario: Simple updates with lua tagtransform
|
||||
Given the default lua tagtransform
|
||||
When running osm2pgsql pgsql with parameters
|
||||
| --slim |
|
||||