-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from sjyothi54/integration_testing
Integration testing setup for postgres
- Loading branch information
Showing
20 changed files
with
1,548 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
services: | ||
|
||
postgres12: | ||
build: | ||
context: ./perf-testing/oldest_supported/ | ||
dockerfile: Dockerfile | ||
container_name: "postgresql-perf-oldest" | ||
restart: always | ||
environment: | ||
- POSTGRES_USER=dbuser | ||
- POSTGRES_PASSWORD=dbpassword | ||
- POSTGRES_DB=demo | ||
volumes: | ||
- postgres12:/var/lib/postgresql/data | ||
ports: | ||
- "6432:5432" | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
postgresql-latest: | ||
build: | ||
context: ./perf-testing/oldest_supported/ | ||
dockerfile: Dockerfile | ||
restart: always | ||
container_name: "postgresql-perf-latest" | ||
environment: | ||
- POSTGRES_USER=dbuser | ||
- POSTGRES_PASSWORD=dbpassword | ||
- POSTGRES_DB=demo | ||
volumes: | ||
- pgdata_latest:/var/lib/postgresql/data | ||
ports: | ||
- "5432:5432" | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
postgres-without-extensions: | ||
image: postgres:17.0 | ||
restart: always | ||
container_name: "postgresql-noext" | ||
environment: | ||
- POSTGRES_USER=dbuser | ||
- POSTGRES_PASSWORD=dbpassword | ||
- POSTGRES_DB=demo | ||
volumes: | ||
- pgdata_noext:/var/lib/postgresql/data | ||
ports: | ||
- "7432:5432" | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
nri-postgresql: | ||
container_name: nri_postgresql | ||
build: | ||
context: ../ | ||
dockerfile: tests/perf-testing/integration/Dockerfile | ||
|
||
volumes: | ||
pgdata_latest: | ||
postgres12: | ||
pgdata_noext: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM golang:1.23.4-bookworm as builder | ||
ARG CGO_ENABLED=0 | ||
WORKDIR /go/src/github.com/newrelic/nri-postgresql | ||
COPY . . | ||
RUN make clean compile | ||
|
||
FROM alpine:latest | ||
COPY --from=builder /go/src/github.com/newrelic/nri-postgresql/bin / | ||
CMD ["sleep", "1h"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE EXTENSION IF NOT EXISTS pg_stat_statements; | ||
|
||
CREATE EXTENSION IF NOT EXISTS pg_wait_sampling; | ||
|
||
CREATE EXTENSION IF NOT EXISTS pg_stat_monitor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE DATABASE titanic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Connect to titanic database | ||
\c titanic; | ||
|
||
-- Import the titanic.sql file that was downloaded during Docker build | ||
\i /docker-entrypoint-initdb.d/titanic.sql; | ||
|
||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dbuser; | ||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dbuser; | ||
|
||
-- Analyze tables for better query planning | ||
ANALYZE VERBOSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM postgres:17.0 | ||
|
||
# Dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
wget \ | ||
postgresql-server-dev-17 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Postgres Docker Images copy contents of postgresql.conf.sample to postgresql.conf during initialization | ||
# COPY custom.conf /usr/share/postgresql/postgresql.conf.sample -- DO NOT USE | ||
RUN echo "shared_preload_libraries = 'pg_stat_statements,pg_wait_sampling,pg_stat_monitor'" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_statements.track = all" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_statements.save = on" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_monitor.pgsm_enable_query_plan = on" >> /usr/share/postgresql/postgresql.conf.sample | ||
|
||
# Install pg_wait_sampling | ||
RUN git clone https://github.com/postgrespro/pg_wait_sampling.git \ | ||
&& cd pg_wait_sampling \ | ||
&& make USE_PGXS=1 \ | ||
&& make USE_PGXS=1 install \ | ||
&& cd .. \ | ||
&& rm -rf pg_wait_sampling | ||
|
||
# Install pg_stat_monitor | ||
RUN git clone https://github.com/percona/pg_stat_monitor.git \ | ||
&& cd pg_stat_monitor \ | ||
&& make USE_PGXS=1 \ | ||
&& make USE_PGXS=1 install \ | ||
&& cd .. \ | ||
&& rm -rf pg_stat_monitor | ||
|
||
# Download the titanic database | ||
RUN wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/titanic.sql -P /docker-entrypoint-initdb.d/ | ||
|
||
# Enable the extensions and setup the titanic database | ||
COPY 01-init-extensions.sql /docker-entrypoint-initdb.d/01-init-extensions.sql | ||
COPY 02-create-database.sql /docker-entrypoint-initdb.d/02-create-database.sql | ||
COPY 03-import-data.sql /docker-entrypoint-initdb.d/03-import-data.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE EXTENSION IF NOT EXISTS pg_stat_statements; | ||
|
||
CREATE EXTENSION IF NOT EXISTS pg_wait_sampling; | ||
|
||
CREATE EXTENSION IF NOT EXISTS pg_stat_monitor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE DATABASE titanic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Connect to titanic database | ||
\c titanic; | ||
|
||
-- Import the titanic.sql file that was downloaded during Docker build | ||
\i /docker-entrypoint-initdb.d/titanic.sql; | ||
|
||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dbuser; | ||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dbuser; | ||
|
||
-- Analyze tables for better query planning | ||
ANALYZE VERBOSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM postgres:12 | ||
|
||
# Dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
wget \ | ||
postgresql-server-dev-12 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Postgres Docker Images copy contents of postgresql.conf.sample to postgresql.conf during initialization | ||
# COPY custom.conf /usr/share/postgresql/postgresql.conf.sample -- DO NOT USE | ||
RUN echo "shared_preload_libraries = 'pg_stat_statements,pg_wait_sampling,pg_stat_monitor'" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_statements.track = all" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_statements.save = on" >> /usr/share/postgresql/postgresql.conf.sample | ||
RUN echo "pg_stat_monitor.pgsm_enable_query_plan = on" >> /usr/share/postgresql/postgresql.conf.sample | ||
|
||
# Install pg_wait_sampling | ||
RUN git clone https://github.com/postgrespro/pg_wait_sampling.git \ | ||
&& cd pg_wait_sampling \ | ||
&& make USE_PGXS=1 \ | ||
&& make USE_PGXS=1 install \ | ||
&& cd .. \ | ||
&& rm -rf pg_wait_sampling | ||
|
||
# Install pg_stat_monitor | ||
RUN git clone https://github.com/percona/pg_stat_monitor.git \ | ||
&& cd pg_stat_monitor \ | ||
&& make USE_PGXS=1 \ | ||
&& make USE_PGXS=1 install \ | ||
&& cd .. \ | ||
&& rm -rf pg_stat_monitor | ||
|
||
# Download the titanic database | ||
RUN wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/titanic.sql -P /docker-entrypoint-initdb.d/ | ||
|
||
RUN echo ${PWD} && ls -lR | ||
|
||
# Enable the extensions and setup the titanic database | ||
COPY 01-init-extensions.sql /docker-entrypoint-initdb.d/01-init-extensions.sql | ||
COPY 02-create-database.sql /docker-entrypoint-initdb.d/02-create-database.sql | ||
COPY 03-import-data.sql /docker-entrypoint-initdb.d/03-import-data.sql |
Oops, something went wrong.