Skip to content
Open
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
65 changes: 65 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Compilable against Ubuntu packages test instead of full C complex CI

on: [push, pull_request]

jobs:
linux:

runs-on: ubuntu-latest

name: "CI"
strategy:
fail-fast: true
matrix:
pg: ["14", "15", "16", "17", "18"]
config: ["default", "postgis"]

steps:

- name: 'Check Out'
uses: actions/checkout@v4

- 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: '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 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

- name: 'Install Redis + Hiredis'
run: |
sudo apt-get -y install libhiredis-dev redis-server

- name: 'Start PostgreSQL'
run: |
export PGVER=${{ matrix.pg }}
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 ./GitHubActions/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.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)
8 changes: 8 additions & 0 deletions GitHubActions/pg_hba.conf
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions test/expected/nogis.out
Original file line number Diff line number Diff line change
@@ -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;
29 changes: 29 additions & 0 deletions test/expected/postgis.out
Original file line number Diff line number Diff line change
@@ -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
78 changes: 72 additions & 6 deletions test/expected/redis_fdw.out
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
1 change: 0 additions & 1 deletion test/sql/redis_clean → test/redis_clean
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
select 15

flushdb

4 changes: 0 additions & 4 deletions test/sql/redis_setup → test/redis_setup
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ sadd hkeys hash1 hash2
sadd lkeys list1 list2
sadd skeys set1 set2
sadd zkeys zset1 zset2




23 changes: 23 additions & 0 deletions test/sql/nogis.sql
Original file line number Diff line number Diff line change
@@ -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;
26 changes: 26 additions & 0 deletions test/sql/postgis.sql
Original file line number Diff line number Diff line change
@@ -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;
26 changes: 17 additions & 9 deletions test/sql/redis_fdw.sql
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;