Skip to content

Commit

Permalink
Improve Quack test environment
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.
  • Loading branch information
mkaruza committed May 27, 2024
1 parent de5761f commit 083424b
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 36 deletions.
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,28 +19,21 @@ 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=

ifeq ($(QUACK_BUILD), Debug)
QUACK_BUILD_CXX_FLAGS = -g -O0
QUACK_BUILD_DUCKDB = debug
else
QUACK_BUILD_CXX_FLAGS =
QUACK_BUILD_DUCKDB = release
QUACK_BUILD_CXX_FLAGS = -g -O0
QUACK_BUILD_DUCKDB = debug
endif

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

include Makefile.global

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

COMPILE.cc.bc = $(CXX) -Wno-ignored-attributes -Wno-register $(BITCODE_CXXFLAGS) $(CXXFLAGS) $(PG_CPPFLAGS) -I$(INCLUDEDIR_SERVER) -emit-llvm -c
Expand All @@ -59,7 +52,15 @@ endif

all: duckdb $(OBJS) .depend

include $(PGXS)
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)

Expand All @@ -69,15 +70,15 @@ third_party/duckdb/Makefile:
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

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.so'
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 083424b

Please sign in to comment.