Skip to content

Commit 1ca9eba

Browse files
authored
pg-cdc test: Fix certificate generation process for tests (#35751)
Follow-up to #35487 Causing test failures in main, see for example: https://buildkite.com/materialize/test/builds/119386#019d2eee-d56c-4bd2-8d5e-409525b0a147 ``` pg-cdc-ssl-ca-bundle.td:38:1: executing query failed: db error: ERROR: error performing TLS handshake: error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:2091:: self-signed certificate in certificate chain: error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:2091:: error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:2091: ```
1 parent 64189bf commit 1ca9eba

File tree

7 files changed

+39
-5
lines changed

7 files changed

+39
-5
lines changed

test/legacy-upgrade/mzcompose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Zookeeper(),
4242
Kafka(),
4343
SchemaRegistry(),
44-
Postgres(),
44+
Postgres(volumes=["secrets:/certs:ro"]),
4545
MySql(),
4646
Cockroach(setup_materialize=True, in_memory=True),
4747
# Overridden below

test/pg-cdc-old-syntax/mzcompose.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def create_postgres(
105105
else:
106106
image = f"postgres:{pg_version}"
107107

108-
return Postgres(image=image, extra_command=extra_command)
108+
return Postgres(
109+
image=image, extra_command=extra_command, volumes=["secrets:/certs:ro"]
110+
)
109111

110112

111113
def get_testdrive_ssl_args(c: Composition):

test/pg-cdc/mzcompose.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def create_postgres(
9292
else:
9393
image = f"postgres:{pg_version}"
9494

95-
return Postgres(image=image, extra_command=extra_command)
95+
return Postgres(
96+
image=image, extra_command=extra_command, volumes=["secrets:/certs:ro"]
97+
)
9698

9799

98100
SERVICES = [

test/platform-checks/mzcompose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def create_mzs(
102102
Minio(setup_materialize=True, additional_directories=["copytos3"]),
103103
Azurite(),
104104
Mc(),
105-
Postgres(),
105+
Postgres(volumes=["secrets:/certs:ro"]),
106106
MySql(),
107107
SqlServer(),
108108
Zookeeper(),

test/postgres/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ RUN apt-get update --fix-missing && TZ=UTC DEBIAN_FRONTEND=noninteractive apt-ge
1818
&& rm -rf /var/lib/apt/lists/* \
1919
&& rm -rf /usr/share/doc/* /usr/share/man/* /usr/share/info/* /usr/share/locale/* /var/cache/* /var/log/*
2020

21+
# Bake in certs from test-certs as a build-time default.
2122
COPY --chown=postgres --from=certs /secrets/* /share/secrets/
2223
COPY pg_hba.conf /share/conf/pg_hba.conf
2324
COPY setup-postgres.sh /docker-entrypoint-initdb.d/setup-postgres.sh
25+
COPY entrypoint-wrapper.sh /usr/local/bin/entrypoint-wrapper.sh
26+
27+
ENTRYPOINT ["entrypoint-wrapper.sh"]
28+
CMD ["postgres"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright Materialize, Inc. and contributors. All rights reserved.
4+
#
5+
# Use of this software is governed by the Business Source License
6+
# included in the LICENSE file at the root of this repository.
7+
#
8+
# As of the Change Date specified in that file, in accordance with
9+
# the Business Source License, use of this software will be governed
10+
# by the Apache License, Version 2.0.
11+
12+
# Override baked-in TLS certificates with runtime certs from the test-certs
13+
# container (shared via the secrets volume at /certs). This ensures postgres
14+
# always uses the same CA that tests read from the test-certs container,
15+
# eliminating mismatches when Docker images are rebuilt independently.
16+
17+
set -euo pipefail
18+
19+
if [ -f /certs/postgres.crt ]; then
20+
cp /certs/* /share/secrets/
21+
chown -R postgres:postgres /share/secrets
22+
chmod 600 /share/secrets/postgres.key
23+
fi
24+
25+
exec docker-entrypoint.sh "$@"

test/ssh-connection/mzcompose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
Materialized(),
4141
Testdrive(consistent_seed=True),
4242
SshBastionHost(),
43-
Postgres(),
43+
Postgres(volumes=["secrets:/certs:ro"]),
4444
TestCerts(),
4545
Redpanda(),
4646
MySql(),

0 commit comments

Comments
 (0)