pgaudit.git / summary / log / commit / refs

commit    bb816445df1c770a6f034d7bee0f428fc2265904
Author:   David Steele <david@pgmasters.net>
Date:     Tue Aug 03 20:17:09 2021 +0000

    Add RHEL test container.


.github/workflows/test.yml | 3 +++ test/Dockerfile.rhel | 35 +++++++++++++++++++++++++++++++++++ test/README.md | 4 ++++ test/test.sh | 5 ++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44751da..b970e51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,9 @@ jobs: # Debian - image: debian + # RHEL + - image: rhel + steps: - name: Checkout Code uses: actions/checkout@v2 diff --git a/test/Dockerfile.rhel b/test/Dockerfile.rhel new file mode 100644 index 0000000..d8ee657 --- /dev/null +++ b/test/Dockerfile.rhel @@ -0,0 +1,35 @@ +FROM centos:7 + +# User and group id +ARG UID=1000 +ARG GID=1000 + +# Setup environment +ENV PGVERSION=14 +ENV PGBIN=/usr/pgsql-${PGVERSION}/bin +ENV PGDATA="/var/lib/pgsql/${PGVERSION}/data" +ENV PATH="${PATH}:${PGBIN}" + +# Install packages +RUN yum install -y centos-release-scl-rh epel-release +RUN yum install -y sudo + +# Create postgres user/group with specific IDs +RUN groupadd -g $GID -o postgres +RUN useradd -m -u $UID -g $GID -o -s /bin/bash postgres + +# Install PostgreSQL +RUN rpm --import http://yum.postgresql.org/RPM-GPG-KEY-PGDG +RUN rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +# Enable PG14 repo (can be removed after the official release) +RUN yum-config-manager --enable pgdg14-updates-testing +RUN yum install -y postgresql${PGVERSION?}-server postgresql${PGVERSION?}-devel make gcc openssl-devel llvm-toolset-7-clang llvm5.0 + +# Create PostgreSQL cluster +RUN sudo -u postgres ${PGBIN?}/initdb -A trust -k ${PGDATA?} +RUN echo "shared_preload_libraries = 'pgaudit'" >> ${PGDATA?}/postgresql.conf + +# Configure sudo +RUN echo 'postgres ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +USER postgres diff --git a/test/README.md b/test/README.md index 9a10b40..3788556 100644 --- a/test/README.md +++ b/test/README.md @@ -4,6 +4,10 @@ Testing is performed using a Docker container. First build the container: ``` docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -f test/Dockerfile.debian -t pgaudit-test . ``` +or +``` +docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -f test/Dockerfile.rhel -t pgaudit-test . +``` Then run the test: ``` docker run --rm -v $(pwd):/pgaudit pgaudit-test /pgaudit/test/test.sh diff --git a/test/test.sh b/test/test.sh index 5757e08..51529b0 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,8 +1,11 @@ #!/bin/bash set -e +# Clean and build pgaudit +make -C /pgaudit clean all USE_PGXS=1 + # Install pgaudit so postgres will start with shared_preload_libraries set -sudo make -C /pgaudit clean install USE_PGXS=1 +sudo bash -c "PATH=${PATH?} make -C /pgaudit install USE_PGXS=1" # Start postgres ${PGBIN}/pg_ctl -w start -D ${PGDATA} [parent: e8cded51a4a1]