Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgrade and migration tests #588

Merged
merged 4 commits into from
Sep 4, 2024
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
3 changes: 2 additions & 1 deletion 12/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:12 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
25 changes: 2 additions & 23 deletions 12/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -345,13 +331,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
3 changes: 2 additions & 1 deletion 13/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ RUN { yum -y module enable postgresql:13 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 13/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:13 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 13/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:13 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
25 changes: 2 additions & 23 deletions 13/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -345,13 +331,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
25 changes: 2 additions & 23 deletions 14/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -345,13 +331,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
3 changes: 2 additions & 1 deletion 15/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ RUN { yum -y module enable postgresql:15 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 15/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:15 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 15/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:15 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
25 changes: 2 additions & 23 deletions 15/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -345,13 +331,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
3 changes: 2 additions & 1 deletion 16/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ RUN { yum -y module enable postgresql:16 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 16/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:16 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
3 changes: 2 additions & 1 deletion 16/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:16 || :; } && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
25 changes: 2 additions & 23 deletions 16/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -345,13 +331,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
3 changes: 2 additions & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ RUN {{ spec.environment_setup }}
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
mkdir -p /run/postgresql && \
/usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql

# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
Expand Down
25 changes: 2 additions & 23 deletions src/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,8 @@ run_pgupgrade ()
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
new_raw_version=${POSTGRESQL_VERSION//\./}

if test "$old_raw_version" = 92; then
old_collection=postgresql92
else
old_collection=rh-postgresql$old_raw_version
fi

# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin

PGDATA_new="${PGDATA}-new"

Expand All @@ -346,13 +332,6 @@ run_pgupgrade ()
# anyways
set +u

# we need to have the old SCL enabled, otherwise the $old_pgengine is not
# working. The scl_source script doesn't pay attention to non-zero exit
# statuses, so use 'set +e'.
set +e
source scl_source enable $old_collection
set -e

case $POSTGRESQL_UPGRADE in
copy) # we accept this
;;
Expand Down
6 changes: 3 additions & 3 deletions test/pagila.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I don't think this is a good idea long term (and why the separate issue was created) is that since we are linking to a specific version on the repository that is not supported anymore, the link can stop working anytime.

Silently missing, this is resolved with the check that the download succeeded, which is a great addition!

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ die() { echo "$*" >&2 ; exit 1; }
test -z "$CID" && die "Please specify \$CID variable"
# test -d common || die "Please run me from git root directory"

pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/
pagila_koji=https://kojipkgs.fedoraproject.org//packages/pagila/0.10.1/3.el7/noarch/
pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
pagila=$pagila_mirror$pagila_base
pagila=$pagila_koji$pagila_base
pagila_file="$PWD/postgresql-container-pagila.sql"
pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae802701

Expand All @@ -20,7 +20,7 @@ pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae80270
test ! -f "$pagila_file" || exit 0

set -o pipefail
curl -s "$pagila" > "$pagila_base"
curl -s "$pagila" > "$pagila_base" || die "ERROR: Could not download $pagila"
for file in ./usr/share/pagila/pagila-schema.sql \
./usr/share/pagila/pagila-data.sql \
./usr/share/pagila/pagila-insert-data.sql ; \
Expand Down
Loading