Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/actions/ubuntu-prerequisites/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ runs:
postgresql-${POSTGRESQL_VERSION}-postgis-${POSTGIS_VERSION} \
postgresql-${POSTGRESQL_VERSION}-postgis-${POSTGIS_VERSION}-scripts \
postgresql-client postgresql-contrib-${POSTGRESQL_VERSION} \
python3-psycopg2 \
python3-setuptools \
zlib1g-dev
pip3 install behave osmium
if [ "$CC" = clang-8 ]; then sudo apt-get install -yq --no-install-suggests --no-install-recommends clang-8; fi
if [ "$PSYCOPG" = "2"]; then
sudo apt-get install -yq --no-install-suggests --no-install-recommends python3-psycopg2
else
pip3 install psycopg
fi
shell: bash

- name: Install Lua
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
POSTGRESQL_VERSION: 9.6
POSTGIS_VERSION: 2.5
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -75,6 +76,7 @@ jobs:
POSTGRESQL_VERSION: 9.6
POSTGIS_VERSION: 2.5
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -93,6 +95,7 @@ jobs:
POSTGRESQL_VERSION: 10
POSTGIS_VERSION: 3
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -111,6 +114,7 @@ jobs:
POSTGRESQL_VERSION: 11
POSTGIS_VERSION: 2.5
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -128,6 +132,7 @@ jobs:
POSTGRESQL_VERSION: 12
POSTGIS_VERSION: 2.5
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -146,6 +151,7 @@ jobs:
POSTGRESQL_VERSION: 13
POSTGIS_VERSION: 3
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -164,6 +170,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -182,6 +189,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: off
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -200,6 +208,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -217,6 +226,7 @@ jobs:
POSTGRESQL_VERSION: 13
POSTGIS_VERSION: 2.5
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -232,6 +242,7 @@ jobs:
POSTGRESQL_VERSION: 13
POSTGIS_VERSION: 2.5
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -249,6 +260,7 @@ jobs:
POSTGRESQL_VERSION: 14
POSTGIS_VERSION: 3
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -267,6 +279,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -285,6 +298,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: off
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -303,6 +317,7 @@ jobs:
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -321,6 +336,7 @@ jobs:
POSTGRESQL_VERSION: 14
POSTGIS_VERSION: 3
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -337,6 +353,7 @@ jobs:
POSTGRESQL_VERSION: 14
POSTGIS_VERSION: 3
BUILD_TYPE: Release
PSYCOPG: 2

steps:
- uses: actions/checkout@v3
Expand All @@ -355,6 +372,7 @@ jobs:
POSTGIS_VERSION: 3
CPP_VERSION: 20
BUILD_TYPE: Debug
PSYCOPG: 3

steps:
- uses: actions/checkout@v3
Expand All @@ -373,6 +391,7 @@ jobs:
POSTGIS_VERSION: 3
CPP_VERSION: 20
BUILD_TYPE: Debug
PSYCOPG: 3

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion scripts/osm2pgsql-replication
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DBConnection:
host=args.host, port=args.port,
fallback_application_name="osm2pgsql-replication")

self.name = self.conn.get_dsn_parameters()['dbname']
self.name = self.conn.info.dbname

def __enter__(self):
return self
Expand Down
18 changes: 13 additions & 5 deletions tests/bdd/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
from importlib.machinery import SourceFileLoader

from behave import *
import psycopg2
from psycopg2 import sql
try:
import psycopg2 as psycopg
from psycopg2 import sql
except ImportError:
import psycopg
from psycopg import sql


from steps.geometry_factory import GeometryFactory
from steps.replication_server_mock import ReplicationServerMock
Expand Down Expand Up @@ -44,14 +49,18 @@ def _connect_db(context, dbname):
object as a context manager that automatically closes.
Note that the connection does not commit automatically.
"""
return closing(psycopg2.connect(dbname=dbname))
if psycopg.__version__.startswith('2'):
conn = psycopg.connect(dbname=dbname)
conn.autocommit = True
return closing(conn)

return psycopg.connect(dbname=dbname, autocommit=True)


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))
Expand Down Expand Up @@ -136,7 +145,6 @@ def test_db(context, **kwargs):
_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')
Expand Down
6 changes: 5 additions & 1 deletion tests/bdd/steps/steps_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import re
from typing import Iterable

from psycopg2 import sql
try:
from psycopg2 import sql
except ImportError:
from psycopg import sql


@given("the database schema (?P<schema>.+)")
def create_db_schema(context, schema):
Expand Down