Skip to content

Commit

Permalink
Improve Quack test environment (#35)
Browse files Browse the repository at this point in the history
* Move regression test to test/regression directory. Running test will
  now start temporary PG instance for which we can now add custom
  configuration. Quack extension will now be loaded when instance
  starts.
* Make with required lz4 library
* gha: add ccache, move install build deps to separate step

---------

Co-authored-by: Jonathan Dance <[email protected]>
  • Loading branch information
mkaruza and wuputah authored May 28, 2024
1 parent 7a8acd3 commit 80271bc
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 54 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: pg_quack Build and Test
on:
push:
pull_request:
- push
- pull_request

jobs:
build-and-test:
strategy:
Expand All @@ -15,31 +16,33 @@ jobs:
- name: Test details
run: echo Build and test pg_quack on ${{ matrix.os }} with PostgreSQL ${{ matrix.version }} branch

- name: Checkout and build PostgreSQL code
- name: Install build deps
run: |
sudo apt-get update -qq
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config libc++-dev libc++abi-dev libglib2.0-dev libtinfo5 cmake libstdc++-12-dev
rm -rf postgres
git clone --branch ${{ matrix.version }} --single-branch --depth 1 https://github.com/postgres/postgres.git
pushd postgres
git branch
./configure --prefix=$PWD/inst/ --enable-cassert --enable-debug --with-openssl
make -j4 install
sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev \
libssl-dev libxml2-utils xsltproc pkg-config libc++-dev libc++abi-dev libglib2.0-dev libtinfo5 cmake \
libstdc++-12-dev
- name: Start Postgres
run: |
pushd postgres
cd inst/bin
./initdb -D data
./pg_ctl -D data -l logfile start
popd
- name: ccache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true

- name: Checkout pg_quack extension code
uses: actions/checkout@v4
with:
path: quack

- name: Checkout and build PostgreSQL code
run: |
rm -rf postgres
git clone --branch ${{ matrix.version }} --single-branch --depth 1 https://github.com/postgres/postgres.git
pushd postgres
git branch
./configure --prefix=$PWD/inst/ --enable-cassert --enable-debug --with-openssl
make -j8 install
- name: Build and test pg_quack extension
id: regression-tests
run: |
Expand All @@ -54,4 +57,4 @@ jobs:
- name: Print regression.diffs if regression tests failed
if: failure() && steps.regression-tests.outcome != 'success'
run: |
cat quack/regression.diffs
cat quack/test/regression/regression.diffs
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ compile_commands.json
*.so
*.o
*.bc
*.dylib

results
regression.diffs
regression.out
*.dylib
35 changes: 18 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: duckdb install_duckdb clean_duckdb lintcheck .depend
.PHONY: duckdb install-duckdb clean-duckdb lintcheck check-regression-quack clean-regression .depend

MODULE_big = quack
EXTENSION = quack
Expand All @@ -19,15 +19,6 @@ SRCS = src/utility/copy.cpp \

OBJS = $(subst .cpp,.o, $(SRCS))

REGRESS = $(subst .sql,,$(subst sql/,,$(wildcard sql/*.sql)))

PG_CONFIG ?= pg_config

PGXS := $(shell $(PG_CONFIG) --pgxs)
PG_LIB := $(shell $(PG_CONFIG) --pkglibdir)
INCLUDEDIR := ${shell $(PG_CONFIG) --includedir}
INCLUDEDIR_SERVER := ${shell $(PG_CONFIG) --includedir-server}

QUACK_BUILD_CXX_FLAGS=
QUACK_BUILD_DUCKDB=

Expand All @@ -41,7 +32,7 @@ endif

override PG_CPPFLAGS += -Iinclude -Ithird_party/duckdb/src/include -std=c++17 -Wno-sign-compare ${QUACK_BUILD_CXX_FLAGS}

SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -L$(PG_LIB) -lduckdb -Lthird_party/duckdb/build/$(QUACK_BUILD_DUCKDB)/src -lstdc++
SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -L$(PG_LIB) -lduckdb -Lthird_party/duckdb/build/$(QUACK_BUILD_DUCKDB)/src -lstdc++ -llz4

COMPILE.cc.bc = $(CXX) -Wno-ignored-attributes -Wno-register $(BITCODE_CXXFLAGS) $(CXXFLAGS) $(PG_CPPFLAGS) -I$(INCLUDEDIR_SERVER) -emit-llvm -c

Expand All @@ -59,25 +50,35 @@ endif

all: duckdb $(OBJS) .depend

include $(PGXS)
include Makefile.global

NO_INSTALLCHECK = 1

check-regression-quack:
$(MAKE) -C test/regression check-regression-quack

clean-regression:
$(MAKE) -C test/regression clean-regression

installcheck: all install check-regression-quack

duckdb: third_party/duckdb/Makefile third_party/duckdb/build/$(QUACK_BUILD_DUCKDB)/src/$(DUCKDB_LIB)

third_party/duckdb/Makefile:
git submodule update --init --recursive

third_party/duckdb/build/$(QUACK_BUILD_DUCKDB)/src/$(DUCKDB_LIB):
$(MAKE) -C third_party/duckdb $(QUACK_BUILD_DUCKDB) DISABLE_SANITIZER=1 ENABLE_UBSAN=0 BUILD_UNITTESTS=OFF BUILD_HTTPFS=1 CMAKE_EXPORT_COMPILE_COMMANDS=1
$(MAKE) -C third_party/duckdb $(QUACK_BUILD_DUCKDB) DISABLE_SANITIZER=1 ENABLE_UBSAN=0 BUILD_UNITTESTS=OFF BUILD_HTTPFS=1 CMAKE_EXPORT_COMPILE_COMMANDS=1 -j8

install_duckdb:
install-duckdb:
$(install_bin) -m 755 third_party/duckdb/build/$(QUACK_BUILD_DUCKDB)/src/$(DUCKDB_LIB) $(DESTDIR)$(PG_LIB)

clean_duckdb:
clean-duckdb:
rm -rf third_party/duckdb/build

install: install_duckdb
install: install-duckdb

clean: clean_duckdb
clean: clean-regression clean-duckdb

lintcheck:
clang-tidy $(SRCS) -- -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) -Iinclude $(CPPFLAGS) -std=c++17
Expand Down
9 changes: 9 additions & 0 deletions Makefile.global
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PG_CONFIG ?= pg_config

PGXS := $(shell $(PG_CONFIG) --pgxs)
PG_LIB := $(shell $(PG_CONFIG) --pkglibdir)
INCLUDEDIR := ${shell $(PG_CONFIG) --includedir}
INCLUDEDIR_SERVER := ${shell $(PG_CONFIG) --includedir-server}

USE_PGXS = 1
include $(PGXS)
12 changes: 12 additions & 0 deletions test/regression/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated subdirectories
/tmp_check/
/results/
/log/

# Regression test output
/regression.diffs
/regression.output
/regression.out

# core dumps
core
18 changes: 18 additions & 0 deletions test/regression/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Makefile for regression test

ROOT_DIR = ../..

include $(ROOT_DIR)/Makefile.global

check-regression-quack:
TEST_DIR=$(CURDIR) $(pg_regress_check) \
--temp-config regression.conf \
--load-extension=quack \
--schedule schedule

clean-regression:
rm -fr $(CURDIR)/tmp_check
rm -fr $(CURDIR)/log
rm -fr $(CURDIR)/results
rm -f $(CURDIR)/regression.diffs
rm -f $(CURDIR)/regression.out
2 changes: 0 additions & 2 deletions expected/basic.out → test/regression/expected/basic.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CREATE EXTENSION quack;
CREATE TABLE t(a INT);
INSERT INTO t SELECT g % 10 from generate_series(1,1000000) g;
SET client_min_messages to 'DEBUG3';
Expand Down Expand Up @@ -48,4 +47,3 @@ DEBUG: -- (DuckDB/PostgresHeapScanGlobalState) Running 4 threads --
SET quack.max_threads_per_query TO default;
SET client_min_messages TO default;
DROP TABLE t;
DROP EXTENSION quack;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CREATE EXTENSION quack;
CREATE TABLE t(a INT);
INSERT INTO t SELECT g from generate_series(1,10) g;
SELECT count(*) FROM t;
Expand Down Expand Up @@ -68,4 +67,3 @@ SELECT count(*) FROM public.t, other.t;
DROP TABLE other.t;
DROP SCHEMA other;
RESET search_path;
DROP EXTENSION quack;
4 changes: 4 additions & 0 deletions test/regression/regression.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Configuration

shared_preload_libraries = 'quack'
log_temp_files = -1
2 changes: 2 additions & 0 deletions test/regression/schedule
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test: basic
test: search_path
6 changes: 1 addition & 5 deletions sql/basic.sql → test/regression/sql/basic.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CREATE EXTENSION quack;

CREATE TABLE t(a INT);

INSERT INTO t SELECT g % 10 from generate_series(1,1000000) g;
Expand All @@ -17,6 +15,4 @@ SELECT a, COUNT(*) FROM t WHERE a > 5 GROUP BY a ORDER BY a;
SET quack.max_threads_per_query TO default;
SET client_min_messages TO default;

DROP TABLE t;

DROP EXTENSION quack;
DROP TABLE t;
6 changes: 1 addition & 5 deletions sql/search_path.sql → test/regression/sql/search_path.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CREATE EXTENSION quack;

CREATE TABLE t(a INT);
INSERT INTO t SELECT g from generate_series(1,10) g;
SELECT count(*) FROM t;
Expand Down Expand Up @@ -29,6 +27,4 @@ SELECT count(*) FROM public.t, other.t;
-- Cleanup
DROP TABLE other.t;
DROP SCHEMA other;
RESET search_path;

DROP EXTENSION quack;
RESET search_path;

0 comments on commit 80271bc

Please sign in to comment.