From 1347912b498ec160ee9ded5d7bed19b0b3761f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Wed, 1 Oct 2025 13:13:40 +0300 Subject: [PATCH 1/8] Add CI and CI scripts --- .github/workflows/CI.yml | 86 +++++++++++++++++++++++++++++++ GitHubActions/README.md | 13 +++++ GitHubActions/build_postgis.sh | 41 +++++++++++++++ GitHubActions/build_postgres.sh | 42 +++++++++++++++ GitHubActions/build_redis_fdw.sh | 35 +++++++++++++ GitHubActions/detect_targets.sh | 30 +++++++++++ GitHubActions/download_postgis.sh | 28 ++++++++++ GitHubActions/env.sh | 20 +++++++ GitHubActions/execute_test.sh | 61 ++++++++++++++++++++++ GitHubActions/install_locales.sh | 22 ++++++++ GitHubActions/install_redis.sh | 23 +++++++++ 11 files changed, 401 insertions(+) create mode 100644 .github/workflows/CI.yml create mode 100644 GitHubActions/README.md create mode 100644 GitHubActions/build_postgis.sh create mode 100644 GitHubActions/build_postgres.sh create mode 100644 GitHubActions/build_redis_fdw.sh create mode 100644 GitHubActions/detect_targets.sh create mode 100644 GitHubActions/download_postgis.sh create mode 100644 GitHubActions/env.sh create mode 100644 GitHubActions/execute_test.sh create mode 100644 GitHubActions/install_locales.sh create mode 100644 GitHubActions/install_redis.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..418432d --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,86 @@ +name: Redis FDW test + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - main +jobs: + detect-pgversion: + runs-on: ubuntu-22.04 + outputs: + pgversion: ${{ steps.detect-pgversion.outputs.targets }} + steps: + - uses: actions/checkout@v4 + + - name: detect-pgversion + id: detect-pgversion + run: | + targets=`bash GitHubActions/detect_targets.sh` + echo "targets=$targets" >> $GITHUB_OUTPUT + + test: + needs: detect-pgversion + env: + POSTGIS_VERSION : "3.4.2" + HTTP_PROXY: "" + HTTPS_PROXY: "" + HIREDIS_FOR_TESTING_DIR: "/opt/hiredis_testing" + strategy: + fail-fast: false + matrix: + pg: ${{ fromJSON(needs.detect-pgversion.outputs.pgversion) }} + config: ["default", "postgis"] + + name: Test on PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: tar + run: tar zcvf redis_fdw.tar.gz ./* + + - name: set_proxy + run: bash GitHubActions/env.sh + + - name: download PostGIS, ${{ matrix.config }} mode + run: | + if [[ "${{ matrix.config }}" == "postgis" ]]; then + bash GitHubActions/download_postgis.sh ${{ env.POSTGIS_VERSION }} + fi + + - name: install locales + run: bash GitHubActions/install_locales.sh + + - name: build PostgreSQL ${{ matrix.pg }} + run: bash GitHubActions/build_postgres.sh ${{ matrix.pg }} + + - name: install Redis, ${{ matrix.config }} mode + run: bash GitHubActions/install_redis.sh ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + + - name: build PostGIS ${{ env.POSTGIS_VERSION }} for PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode + run: | + if [[ "${{ matrix.config }}" == "postgis" ]]; then + bash GitHubActions/build_postgis.sh ${{ matrix.pg }} ${{ env.POSTGIS_VERSION }} + fi + + - name: build redis_fdw, ${{ matrix.config }} mode + run: | + bash GitHubActions/build_redis_fdw.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + + - name: execute redis_fdw test + run: bash GitHubActions/execute_test.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + + - name: download output files (regression.diffs) + if: failure() + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.pg }}-${{ matrix.config }}-test-results + path: | + workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/regression.diffs + workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/regression.out + workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/results + retention-days: 7 + diff --git a/GitHubActions/README.md b/GitHubActions/README.md new file mode 100644 index 0000000..641cb90 --- /dev/null +++ b/GitHubActions/README.md @@ -0,0 +1,13 @@ +# CI environment of redis_fdw. + +Tests will be executed automatically when commited to main/master branch and when a pull request was opened/updated. +It is realized by using GitHub actions. + +The CI process is defined in .github/workflows/CI.yml file. +Scripts in this directory (GitHubActions/*.sh) are referred by CI.yml. + +The regression test will be executed for multi-versions of PostgreSQL. +Target versions are determined automatically based on directory names in "expected" directory. + +If the regression test failed, test result files (result directory, regression.diff amd regression.out) are uploaded as artifacts. +7 days later, artifact files will be deleted. diff --git a/GitHubActions/build_postgis.sh b/GitHubActions/build_postgis.sh new file mode 100644 index 0000000..348646b --- /dev/null +++ b/GitHubActions/build_postgis.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +################################################################################ +# +# This script downloads PostGIS from the official web site into ./workdir +# then builds it. +# +# Usage: ./build_postgis.sh pg_version postgis_version +# pg_version is a PostgreSQL version to be installed like 16.0. +# postgis_version is a PostGIS version to be installed. +# +# Requirements +# - be able to connect to the PostGIS official web site by wget. +# +################################################################################ + +POSTGRESQL_VERSION=$1 +POSTGIS_VERSION=$2 + +# Install necessary dependencies +sudo apt update +sudo apt install -y build-essential libxml2-dev libgeos-dev libproj-dev libgdal-dev libjson-c-dev libprotobuf-c-dev protobuf-c-compiler + +cd ./workdir +# Download and compile PostGIS +cp -vr postgis "postgresql-${POSTGRESQL_VERSION}/contrib" +( +cd "postgresql-${POSTGRESQL_VERSION}/contrib/postgis" +echo " - PostGIS directory" +GEOS_CONFIG_PATH=$(which geos-config) +export LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH" +./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=$GEOS_CONFIG_PATH +make +sudo make install +) + +( +cd "postgresql-${POSTGRESQL_VERSION}/contrib/hstore" +make +sudo make install +) diff --git a/GitHubActions/build_postgres.sh b/GitHubActions/build_postgres.sh new file mode 100644 index 0000000..fca424d --- /dev/null +++ b/GitHubActions/build_postgres.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################ +# +# This script downloads PostgreSQL from the official web site into ./workdir +# then builds it. +# +# Usage: ./build_postgres.sh pg_version [configure_options] +# pg_version is a PostgreSQL version to be installed like 17.0. +# configure_options are a list of option for postgres server. +# +# Requirements +# - be able to connect to the PostgreSQL official web site by curl. +# +################################################################################ + +POSTGRESQL_VERSION=$1 +CONFIGURE_OPTIONS="" + +while (( "$#" )); do + CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $2" + shift +done + +mkdir -p ./workdir +cd ./workdir +adr="https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.bz2"; +echo "PG version URL: + $adr" +curl -O "$adr" +tar xjf postgresql-${POSTGRESQL_VERSION}.tar.bz2 +cd postgresql-${POSTGRESQL_VERSION} + +if [ -z "$CONFIGURE_OPTIONS" ]; then + ./configure +else + ./configure $CONFIGURE_OPTIONS +fi + +make +sudo make install +sudo chown -R $USER /usr/local/pgsql diff --git a/GitHubActions/build_redis_fdw.sh b/GitHubActions/build_redis_fdw.sh new file mode 100644 index 0000000..bcc34b8 --- /dev/null +++ b/GitHubActions/build_redis_fdw.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +################################################################################ +# +# This script builds redis_fdw in PostgreSQL source tree. +# +# Usage: ./build_redis_fdw.sh pg_version mode hiredis_for_testing_dir +# pg_version is a PostgreSQL version like 17.0 to be built in. +# mode is flag for redis_fdw compiler. +# hiredis_for_testing_dir: path to install directory of hiredis version for testing +# +# Requirements +# - the source code of redis_fdw is available by git clone. +# - the source code of PostgreSQL is located in ~/workdir/postgresql-{pg_version}. +# - Hiredis development package is installed in a system. +################################################################################ + +VERSION="$1" +MODE="$2" +HIREDIS_FOR_TESTING_DIR="$3" + +mkdir -p ./workdir/postgresql-${VERSION}/contrib/redis_fdw +tar zxf ./redis_fdw.tar.gz -C ./workdir/postgresql-${VERSION}/contrib/redis_fdw/ +cd ./workdir/postgresql-${VERSION}/contrib/redis_fdw + +# show locally compiled hiredis library +ls -la /usr/local/lib + +if [ "$MODE" == "postgis" ]; then + make ENABLE_GIS=1 HIREDIS_FOR_TESTING_DIR="$3" +else + make HIREDIS_FOR_TESTING_DIR="$3" +fi + +sudo make install diff --git a/GitHubActions/detect_targets.sh b/GitHubActions/detect_targets.sh new file mode 100644 index 0000000..95808e8 --- /dev/null +++ b/GitHubActions/detect_targets.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################ +# +# This script detects target PostgreSQL versions for redis_fdw testing from +# directory names in ./sql directory. Detected versions will be outputed to +# the standard output as an array of string like ["16.3","17.0"]. +# +# Usage: ./detect_targets.sh +# +# Requirements +# - there is a directory named "sql" in a curent directory. +# +################################################################################ + +dirs="./test/expected/*" +pattern="[0-9]+(\.|rc)[0-9]+" +targets="[" +for pathname in $dirs; do + if [[ "$pathname" =~ $pattern ]]; then + target=`basename $pathname` + if [ "$targets" != "[" ]; then + targets+="," + fi + targets+="\"$target\"" + fi +done +targets+="]" + +echo "$targets" diff --git a/GitHubActions/download_postgis.sh b/GitHubActions/download_postgis.sh new file mode 100644 index 0000000..bc72a20 --- /dev/null +++ b/GitHubActions/download_postgis.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +################################################################################ +# +# This script downloads PostGIS from the official web site into ./workdir +# then builds it. +# +# Usage: ./download_postgis.sh postgis_version +# postgis_version is a PostGIS version to be installed. +# +# Requirements +# - be able to connect to the PostGIS official web site by wget. +# +################################################################################ + +POSTGIS_VERSION=$1 + +mkdir -p ./workdir +cd ./workdir +pgisfile="postgis-${POSTGIS_VERSION}.tar.gz" +if [ ! -f "$pgisfile" ]; then + wget -nv "http://download.osgeo.org/postgis/source/$pgisfile" + tar -xzf "$pgisfile" + mv postgis-${POSTGIS_VERSION} postgis -v + echo "PostGIS source code directory " $(dirname $(readlink -f postgis)) +else + echo "PostGIS downloaded" +fi diff --git a/GitHubActions/env.sh b/GitHubActions/env.sh new file mode 100644 index 0000000..f607376 --- /dev/null +++ b/GitHubActions/env.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +################################################################################ +# +# This script configures apt.conf to set a proxy if an environment variable +# HTTP_PROXY or HTTPS_PROXY is set. +# +# Usage: ./env.sh +# +# Requirements +# - having superuser privileges +# +################################################################################ + +if [ -z $HTTP_PROXY ] && [ "$HTTP_PROXY" != "" ]; then + echo 'Acquire::http::proxy "$HTTP_PROXY";' | sudo tee /etc/apt/apt.conf +fi +if [ -z $HTTPS_PROXY ] && [ "$HTTPS_PROXY" != "" ]; then + echo 'Acquire::https::proxy "$HTTPS_PROXY";' | sudo tee -a /etc/apt/apt.conf +fi diff --git a/GitHubActions/execute_test.sh b/GitHubActions/execute_test.sh new file mode 100644 index 0000000..98e5684 --- /dev/null +++ b/GitHubActions/execute_test.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +################################################################################ +# +# This script executes a regression test pf redis_fdw by calling test.sh in +# redis_fdw. If all tests are passed, this script will exit successfully. +# Otherwise, it will exit with failure. + +# Usage: ./execute_test.sh pg_version mode redis_for_testing_dir +# pg_version is a PostgreSQL version to be tested like 17.0. +# mode is flag for redis_fdw compiler. +# hiredis_for_testing_dir: path to install directory of hiredis version for testing +# +# Requiremets +# - the source code of PostgreSQL is located in ./workdir/postgresql-{pg_version}. +# - the source code of redis_fdw is loacted in ./workdir/postgresql-{pg_version}/contrib/redis_fdw. +# - PostgreSQL and redis_fdw were built. +# - this script assumes that tests are passed if this file (created by executing +# the test) contains " ALL {number} tests passed" at the last or the 3rd line +# from the end. +# +################################################################################ + +VERSION=$1 +MODE="$2" +HIREDIS_FOR_TESTING_DIR="$3" + +cd ./workdir/postgresql-${VERSION}/contrib/redis_fdw + +if [ "$MODE" == "postgis" ]; then + export ENABLE_GIS=1 + + # Start postgres server + POSTGRES_HOME=/usr/local/pgsql + ${POSTGRES_HOME}/bin/initdb ${POSTGRES_HOME}/databases + ${POSTGRES_HOME}/bin/pg_ctl -D ${POSTGRES_HOME}/databases -l logfile start + + # Change the testing method + sed -i 's/make check/make installcheck/' test.sh +fi + +# Execute test script +chmod +x ./test.sh +./test.sh $MAKEFILE_OPT + +last_line=$(tail -n 1 make_check.out) +third_line_from_the_last=$(tail -n 3 make_check.out | head -n 1) + +pattern=" All [0-9]+ tests passed.+" + +if [[ "$last_line" =~ $pattern ]]; then + echo "last_line" + +elif [[ "$third_line_from_the_last" =~ $pattern ]]; then + echo "$third_line_from_the_last" +else + echo "Error : not All the tests passed" + echo "last line : '$last_line'" + echo "thierd_line_from_the_last : '$third_line_from_the_last'" + exit 1 +fi diff --git a/GitHubActions/install_locales.sh b/GitHubActions/install_locales.sh new file mode 100644 index 0000000..1d5f606 --- /dev/null +++ b/GitHubActions/install_locales.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +################################################################################ +# +# This script installs some locales and language packs used by redis_fdw +# tests in Ubuntu. +# +# Usage: ./install_locales.sh +# +# Requirements: +# - having superuser privileges +# +################################################################################ + +sudo apt-get update +sudo apt-get install locales language-pack-ja +sudo locale-gen ja_JP.EUC-JP +sudo apt-get install language-pack-ko-base language-pack-ko +sudo locale-gen ko_KR.EUC-KR +sudo apt-get install language-pack-bg-base language-pack-bg +sudo locale-gen bg_BG +sudo apt-get install libreadline8 libreadline-dev diff --git a/GitHubActions/install_redis.sh b/GitHubActions/install_redis.sh new file mode 100644 index 0000000..3e49d5a --- /dev/null +++ b/GitHubActions/install_redis.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +################################################################################ +# +# This sript installs Redis environment for Redis FDW testing +# +# Usage: ./install_redis.sh version year testing_mode hiredis_for_testing_dir [configure_options] +# testing_mode: 'default' or 'postgis' value. +# hiredis_for_testing_dir: path to install directory of the specified hiredis version +# +# Ex) ./install_redis.sh postgis /opt/redis_testing +# +# Requirements +# - be able to connect to official repository of Ununtu +# - having superuser privileges +# +################################################################################ + +TESTING_MODE="$1" +HIREDIS_FOR_TESTING_DIR="$2" + +# libhiredis*** is a dependency of hiredis-dev +sudo apt-get install redis libhiredis-dev -y From f3fb59e546e6db3af5982548005c06e1a8d56d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Wed, 1 Oct 2025 15:20:44 +0300 Subject: [PATCH 2/8] Upd to undefined PG major version --- GitHubActions/build_postgres.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/GitHubActions/build_postgres.sh b/GitHubActions/build_postgres.sh index fca424d..15169da 100644 --- a/GitHubActions/build_postgres.sh +++ b/GitHubActions/build_postgres.sh @@ -24,12 +24,14 @@ done mkdir -p ./workdir cd ./workdir -adr="https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.bz2"; -echo "PG version URL: - $adr" -curl -O "$adr" -tar xjf postgresql-${POSTGRESQL_VERSION}.tar.bz2 -cd postgresql-${POSTGRESQL_VERSION} +#adr="https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.bz2"; +#echo "PG version URL: +# $adr" +#curl -O "$adr" +#tar xjf postgresql-${POSTGRESQL_VERSION}.tar.bz2 +#cd postgresql-${POSTGRESQL_VERSION} +git clone https://git.postgresql.org/git/postgresql.git -b "REL_${POSTGRESQL_VERSION}"; +cd "REL_${POSTGRESQL_VERSION}/postgresql"; if [ -z "$CONFIGURE_OPTIONS" ]; then ./configure From adda2f97592a62c95f796449084000b95aaba7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:19:46 +0300 Subject: [PATCH 3/8] Try primitive CI --- .github/workflows/CI.yml | 130 +++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 74 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 418432d..9522a6a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,86 +1,68 @@ -name: Redis FDW test +name: Compilable against Ubuntu packages test instead of full C complex CI + +on: [push, pull_request] -on: - workflow_dispatch: - pull_request: - push: - branches: - - master - - main jobs: - detect-pgversion: - runs-on: ubuntu-22.04 - outputs: - pgversion: ${{ steps.detect-pgversion.outputs.targets }} - steps: - - uses: actions/checkout@v4 - - - name: detect-pgversion - id: detect-pgversion - run: | - targets=`bash GitHubActions/detect_targets.sh` - echo "targets=$targets" >> $GITHUB_OUTPUT + linux: - test: - needs: detect-pgversion - env: - POSTGIS_VERSION : "3.4.2" - HTTP_PROXY: "" - HTTPS_PROXY: "" - HIREDIS_FOR_TESTING_DIR: "/opt/hiredis_testing" + runs-on: ubuntu-latest + + name: "CI" strategy: - fail-fast: false + fail-fast: true matrix: - pg: ${{ fromJSON(needs.detect-pgversion.outputs.pgversion) }} - config: ["default", "postgis"] - - name: Test on PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - - name: tar - run: tar zcvf redis_fdw.tar.gz ./* + ci: + - { PGVER: 13 } + - { PGVER: 14 } + - { PGVER: 15 } + - { PGVER: 16 } + - { PGVER: 17 } + - { PGVER: 18 } - - name: set_proxy - run: bash GitHubActions/env.sh - - - name: download PostGIS, ${{ matrix.config }} mode - run: | - if [[ "${{ matrix.config }}" == "postgis" ]]; then - bash GitHubActions/download_postgis.sh ${{ env.POSTGIS_VERSION }} - fi - - - name: install locales - run: bash GitHubActions/install_locales.sh - - - name: build PostgreSQL ${{ matrix.pg }} - run: bash GitHubActions/build_postgres.sh ${{ matrix.pg }} + steps: - - name: install Redis, ${{ matrix.config }} mode - run: bash GitHubActions/install_redis.sh ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + - name: 'Check Out' + uses: actions/checkout@v4 - - name: build PostGIS ${{ env.POSTGIS_VERSION }} for PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode - run: | - if [[ "${{ matrix.config }}" == "postgis" ]]; then - bash GitHubActions/build_postgis.sh ${{ matrix.pg }} ${{ env.POSTGIS_VERSION }} - fi + - name: 'Raise Priority for apt.postgresql.org' + run: | + cat << EOF >> ./pgdg.pref + Package: * + Pin: release o=apt.postgresql.org + Pin-Priority: 600 + EOF + sudo mv ./pgdg.pref /etc/apt/preferences.d/ + sudo apt update - - name: build redis_fdw, ${{ matrix.config }} mode - run: | - bash GitHubActions/build_redis_fdw.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + - name: 'Install PostgreSQL' + run: | + sudo apt-get purge postgresql-* + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-snapshot main ${{ matrix.ci.PGVER }}" > /etc/apt/sources.list.d/pgdg.list' + curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null + sudo apt-get update + sudo apt-get -y install postgresql-${{ matrix.ci.PGVER }} postgresql-server-dev-${{ matrix.ci.PGVER }} postgresql-client-${{ matrix.ci.PGVER }} - - name: execute redis_fdw test - run: bash GitHubActions/execute_test.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.HIREDIS_FOR_TESTING_DIR }} + - name: 'Install Redis + Hiredis' + run: | + sudo apt-get -y install libhiredis-dev redis-server - - name: download output files (regression.diffs) - if: failure() - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.pg }}-${{ matrix.config }}-test-results - path: | - workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/regression.diffs - workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/regression.out - workdir/postgresql-${{ matrix.pg }}/contrib/redis_fdw/test/results - retention-days: 7 + - name: 'Start PostgreSQL' + run: | + export PGVER=${{ matrix.ci.PGVER }} + export PGDATA=/var/lib/postgresql/$PGVER/main + export PGETC=/etc/postgresql/$PGVER/main + export PGBIN=/usr/lib/postgresql/$PGVER/bin + sudo chmod -R 755 /home/`whoami` + sudo cp ./ci/pg_hba.conf $PGETC/pg_hba.conf + sudo systemctl stop postgresql + sudo pg_ctlcluster $PGVER main start + sudo pg_lsclusters + - name: 'Build & Test' + run: | + export PATH=/usr/lib/postgresql/${{ matrix.ci.PGVER }}/bin/:$PATH + export PG_CONFIG=/usr/lib/postgresql/${{ matrix.ci.PGVER }}/bin/pg_config + export PG_CFLAGS=-Werror + make + sudo -E make PG_CONFIG=$PG_CONFIG install + PGUSER=postgres make installcheck || (cat regression.diffs && /bin/false) From 608148b5015b3e58809ffcbdf75e9e3c6e393649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:23:42 +0300 Subject: [PATCH 4/8] Create pg_hba.conf Typical PG HBA for primitive CI --- GitHubActions/pg_hba.conf | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 GitHubActions/pg_hba.conf diff --git a/GitHubActions/pg_hba.conf b/GitHubActions/pg_hba.conf new file mode 100644 index 0000000..16fda31 --- /dev/null +++ b/GitHubActions/pg_hba.conf @@ -0,0 +1,8 @@ +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all postgres trust +# IPv4 local connections: +host all postgres 127.0.0.1/32 trust +# IPv6 local connections: +host all postgres ::1/128 trust From 32a85fe0b2359f061ea6fc111f35cb85a52db999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:24:30 +0300 Subject: [PATCH 5/8] Fix pg_hba --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9522a6a..6352e27 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,7 +53,7 @@ jobs: export PGETC=/etc/postgresql/$PGVER/main export PGBIN=/usr/lib/postgresql/$PGVER/bin sudo chmod -R 755 /home/`whoami` - sudo cp ./ci/pg_hba.conf $PGETC/pg_hba.conf + sudo cp ./GitHubActions/pg_hba.conf $PGETC/pg_hba.conf sudo systemctl stop postgresql sudo pg_ctlcluster $PGVER main start sudo pg_lsclusters From 2fbdc370298962c6e1a8e9a8d23a4e01630eba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:39:58 +0300 Subject: [PATCH 6/8] Exclude PG13 from primitive CI --- .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6352e27..0ea474a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,7 +12,6 @@ jobs: fail-fast: true matrix: ci: - - { PGVER: 13 } - { PGVER: 14 } - { PGVER: 15 } - { PGVER: 16 } From 8f122dffceb1f75294985b7ef44e7656ab555a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Sat, 4 Oct 2025 06:46:32 +0300 Subject: [PATCH 7/8] Try to implement CI matrix --- .github/workflows/CI.yml | 20 ++++---- GitHubActions/README.md | 13 ------ GitHubActions/build_postgis.sh | 41 ---------------- GitHubActions/build_postgres.sh | 44 ----------------- GitHubActions/build_redis_fdw.sh | 35 -------------- GitHubActions/detect_targets.sh | 30 ------------ GitHubActions/download_postgis.sh | 28 ----------- GitHubActions/env.sh | 20 -------- GitHubActions/execute_test.sh | 61 ------------------------ GitHubActions/install_locales.sh | 22 --------- GitHubActions/install_redis.sh | 23 --------- Makefile | 17 +++++-- test/expected/nogis.out | 23 +++++++++ test/expected/postgis.out | 29 ++++++++++++ test/expected/redis_fdw.out | 78 ++++++++++++++++++++++++++++--- test/{sql => }/redis_clean | 1 - test/{sql => }/redis_setup | 4 -- test/sql/nogis.sql | 23 +++++++++ test/sql/postgis.sql | 26 +++++++++++ test/sql/redis_fdw.sql | 26 +++++++---- 20 files changed, 212 insertions(+), 352 deletions(-) delete mode 100644 GitHubActions/README.md delete mode 100644 GitHubActions/build_postgis.sh delete mode 100644 GitHubActions/build_postgres.sh delete mode 100644 GitHubActions/build_redis_fdw.sh delete mode 100644 GitHubActions/detect_targets.sh delete mode 100644 GitHubActions/download_postgis.sh delete mode 100644 GitHubActions/env.sh delete mode 100644 GitHubActions/execute_test.sh delete mode 100644 GitHubActions/install_locales.sh delete mode 100644 GitHubActions/install_redis.sh create mode 100644 test/expected/nogis.out create mode 100644 test/expected/postgis.out rename test/{sql => }/redis_clean (95%) rename test/{sql => }/redis_setup (99%) create mode 100644 test/sql/nogis.sql create mode 100644 test/sql/postgis.sql diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0ea474a..e091631 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,12 +11,8 @@ jobs: strategy: fail-fast: true matrix: - ci: - - { PGVER: 14 } - - { PGVER: 15 } - - { PGVER: 16 } - - { PGVER: 17 } - - { PGVER: 18 } + pg: ["14", "15", "16", "17", "18"] + config: ["default", "postgis"] steps: @@ -36,10 +32,11 @@ jobs: - name: 'Install PostgreSQL' run: | sudo apt-get purge postgresql-* - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-snapshot main ${{ matrix.ci.PGVER }}" > /etc/apt/sources.list.d/pgdg.list' + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-snapshot main ${{ matrix.pg }}" > /etc/apt/sources.list.d/pgdg.list' curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null sudo apt-get update - sudo apt-get -y install postgresql-${{ matrix.ci.PGVER }} postgresql-server-dev-${{ matrix.ci.PGVER }} postgresql-client-${{ matrix.ci.PGVER }} + sudo apt-get -y install postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }} postgresql-client-${{ matrix.pg }} + [ "${{ matrix.config }}" == "postgis" ] && sudo apt-get -y install postgresql-${{ matrix.pg }}-postgis-3 - name: 'Install Redis + Hiredis' run: | @@ -47,7 +44,7 @@ jobs: - name: 'Start PostgreSQL' run: | - export PGVER=${{ matrix.ci.PGVER }} + export PGVER=${{ matrix.pg }} export PGDATA=/var/lib/postgresql/$PGVER/main export PGETC=/etc/postgresql/$PGVER/main export PGBIN=/usr/lib/postgresql/$PGVER/bin @@ -59,9 +56,10 @@ jobs: - name: 'Build & Test' run: | - export PATH=/usr/lib/postgresql/${{ matrix.ci.PGVER }}/bin/:$PATH - export PG_CONFIG=/usr/lib/postgresql/${{ matrix.ci.PGVER }}/bin/pg_config + export PATH=/usr/lib/postgresql/${{ matrix.pg }}/bin/:$PATH + export PG_CONFIG=/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config export PG_CFLAGS=-Werror + [ "${{ matrix.config }}" == "postgis" ] && export ENABLE_GIS=1 make sudo -E make PG_CONFIG=$PG_CONFIG install PGUSER=postgres make installcheck || (cat regression.diffs && /bin/false) diff --git a/GitHubActions/README.md b/GitHubActions/README.md deleted file mode 100644 index 641cb90..0000000 --- a/GitHubActions/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# CI environment of redis_fdw. - -Tests will be executed automatically when commited to main/master branch and when a pull request was opened/updated. -It is realized by using GitHub actions. - -The CI process is defined in .github/workflows/CI.yml file. -Scripts in this directory (GitHubActions/*.sh) are referred by CI.yml. - -The regression test will be executed for multi-versions of PostgreSQL. -Target versions are determined automatically based on directory names in "expected" directory. - -If the regression test failed, test result files (result directory, regression.diff amd regression.out) are uploaded as artifacts. -7 days later, artifact files will be deleted. diff --git a/GitHubActions/build_postgis.sh b/GitHubActions/build_postgis.sh deleted file mode 100644 index 348646b..0000000 --- a/GitHubActions/build_postgis.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script downloads PostGIS from the official web site into ./workdir -# then builds it. -# -# Usage: ./build_postgis.sh pg_version postgis_version -# pg_version is a PostgreSQL version to be installed like 16.0. -# postgis_version is a PostGIS version to be installed. -# -# Requirements -# - be able to connect to the PostGIS official web site by wget. -# -################################################################################ - -POSTGRESQL_VERSION=$1 -POSTGIS_VERSION=$2 - -# Install necessary dependencies -sudo apt update -sudo apt install -y build-essential libxml2-dev libgeos-dev libproj-dev libgdal-dev libjson-c-dev libprotobuf-c-dev protobuf-c-compiler - -cd ./workdir -# Download and compile PostGIS -cp -vr postgis "postgresql-${POSTGRESQL_VERSION}/contrib" -( -cd "postgresql-${POSTGRESQL_VERSION}/contrib/postgis" -echo " - PostGIS directory" -GEOS_CONFIG_PATH=$(which geos-config) -export LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH" -./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=$GEOS_CONFIG_PATH -make -sudo make install -) - -( -cd "postgresql-${POSTGRESQL_VERSION}/contrib/hstore" -make -sudo make install -) diff --git a/GitHubActions/build_postgres.sh b/GitHubActions/build_postgres.sh deleted file mode 100644 index 15169da..0000000 --- a/GitHubActions/build_postgres.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script downloads PostgreSQL from the official web site into ./workdir -# then builds it. -# -# Usage: ./build_postgres.sh pg_version [configure_options] -# pg_version is a PostgreSQL version to be installed like 17.0. -# configure_options are a list of option for postgres server. -# -# Requirements -# - be able to connect to the PostgreSQL official web site by curl. -# -################################################################################ - -POSTGRESQL_VERSION=$1 -CONFIGURE_OPTIONS="" - -while (( "$#" )); do - CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $2" - shift -done - -mkdir -p ./workdir -cd ./workdir -#adr="https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.bz2"; -#echo "PG version URL: -# $adr" -#curl -O "$adr" -#tar xjf postgresql-${POSTGRESQL_VERSION}.tar.bz2 -#cd postgresql-${POSTGRESQL_VERSION} -git clone https://git.postgresql.org/git/postgresql.git -b "REL_${POSTGRESQL_VERSION}"; -cd "REL_${POSTGRESQL_VERSION}/postgresql"; - -if [ -z "$CONFIGURE_OPTIONS" ]; then - ./configure -else - ./configure $CONFIGURE_OPTIONS -fi - -make -sudo make install -sudo chown -R $USER /usr/local/pgsql diff --git a/GitHubActions/build_redis_fdw.sh b/GitHubActions/build_redis_fdw.sh deleted file mode 100644 index bcc34b8..0000000 --- a/GitHubActions/build_redis_fdw.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script builds redis_fdw in PostgreSQL source tree. -# -# Usage: ./build_redis_fdw.sh pg_version mode hiredis_for_testing_dir -# pg_version is a PostgreSQL version like 17.0 to be built in. -# mode is flag for redis_fdw compiler. -# hiredis_for_testing_dir: path to install directory of hiredis version for testing -# -# Requirements -# - the source code of redis_fdw is available by git clone. -# - the source code of PostgreSQL is located in ~/workdir/postgresql-{pg_version}. -# - Hiredis development package is installed in a system. -################################################################################ - -VERSION="$1" -MODE="$2" -HIREDIS_FOR_TESTING_DIR="$3" - -mkdir -p ./workdir/postgresql-${VERSION}/contrib/redis_fdw -tar zxf ./redis_fdw.tar.gz -C ./workdir/postgresql-${VERSION}/contrib/redis_fdw/ -cd ./workdir/postgresql-${VERSION}/contrib/redis_fdw - -# show locally compiled hiredis library -ls -la /usr/local/lib - -if [ "$MODE" == "postgis" ]; then - make ENABLE_GIS=1 HIREDIS_FOR_TESTING_DIR="$3" -else - make HIREDIS_FOR_TESTING_DIR="$3" -fi - -sudo make install diff --git a/GitHubActions/detect_targets.sh b/GitHubActions/detect_targets.sh deleted file mode 100644 index 95808e8..0000000 --- a/GitHubActions/detect_targets.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script detects target PostgreSQL versions for redis_fdw testing from -# directory names in ./sql directory. Detected versions will be outputed to -# the standard output as an array of string like ["16.3","17.0"]. -# -# Usage: ./detect_targets.sh -# -# Requirements -# - there is a directory named "sql" in a curent directory. -# -################################################################################ - -dirs="./test/expected/*" -pattern="[0-9]+(\.|rc)[0-9]+" -targets="[" -for pathname in $dirs; do - if [[ "$pathname" =~ $pattern ]]; then - target=`basename $pathname` - if [ "$targets" != "[" ]; then - targets+="," - fi - targets+="\"$target\"" - fi -done -targets+="]" - -echo "$targets" diff --git a/GitHubActions/download_postgis.sh b/GitHubActions/download_postgis.sh deleted file mode 100644 index bc72a20..0000000 --- a/GitHubActions/download_postgis.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script downloads PostGIS from the official web site into ./workdir -# then builds it. -# -# Usage: ./download_postgis.sh postgis_version -# postgis_version is a PostGIS version to be installed. -# -# Requirements -# - be able to connect to the PostGIS official web site by wget. -# -################################################################################ - -POSTGIS_VERSION=$1 - -mkdir -p ./workdir -cd ./workdir -pgisfile="postgis-${POSTGIS_VERSION}.tar.gz" -if [ ! -f "$pgisfile" ]; then - wget -nv "http://download.osgeo.org/postgis/source/$pgisfile" - tar -xzf "$pgisfile" - mv postgis-${POSTGIS_VERSION} postgis -v - echo "PostGIS source code directory " $(dirname $(readlink -f postgis)) -else - echo "PostGIS downloaded" -fi diff --git a/GitHubActions/env.sh b/GitHubActions/env.sh deleted file mode 100644 index f607376..0000000 --- a/GitHubActions/env.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script configures apt.conf to set a proxy if an environment variable -# HTTP_PROXY or HTTPS_PROXY is set. -# -# Usage: ./env.sh -# -# Requirements -# - having superuser privileges -# -################################################################################ - -if [ -z $HTTP_PROXY ] && [ "$HTTP_PROXY" != "" ]; then - echo 'Acquire::http::proxy "$HTTP_PROXY";' | sudo tee /etc/apt/apt.conf -fi -if [ -z $HTTPS_PROXY ] && [ "$HTTPS_PROXY" != "" ]; then - echo 'Acquire::https::proxy "$HTTPS_PROXY";' | sudo tee -a /etc/apt/apt.conf -fi diff --git a/GitHubActions/execute_test.sh b/GitHubActions/execute_test.sh deleted file mode 100644 index 98e5684..0000000 --- a/GitHubActions/execute_test.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script executes a regression test pf redis_fdw by calling test.sh in -# redis_fdw. If all tests are passed, this script will exit successfully. -# Otherwise, it will exit with failure. - -# Usage: ./execute_test.sh pg_version mode redis_for_testing_dir -# pg_version is a PostgreSQL version to be tested like 17.0. -# mode is flag for redis_fdw compiler. -# hiredis_for_testing_dir: path to install directory of hiredis version for testing -# -# Requiremets -# - the source code of PostgreSQL is located in ./workdir/postgresql-{pg_version}. -# - the source code of redis_fdw is loacted in ./workdir/postgresql-{pg_version}/contrib/redis_fdw. -# - PostgreSQL and redis_fdw were built. -# - this script assumes that tests are passed if this file (created by executing -# the test) contains " ALL {number} tests passed" at the last or the 3rd line -# from the end. -# -################################################################################ - -VERSION=$1 -MODE="$2" -HIREDIS_FOR_TESTING_DIR="$3" - -cd ./workdir/postgresql-${VERSION}/contrib/redis_fdw - -if [ "$MODE" == "postgis" ]; then - export ENABLE_GIS=1 - - # Start postgres server - POSTGRES_HOME=/usr/local/pgsql - ${POSTGRES_HOME}/bin/initdb ${POSTGRES_HOME}/databases - ${POSTGRES_HOME}/bin/pg_ctl -D ${POSTGRES_HOME}/databases -l logfile start - - # Change the testing method - sed -i 's/make check/make installcheck/' test.sh -fi - -# Execute test script -chmod +x ./test.sh -./test.sh $MAKEFILE_OPT - -last_line=$(tail -n 1 make_check.out) -third_line_from_the_last=$(tail -n 3 make_check.out | head -n 1) - -pattern=" All [0-9]+ tests passed.+" - -if [[ "$last_line" =~ $pattern ]]; then - echo "last_line" - -elif [[ "$third_line_from_the_last" =~ $pattern ]]; then - echo "$third_line_from_the_last" -else - echo "Error : not All the tests passed" - echo "last line : '$last_line'" - echo "thierd_line_from_the_last : '$third_line_from_the_last'" - exit 1 -fi diff --git a/GitHubActions/install_locales.sh b/GitHubActions/install_locales.sh deleted file mode 100644 index 1d5f606..0000000 --- a/GitHubActions/install_locales.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This script installs some locales and language packs used by redis_fdw -# tests in Ubuntu. -# -# Usage: ./install_locales.sh -# -# Requirements: -# - having superuser privileges -# -################################################################################ - -sudo apt-get update -sudo apt-get install locales language-pack-ja -sudo locale-gen ja_JP.EUC-JP -sudo apt-get install language-pack-ko-base language-pack-ko -sudo locale-gen ko_KR.EUC-KR -sudo apt-get install language-pack-bg-base language-pack-bg -sudo locale-gen bg_BG -sudo apt-get install libreadline8 libreadline-dev diff --git a/GitHubActions/install_redis.sh b/GitHubActions/install_redis.sh deleted file mode 100644 index 3e49d5a..0000000 --- a/GitHubActions/install_redis.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -################################################################################ -# -# This sript installs Redis environment for Redis FDW testing -# -# Usage: ./install_redis.sh version year testing_mode hiredis_for_testing_dir [configure_options] -# testing_mode: 'default' or 'postgis' value. -# hiredis_for_testing_dir: path to install directory of the specified hiredis version -# -# Ex) ./install_redis.sh postgis /opt/redis_testing -# -# Requirements -# - be able to connect to official repository of Ununtu -# - having superuser privileges -# -################################################################################ - -TESTING_MODE="$1" -HIREDIS_FOR_TESTING_DIR="$2" - -# libhiredis*** is a dependency of hiredis-dev -sudo apt-get install redis libhiredis-dev -y diff --git a/Makefile b/Makefile index 374c688..b618183 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,19 @@ OBJS = redis_fdw.o EXTENSION = redis_fdw DATA = redis_fdw--1.0.sql redis_fdw--2.0.sql redis_fdw--1.0--2.0.sql -REGRESS = redis_fdw -REGRESS_OPTS = --inputdir=test --outputdir=test \ - --load-extension=hstore \ - --load-extension=$(EXTENSION) +ifdef ENABLE_GIS +override PG_CFLAGS += -DREDIS_FDW_GIS_ENABLE +GISTEST=postgis +else +GISTEST=nogis +endif + +ifndef REGRESS +REGRESS = redis_fdw $(GISTEST) +#encodings # future test modules +endif + +REGRESS_OPTS = --encoding=utf8 --inputdir=test --outputdir=test EXTRA_CLEAN = sql/redis_fdw.sql expected/redis_fdw.out diff --git a/test/expected/nogis.out b/test/expected/nogis.out new file mode 100644 index 0000000..cf309cd --- /dev/null +++ b/test/expected/nogis.out @@ -0,0 +1,23 @@ +-- Testcase 001 +CREATE EXTENSION hstore; +-- Testcase 002 +CREATE EXTENSION redis_fdw; +-- Testcase 003 +create server localredis foreign data wrapper redis_fdw; +-- Testcase 004 +create user mapping for public server localredis; +-- Testcase 005 +-- \! redis-cli < test/redis_gis_ini +-- REDIS SPATIAL VALUE TESTS WILL BE HERE +-- Testcase 098 +-- all done, so now blow everything in the db away again +\! redis-cli < test/redis_clean +OK +OK +-- Testcase 099 +DROP EXTENSION redis_fdw CASCADE; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to server localredis +drop cascades to user mapping for public on server localredis +-- Testcase 100 +DROP EXTENSION hstore CASCADE; diff --git a/test/expected/postgis.out b/test/expected/postgis.out new file mode 100644 index 0000000..b84d7cb --- /dev/null +++ b/test/expected/postgis.out @@ -0,0 +1,29 @@ +-- Testcase 001 +CREATE EXTENSION postgis; +ERROR: extension "postgis" is not available +HINT: The extension must first be installed on the system where PostgreSQL is running. +-- Testcase 002 +CREATE EXTENSION hstore; +-- Testcase 003 +CREATE EXTENSION redis_fdw; +-- Testcase 004 +create server localredis foreign data wrapper redis_fdw; +-- Testcase 005 +create user mapping for public server localredis; +-- Testcase 006 +-- \! redis-cli < test/redis_gis_ini +-- Testcase 098 +-- all done, so now blow everything in the db away again +\! redis-cli < test/redis_clean +OK +OK +-- Testcase 099 +DROP EXTENSION redis_fdw CASCADE; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to server localredis +drop cascades to user mapping for public on server localredis +-- Testcase 100 +DROP EXTENSION hstore CASCADE; +-- Testcase 101 +DROP EXTENSION postgis CASCADE; +ERROR: extension "postgis" does not exist diff --git a/test/expected/redis_fdw.out b/test/expected/redis_fdw.out index 7c2841b..7b5789d 100644 --- a/test/expected/redis_fdw.out +++ b/test/expected/redis_fdw.out @@ -1,11 +1,29 @@ +-- Testcase 001: +CREATE EXTENSION hstore; +-- Testcase 002: +CREATE EXTENSION redis_fdw; +-- Testcase 003: +select redis_fdw_version(); + redis_fdw_version +------------------- + 1901 +(1 row) + +-- Testcase 004: +select redis_fdw_hiredis_version(); + redis_fdw_hiredis_version +--------------------------- + 1401 +(1 row) + +-- Testcase 005: CREATE OR REPLACE FUNCTION atsort( a text[]) RETURNS text[] LANGUAGE sql IMMUTABLE STRICT AS $function$ select array(select unnest($1) order by 1) -$function$ -; +$function$; create server localredis foreign data wrapper redis_fdw; create user mapping for public server localredis; -- tables for all 5 data types (4 structured plus scalar) @@ -44,7 +62,7 @@ do $$ $$; \unset ON_ERROR_STOP -- ok, empty, so now run the setup script -\! redis-cli < test/sql/redis_setup +\! redis-cli < test/redis_setup OK OK OK @@ -378,7 +396,7 @@ select * from db15_1key_zset_scores order by score desc; -- insert delete update -- first clean the database again -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean OK OK -- singleton scalar table @@ -1342,7 +1360,7 @@ select * from db15_w_hash_kset; (0 rows) -- now clean up for the cursor tests -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean OK OK -- cursor tests @@ -1395,6 +1413,54 @@ select count(*) from db15bigkeysetscalar; (1 row) -- all done, so now blow everything in the db away again -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean OK OK +DROP EXTENSION redis_fdw CASCADE; +NOTICE: drop cascades to 45 other objects +DETAIL: drop cascades to server localredis +drop cascades to user mapping for public on server localredis +drop cascades to foreign table db15 +drop cascades to foreign table db15_hash +drop cascades to foreign table db15_set +drop cascades to foreign table db15_list +drop cascades to foreign table db15_zset +drop cascades to foreign table db15_hash_prefix +drop cascades to foreign table db15_hash_prefix_array +drop cascades to foreign table db15_hash_keyset_array +drop cascades to foreign table db15_set_prefix +drop cascades to foreign table db15_set_prefix_array +drop cascades to foreign table db15_set_keyset_array +drop cascades to foreign table db15_list_prefix +drop cascades to foreign table db15_list_prefix_array +drop cascades to foreign table db15_list_keyset_array +drop cascades to foreign table db15_zset_prefix +drop cascades to foreign table db15_zset_prefix_array +drop cascades to foreign table db15_zset_keyset_array +drop cascades to foreign table db15_1key +drop cascades to foreign table db15_1key_hash +drop cascades to foreign table db15_1key_set +drop cascades to foreign table db15_1key_list +drop cascades to foreign table db15_1key_zset +drop cascades to foreign table db15_1key_zset_scores +drop cascades to foreign table db15_w_1key_scalar +drop cascades to foreign table db15_w_1key_hash +drop cascades to foreign table db15_w_1key_list +drop cascades to foreign table db15_w_1key_set +drop cascades to foreign table db15_w_1key_zset +drop cascades to foreign table db15_w_1key_zsetx +drop cascades to foreign table db15_w_scalar +drop cascades to foreign table db15_w_scalar_pfx +drop cascades to foreign table db15_w_scalar_kset +drop cascades to foreign table db15_w_set_nonarr +drop cascades to foreign table db15_w_set_pfx +drop cascades to foreign table db15_w_set_kset +drop cascades to foreign table db15_w_list_pfx +drop cascades to foreign table db15_w_list_kset +drop cascades to foreign table db15_w_zset_pfx +drop cascades to foreign table db15_w_zset_kset +drop cascades to foreign table db15_w_hash_pfx +drop cascades to foreign table db15_w_hash_kset +drop cascades to foreign table db15bigprefixscalar +drop cascades to foreign table db15bigkeysetscalar +DROP EXTENSION hstore; diff --git a/test/sql/redis_clean b/test/redis_clean similarity index 95% rename from test/sql/redis_clean rename to test/redis_clean index 4a96e9e..fd2a8ec 100644 --- a/test/sql/redis_clean +++ b/test/redis_clean @@ -1,4 +1,3 @@ select 15 flushdb - diff --git a/test/sql/redis_setup b/test/redis_setup similarity index 99% rename from test/sql/redis_setup rename to test/redis_setup index 3c6f2c9..a3b157c 100644 --- a/test/sql/redis_setup +++ b/test/redis_setup @@ -19,7 +19,3 @@ sadd hkeys hash1 hash2 sadd lkeys list1 list2 sadd skeys set1 set2 sadd zkeys zset1 zset2 - - - - diff --git a/test/sql/nogis.sql b/test/sql/nogis.sql new file mode 100644 index 0000000..f766e69 --- /dev/null +++ b/test/sql/nogis.sql @@ -0,0 +1,23 @@ +-- Testcase 001 +CREATE EXTENSION hstore; +-- Testcase 002 +CREATE EXTENSION redis_fdw; + +-- Testcase 003 +create server localredis foreign data wrapper redis_fdw; +-- Testcase 004 +create user mapping for public server localredis; + +-- Testcase 005 +-- \! redis-cli < test/redis_gis_ini + +-- REDIS SPATIAL VALUE TESTS WILL BE HERE + +-- Testcase 098 +-- all done, so now blow everything in the db away again +\! redis-cli < test/redis_clean + +-- Testcase 099 +DROP EXTENSION redis_fdw CASCADE; +-- Testcase 100 +DROP EXTENSION hstore CASCADE; diff --git a/test/sql/postgis.sql b/test/sql/postgis.sql new file mode 100644 index 0000000..e166f99 --- /dev/null +++ b/test/sql/postgis.sql @@ -0,0 +1,26 @@ +-- Testcase 001 +CREATE EXTENSION postgis; +-- Testcase 002 +CREATE EXTENSION hstore; +-- Testcase 003 +CREATE EXTENSION redis_fdw; + +-- Testcase 004 +create server localredis foreign data wrapper redis_fdw; +-- Testcase 005 +create user mapping for public server localredis; + +-- Testcase 006 +-- \! redis-cli < test/redis_gis_ini + + +-- Testcase 098 +-- all done, so now blow everything in the db away again +\! redis-cli < test/redis_clean + +-- Testcase 099 +DROP EXTENSION redis_fdw CASCADE; +-- Testcase 100 +DROP EXTENSION hstore CASCADE; +-- Testcase 101 +DROP EXTENSION postgis CASCADE; diff --git a/test/sql/redis_fdw.sql b/test/sql/redis_fdw.sql index b74e0f0..ee832d2 100644 --- a/test/sql/redis_fdw.sql +++ b/test/sql/redis_fdw.sql @@ -1,15 +1,21 @@ +-- Testcase 001: +CREATE EXTENSION hstore; +-- Testcase 002: +CREATE EXTENSION redis_fdw; +-- Testcase 003: +select redis_fdw_version(); +-- Testcase 004: +select redis_fdw_hiredis_version(); + +-- Testcase 005: CREATE OR REPLACE FUNCTION atsort( a text[]) RETURNS text[] LANGUAGE sql IMMUTABLE STRICT AS $function$ select array(select unnest($1) order by 1) -$function$ - -; - - +$function$; create server localredis foreign data wrapper redis_fdw; @@ -61,7 +67,7 @@ $$; -- ok, empty, so now run the setup script -\! redis-cli < test/sql/redis_setup +\! redis-cli < test/redis_setup select * from db15 order by key; @@ -231,7 +237,7 @@ select * from db15_1key_zset_scores order by score desc; -- first clean the database again -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean -- singleton scalar table @@ -841,7 +847,7 @@ select * from db15_w_hash_kset; -- now clean up for the cursor tests -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean -- cursor tests @@ -891,5 +897,7 @@ select count(*) from db15bigkeysetscalar; -- all done, so now blow everything in the db away again -\! redis-cli < test/sql/redis_clean +\! redis-cli < test/redis_clean +DROP EXTENSION redis_fdw CASCADE; +DROP EXTENSION hstore; From 42148cf9aea1f1b2863e224b75fc8d18f392f448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Sat, 4 Oct 2025 07:53:08 +0300 Subject: [PATCH 8/8] Try Ubuntu repo itself --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e091631..7515993 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,8 +32,8 @@ jobs: - name: 'Install PostgreSQL' run: | sudo apt-get purge postgresql-* - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-snapshot main ${{ matrix.pg }}" > /etc/apt/sources.list.d/pgdg.list' - curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null + #sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-snapshot main ${{ matrix.pg }}" > /etc/apt/sources.list.d/pgdg.list' + #curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null sudo apt-get update sudo apt-get -y install postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }} postgresql-client-${{ matrix.pg }} [ "${{ matrix.config }}" == "postgis" ] && sudo apt-get -y install postgresql-${{ matrix.pg }}-postgis-3