Skip to content

Commit

Permalink
Add pgbouncer v1.23 to tested versions (#19534)
Browse files Browse the repository at this point in the history
  • Loading branch information
nubtron authored Feb 7, 2025
1 parent 3c32bea commit 7636362
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
12 changes: 11 additions & 1 deletion pgbouncer/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@

[[envs.default.matrix]]
python = ["3.12"]
version = ["1.7", "1.8", "1.12"]
version = ["1.7", "1.8", "1.12", "1.23"]

[envs.default.env-vars]
DDEV_SKIP_GENERIC_TAGS_CHECK = "true"

[envs.default.overrides]
matrix.version.env-vars = [
# 1.7
{ key = "PGBOUNCER_VERSION", value = "1.7.2", if = ["1.7"] },
{ key = "PGBOUNCER_IMAGE_TAG", value = "pgbouncer_1_7", if = ["1.7"] },
{ key = "POSTGRES_IMAGE_TAG", value = "13.4", if = ["1.7"] },
# 1.8
{ key = "PGBOUNCER_VERSION", value = "1.8.1", if = ["1.8"] },
{ key = "PGBOUNCER_IMAGE_TAG", value = "pgbouncer_1_8", if = ["1.8"] },
{ key = "POSTGRES_IMAGE_TAG", value = "13.4", if = ["1.8"] },
# 1.12
{ key = "PGBOUNCER_VERSION", value = "1.12.0", if = ["1.12"] },
{ key = "PGBOUNCER_IMAGE_TAG", value = "1.12.0", if = ["1.12"] },
{ key = "POSTGRES_IMAGE_TAG", value = "13.4", if = ["1.12"] },
# 1.23
{ key = "PGBOUNCER_VERSION", value = "1.23.1", if = ["1.23"] },
{ key = "PGBOUNCER_IMAGE_TAG", value = "1.23.1", if = ["1.23"] },
{ key = "POSTGRES_IMAGE_TAG", value = "15.5", if = ["1.23"] },
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: "postgres:13.4"
image: "postgres:${POSTGRES_IMAGE_TAG}"
environment:
POSTGRES_PASSWORD: d@tadog
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: "postgres:13.4"
image: "postgres:${POSTGRES_IMAGE_TAG}"
environment:
POSTGRES_PASSWORD: d@tadog
volumes:
Expand Down
27 changes: 27 additions & 0 deletions pgbouncer/tests/compose/docker-compose-v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
postgres:
image: "postgres:${POSTGRES_IMAGE_TAG}"
environment:
POSTGRES_PASSWORD: d@tadog
volumes:
- ${TEST_RESOURCES_PATH}/pg:/docker-entrypoint-initdb.d
ports:
- "5432:5432"

pgbouncer:
image: "bitnami/pgbouncer:${PGBOUNCER_IMAGE_TAG}"
environment:
POSTGRESQL_USERNAME: postgres
POSTGRESQL_PASSWORD: d@tadog
POSTGRESQL_HOST: postgres
POSTGRESQL_PORT: 5432
PGBOUNCER_PORT: 6432
PGBOUNCER_DATABASE: datadog_test
PGBOUNCER_STATS_USERS: datadog
PGBOUNCER_LOG_CONNECTIONS: 1
PGBOUNCER_LOG_DISCONNECTIONS: 1

ports:
- "6432:6432"
depends_on:
- postgres
17 changes: 13 additions & 4 deletions pgbouncer/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,25 @@ def container_up(service_name, port):
)


def select_docker_compose_file(env_version):
"""
Select the appropriate docker compose file based on the tested version of pgbouncer
"""
if env_version < version.parse('1.10'):
return 'docker-compose-v1.yml'
if env_version < version.parse('1.23'):
return 'docker-compose-v2.yml'
# Version 1.23 and above
return 'docker-compose-v3.yml'


@pytest.fixture(scope="session")
def dd_environment():
"""
Start postgres and install pgbouncer.
If there's any problem executing `docker compose`, let the exception bubble up.
"""
compose_file = 'docker-compose.yml'
env_version = common.get_version_from_env()
if env_version < version.parse('1.10'):
compose_file = 'docker-compose-old.yml'
compose_file = select_docker_compose_file(common.get_version_from_env())

with docker_run(
compose_file=os.path.join(HERE, 'compose', compose_file),
Expand Down

0 comments on commit 7636362

Please sign in to comment.