Skip to content

Refactoring #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 25, 2018
Merged
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.gcno
*.gcda
*.gcov
*.so
*.o
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
*.o
*.so
*.swp
*.pyc
*.gcda
*.gcno
*.gcov
pg_query_state--*.sql
cscope.out
tags
Dockerfile
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
sudo: required

language: c

services:
- docker

install:
- ./mk_dockerfile.sh
- docker-compose build

script:
- docker-compose run $(bash <(curl -s https://codecov.io/env)) tests

notifications:
email:
on_success: change
on_failure: always

env:
- PG_VERSION=11 LEVEL=hardcore
- PG_VERSION=11
- PG_VERSION=10 LEVEL=hardcore
- PG_VERSION=10
- PG_VERSION=9.6 LEVEL=hardcore
- PG_VERSION=9.6

matrix:
allow_failures:
- env: PG_VERSION=10 LEVEL=nightmare
- env: PG_VERSION=9.6 LEVEL=nightmare
38 changes: 38 additions & 0 deletions Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM postgres:${PG_VERSION}-alpine

# Install dependencies
RUN apk add --no-cache \
openssl curl \
perl perl-ipc-run \
make musl-dev gcc bison flex coreutils \
zlib-dev libedit-dev \
clang clang-analyzer \
python2 python2-dev py2-virtualenv;


# Install fresh valgrind
RUN apk add valgrind \
--update-cache \
--repository http://dl-3.alpinelinux.org/alpine/edge/main;

# Environment
ENV LANG=C.UTF-8 PGDATA=/pg/data

# Make directories
RUN mkdir -p ${PGDATA} && \
mkdir -p /pg/testdir

# Grant privileges
RUN chown postgres:postgres ${PGDATA} && \
chown postgres:postgres /pg/testdir && \
chmod -R a+rwx /usr/local/lib/postgresql && \
chmod a+rwx /usr/local/share/postgresql/extension

COPY run_tests.sh /run.sh
RUN chmod 755 /run.sh

ADD . /pg/testdir
WORKDIR /pg/testdir

USER postgres
ENTRYPOINT LEVEL=${LEVEL} /run.sh
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
MODULE_big = pg_query_state
OBJS = pg_query_state.o signal_handler.o $(WIN32RES)
EXTENSION = pg_query_state
EXTVERSION = 1.0
DATA = $(EXTENSION)--$(EXTVERSION).sql
EXTVERSION = 1.1
DATA = pg_query_state--1.0--1.1.sql
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
PGFILEDESC = "pg_query_state - facility to track progress of plan execution"

EXTRA_CLEAN = ./isolation_output
EXTRA_CLEAN = ./isolation_output $(EXTENSION)--$(EXTVERSION).sql \
Dockerfile ./tests/*.pyc

ifdef USE_PGXS
PG_CONFIG = pg_config
Expand All @@ -20,6 +22,9 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

$(EXTENSION)--$(EXTVERSION).sql: init.sql
cat $^ > $@

check: isolationcheck

ISOLATIONCHECKS=corner_cases
Expand Down
356 changes: 176 additions & 180 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests:
build: .
66 changes: 0 additions & 66 deletions executor_hooks.patch

This file was deleted.

8 changes: 0 additions & 8 deletions pg_query_state--1.0.sql → init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@ CREATE FUNCTION pg_query_state(pid integer
, leader_pid integer)
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT VOLATILE;

CREATE FUNCTION executor_step(pid integer) RETURNS VOID
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE;

CREATE FUNCTION executor_continue(pid integer) RETURNS VOID
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE;
16 changes: 16 additions & 0 deletions mk_dockerfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if [ -z ${PG_VERSION+x} ]; then
echo PG_VERSION is not set!
exit 1
fi

if [ -z ${LEVEL+x} ]; then
LEVEL=scan-build
fi

echo PG_VERSION=${PG_VERSION}
echo LEVEL=${LEVEL}

sed \
-e 's/${PG_VERSION}/'${PG_VERSION}/g \
-e 's/${LEVEL}/'${LEVEL}/g \
Dockerfile.tmpl > Dockerfile
Loading