diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8 index c9b76963..95bd17de 100644 --- a/12/Dockerfile.rhel8 +++ b/12/Dockerfile.rhel8 @@ -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 \ diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh index f480fa2b..0486c735 100644 --- a/12/root/usr/share/container-scripts/postgresql/common.sh +++ b/12/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s index 075839d2..ab81c7bc 100644 --- a/13/Dockerfile.c9s +++ b/13/Dockerfile.c9s @@ -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 \ diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8 index b6e39c72..93dae539 100644 --- a/13/Dockerfile.rhel8 +++ b/13/Dockerfile.rhel8 @@ -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 \ diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9 index a53a917f..31ba1775 100644 --- a/13/Dockerfile.rhel9 +++ b/13/Dockerfile.rhel9 @@ -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 \ diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh index ce9a8e92..369fd133 100644 --- a/13/root/usr/share/container-scripts/postgresql/common.sh +++ b/13/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh index 058ebfac..70ff0766 100644 --- a/14/root/usr/share/container-scripts/postgresql/common.sh +++ b/14/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s index 25ab942f..b13e8303 100644 --- a/15/Dockerfile.c9s +++ b/15/Dockerfile.c9s @@ -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 \ diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8 index 09304483..bb278bcb 100644 --- a/15/Dockerfile.rhel8 +++ b/15/Dockerfile.rhel8 @@ -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 \ diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9 index 23566a5b..f59932a1 100644 --- a/15/Dockerfile.rhel9 +++ b/15/Dockerfile.rhel9 @@ -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 \ diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh index e15bea30..76a2eb0f 100644 --- a/15/root/usr/share/container-scripts/postgresql/common.sh +++ b/15/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s index 7eafdcf5..b5f84829 100644 --- a/16/Dockerfile.c9s +++ b/16/Dockerfile.c9s @@ -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 \ diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8 index 510b8f10..adf4b0f4 100644 --- a/16/Dockerfile.rhel8 +++ b/16/Dockerfile.rhel8 @@ -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 \ diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9 index a81820a1..030fa59b 100644 --- a/16/Dockerfile.rhel9 +++ b/16/Dockerfile.rhel9 @@ -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 \ diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh index c7306a3b..fdb4410e 100644 --- a/16/root/usr/share/container-scripts/postgresql/common.sh +++ b/16/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/common b/common index 1e271d8d..6f1b33a3 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 1e271d8d077833ceed1bc0fcb1eb9629ea5ea410 +Subproject commit 6f1b33a34c353520f4a8fd1906b4f24b13d10d86 diff --git a/src/Dockerfile b/src/Dockerfile index 3d020c1c..7b6ac535 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -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 \ diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh index 7ca09dce..bdad9f9b 100644 --- a/src/root/usr/share/container-scripts/postgresql/common.sh +++ b/src/root/usr/share/container-scripts/postgresql/common.sh @@ -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" @@ -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 ;; diff --git a/test/pagila.sh b/test/pagila.sh index 2068de68..36c89a94 100755 --- a/test/pagila.sh +++ b/test/pagila.sh @@ -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 @@ -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 ; \ diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh index bb240df8..3bc6749d 100644 --- a/test/pg-test-lib.sh +++ b/test/pg-test-lib.sh @@ -54,14 +54,19 @@ data_pagila_check () 2' # Deliberately moving heredoc into the container, otherwise it does not work # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324 - local output=$(docker exec -i "$CID" bash -c "psql -tA </dev/null || : ) - test "$exp_output" = "$output" \ - || error "Unexpected output: '$output', expected: '$exp_output'" + test "$exp_output" = "$output" && return + sleep 1 + done + error "Unexpected output: '$output', expected: '$exp_output', and/or we waited too long" } data_empty_create () @@ -82,11 +87,17 @@ data_empty_check () 3' # Deliberately moving heredoc into the container, otherwise it does not work # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324 - local output=$(docker exec -i "$CID" bash -c "psql -tA </dev/null || : ) - test "$exp_output" = "$output" || error "Unexpected output '$output'" + test "$exp_output" = "$output" && return + sleep 1 + done + error "Unexpected output '$output', expected: '$exp_output', and/or we waited too long" } # wait_for_postgres CID @@ -105,9 +116,9 @@ wait_for_postgres () output=$(docker exec -i "$cid" bash -c \ "psql -h localhost -tA -c 'select 1;' 2>/dev/null || :") case $output in - 1*) return ;; + 1*) debug "server up" ; return ;; "") ;; - *) echo "$output" ; false ;; + *) debug "server down" ; echo "$output" ; false ;; esac sleep 1 counter=$(( counter + 1 )) diff --git a/test/run_test b/test/run_test index e0557a64..2c0c52f9 100755 --- a/test/run_test +++ b/test/run_test @@ -686,14 +686,33 @@ run_upgrade_test () { local ret=0 - local upgrade_path="none 12 13 15 16 none" prev= act= + local upgrade_path= prev= act= + case $OS in + rhel8) + upgrade_path="none 12 13 15 16 none" + ;; + rhel9|c9s) + upgrade_path="none 13 15 16 none" + ;; + rhel10|c10s) + upgrade_path="none 13 15 16 none" + ;; + fedora) + upgrade_path="none 12 13 14 15 16 none" + ;; + *) + echo "unsupported OS variable" >&2 + return 1 + ;; + esac + for act in $upgrade_path; do if test "$act" = $VERSION; then break fi prev=$act done - test "$prev" != none + test "$prev" != none || return 0 # Check if the previous image is available in the registry docker pull "$(get_image_id "$prev:remote")" || return 0 diff --git a/test/run_upgrade_test b/test/run_upgrade_test index 9e194981..410d0cdf 100755 --- a/test/run_upgrade_test +++ b/test/run_upgrade_test @@ -29,6 +29,7 @@ background_container () { CID=$(eval "docker run -d $2 $1 $3") test -n "$CID" + info "Started container $CID" >&2 } # run_server DATADIR IMAGE_ID DOCKER_ARGS