Skip to content

Commit 3c8dbc8

Browse files
authored
Add so files from the specified version to the test image (#180)
Add the library files from the latest minor release to exttester image. These files will be used in mixed version testing, see draft PR citusdata/citus#8369 Tested locally for 17.7 ``` make build-exttester-17.7 // in container ls /opt/citus-versions/v13.2.0/ citus.so citus_columnar.so citus_decoders citus_pgoutput.so citus_wal2json.so ``` Slight increase in the image size: ``` ghcr.io/citusdata/exttester 17.7-dev-15cd08f ae73e573b28d 7 seconds ago 3.02GB ghcr.io/citusdata/exttester 17.7-dev-076d6fb be3fc5177d09 3 minutes ago 3.05GB // from this PR ``` See related PR in citus repo, testing the dev image as well : citusdata/citus#8390
1 parent 15cd08f commit 3c8dbc8

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

circleci/images/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ CITUS_UPGRADE_VERSIONS_17=v13.2.0
2626
# Function to get Citus versions for a specific PG major version
2727
get_citus_versions = $(CITUS_UPGRADE_VERSIONS_$(1))
2828

29+
# Function to get the last Citus version for a specific PG major version
30+
get_last_citus_version = $(lastword $(CITUS_UPGRADE_VERSIONS_$(1)))
31+
2932
# code below creates targets for all postgres versions in PG_VERSIONS
3033
define make-image-targets
3134
# $1 = PG_VERSION
@@ -52,12 +55,12 @@ push-all:: push-extbuilder-$1
5255
push-extbuilder-all:: push-extbuilder-$1
5356

5457
build-exttester-$1:
55-
docker build \
56-
exttester/ \
58+
docker build . \
5759
-f exttester/Dockerfile \
5860
--build-arg=PG_VERSION=$1 \
5961
--build-arg=PG_MAJOR=$2 \
6062
--build-arg=PG_VERSION_CLEAN=$3 \
63+
--build-arg=CITUS_VERSION="$(call get_last_citus_version,$2)" \
6164
--tag=${DOCKER_REPO}/exttester:$3${TAG_SUFFIX}
6265

6366
build-all:: build-exttester-$1

circleci/images/citusupgradetester/files/sbin/build-citus

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ build_ext() {
5050

5151
cd "${installdir}" && find . -type f -print > "${builddir}/files.lst"
5252
tar cvf "${basedir}/install-pg${pg_major}-citus${citus_version}.tar" `cat ${builddir}/files.lst`
53-
54-
cd "${builddir}" && rm -rf install files.lst && make clean
53+
find usr/lib/postgresql/${pg_major}/lib -type f -name '*.so' -printf '%P\n' > "${builddir}/so-files.lst"
54+
tar cvf "${basedir}/so-pg${pg_major}-citus${citus_version}.tar" -C usr/lib/postgresql/${pg_major}/lib -T "${builddir}/so-files.lst"
55+
cd "${builddir}" && rm -rf install files.lst so-files.lst && make clean
5556
}
5657
for citus_version in ${CITUS_VERSIONS}
5758
do

circleci/images/exttester/Dockerfile

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RUN tar jxf "postgresql-${PG_VERSION_CLEAN}.tar.bz2"
5050

5151
# apply optional patches that might be required for a successful testsuite
5252
WORKDIR /build/postgresql-${PG_VERSION_CLEAN}/
53-
COPY patches/ patches/
53+
COPY exttester/patches/ patches/
5454
RUN <<'EOF'
5555
# apply postgres patches
5656

@@ -84,7 +84,7 @@ COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/build/src/te
8484
COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/src/test/regress/ usr/lib/postgresql/${PG_MAJOR}/lib/regress/
8585
RUN rm -rf usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.c usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.h
8686

87-
FROM buildpack-deps:bullseye
87+
FROM buildpack-deps:bullseye AS setup-environment
8888

8989
# add unpriviliged user for tests
9090
RUN useradd -ms /bin/bash circleci
@@ -137,13 +137,15 @@ ENV PATH="/root/.cargo/bin:${PATH}"
137137
RUN cpanm install IPC::Run
138138

139139
# make special locales available
140-
COPY locale.gen /etc/locale.gen
140+
COPY exttester/locale.gen /etc/locale.gen
141141
RUN locale-gen
142142

143143
ARG PG_VERSION
144144
ARG PG_MAJOR
145+
ARG CITUS_VERSION
145146
ENV PG_VERSION=$PG_VERSION
146147
ENV PG_MAJOR=$PG_MAJOR
148+
ENV CITUS_VERSION=$CITUS_VERSION
147149

148150
RUN <<'EOF'
149151
# install postgres ecosystem for pg version: $PG_VERSION
@@ -180,7 +182,40 @@ ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin/:$PATH
180182
# setup /var/run/postgresql for use with circleci
181183
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
182184

185+
186+
FROM setup-environment AS build-citus
187+
188+
ENV CITUS_VERSIONS=$CITUS_VERSION
189+
190+
WORKDIR /build-citus/
191+
COPY citusupgradetester/files/sbin/build-citus .
192+
RUN if [ -n "${CITUS_VERSION}" ]; then ./build-citus; else echo "Skipping citus build - CITUS_VERSION not set"; fi
193+
194+
195+
FROM setup-environment
196+
197+
ARG CITUS_VERSION
198+
ARG PG_VERSION
199+
ARG PG_MAJOR
200+
ENV CITUS_VERSION=$CITUS_VERSION
201+
ENV PG_MAJOR=$PG_MAJOR
202+
ENV PG_VERSION=$PG_VERSION
203+
183204
# copy the collected files from the collection container at once into the final container
184205
COPY --from=dev-tools-collection /collect/ /
185206

207+
# copy citus so files from the build-citus stage
208+
COPY --from=build-citus /build-citus/ /tmp/build-citus/
209+
210+
# Extract conditionally in shell
211+
RUN <<'EOF'
212+
set -eux
213+
if [ -n "${CITUS_VERSION}" ] && [ -f "/tmp/build-citus/so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar" ]; then
214+
mkdir -p /opt/citus-versions/${CITUS_VERSION}
215+
cd /opt/citus-versions/${CITUS_VERSION}
216+
tar xvf /tmp/build-citus/so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar
217+
fi
218+
EOF
219+
RUN rm -rf /tmp/build-citus/
220+
186221
WORKDIR /home/circleci

0 commit comments

Comments
 (0)