From 1946db857b50142e3f52d01409e0cbdb78a6dc51 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 16:43:43 +0100 Subject: [PATCH 1/9] Fixed build version --- postgres-backup-s3/Dockerfile | 2 ++ postgres-backup-s3/integration-tests.test.yml | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/postgres-backup-s3/Dockerfile b/postgres-backup-s3/Dockerfile index 1be5bac..215bb1e 100644 --- a/postgres-backup-s3/Dockerfile +++ b/postgres-backup-s3/Dockerfile @@ -24,4 +24,6 @@ ADD backup.sh backup.sh ADD integration-tests.sh integration-tests.sh ADD config/sample_sql_file.sql sample_sql_file.sql + + CMD ["sh", "run.sh"] diff --git a/postgres-backup-s3/integration-tests.test.yml b/postgres-backup-s3/integration-tests.test.yml index 727e4ca..9772ac0 100644 --- a/postgres-backup-s3/integration-tests.test.yml +++ b/postgres-backup-s3/integration-tests.test.yml @@ -7,7 +7,10 @@ services: - POSTGRES_USER=user - PGDATA=/var/lib/postgresql/data/pgdata sut: - build: . + build: + context: . + args: + DOCKER_API_VERSION: "1.37" command: 'sh integration-tests.sh' depends_on: - postgres From 849a4fe46d200c5d2a4cffed27c0a43049a00237 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 16:57:47 +0100 Subject: [PATCH 2/9] Added Docker API version to the Dockerfile --- postgres-backup-s3/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/postgres-backup-s3/Dockerfile b/postgres-backup-s3/Dockerfile index 215bb1e..7dffc14 100644 --- a/postgres-backup-s3/Dockerfile +++ b/postgres-backup-s3/Dockerfile @@ -1,6 +1,8 @@ FROM alpine:3.7 LABEL maintainer="Johannes Schickling " +ARG DOCKER_API_VERSION + ADD install.sh install.sh RUN sh install.sh && rm install.sh @@ -15,6 +17,7 @@ ENV S3_SECRET_ACCESS_KEY **None** ENV S3_BUCKET **None** ENV S3_REGION us-west-1 ENV S3_PATH 'backup' +ENV S3_FILENAME **None** ENV S3_ENDPOINT **None** ENV S3_S3V4 no ENV SCHEDULE **None** From 7545854774d8799ca18c75362176e61384e63c3f Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:12:17 +0100 Subject: [PATCH 3/9] Commented whole test --- postgres-backup-s3/integration-tests.sh | 156 ++++++++++++------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/postgres-backup-s3/integration-tests.sh b/postgres-backup-s3/integration-tests.sh index dca4f03..6e196ec 100644 --- a/postgres-backup-s3/integration-tests.sh +++ b/postgres-backup-s3/integration-tests.sh @@ -2,84 +2,84 @@ set -e -RETRIES=60 - -until psql -h postgres -U user -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do - echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." - sleep 3 -done - -OUT=$(psql -h postgres -U user -v ON_ERROR_STOP=1 -1 -f sample_sql_file.sql) - -EXPECTED="SET -SET -SET -SET -SET - set_config ------------- +# RETRIES=60 + +# until psql -h postgres -U user -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do +# echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." +# sleep 3 +# done + +# OUT=$(psql -h postgres -U user -v ON_ERROR_STOP=1 -1 -f sample_sql_file.sql) + +# EXPECTED="SET +# SET +# SET +# SET +# SET +# set_config +# ------------ -(1 row) - -SET -SET -SET -SET -CREATE EXTENSION -COMMENT -SET -SET -CREATE TABLE -ALTER TABLE -CREATE SEQUENCE -ALTER TABLE -ALTER SEQUENCE -ALTER TABLE -COPY 10 - setval --------- - 1 -(1 row) - -ALTER TABLE" - -if [ "$OUT" != "$EXPECTED" ]; then - echo "OUT = '$OUT'" - echo "Not '$EXPECTED'" - exit 1 -fi - -pg_dump -h postgres -U user > sample_output.sql - -DIFF=$(diff sample_sql_file.sql sample_output.sql) - -if [ "$DIFF" != "" ]; then - echo "Expected output from diff was ''" - echo "Actual output was '$DIFF'" - exit 1 -fi - - -if [ "${S3_S3V4}" = "yes" ]; then - aws configure set default.s3.signature_version s3v4 -fi - -OUT=$(sh backup.sh) -EXPECTED="Creating dump of user database from postgres... -Uploading dump to flowmoco-s3-backup-test -SQL backup uploaded successfully" - -if [ "$OUT" != "$EXPECTED" ]; then - echo "Output '$OUT' does not equal expected '$EXPECTED'" - exit 1 -fi - -# apt-get update && apt-get install -y wget - -# wget "https://sample-videos.com/sql/Sample-SQL-File-10rows.sql" - - -# echo "Cleaning Up..." -# rm Sample-SQL-File-10rows.sql +# (1 row) + +# SET +# SET +# SET +# SET +# CREATE EXTENSION +# COMMENT +# SET +# SET +# CREATE TABLE +# ALTER TABLE +# CREATE SEQUENCE +# ALTER TABLE +# ALTER SEQUENCE +# ALTER TABLE +# COPY 10 +# setval +# -------- +# 1 +# (1 row) + +# ALTER TABLE" + +# if [ "$OUT" != "$EXPECTED" ]; then +# echo "OUT = '$OUT'" +# echo "Not '$EXPECTED'" +# exit 1 +# fi + +# pg_dump -h postgres -U user > sample_output.sql + +# DIFF=$(diff sample_sql_file.sql sample_output.sql) + +# if [ "$DIFF" != "" ]; then +# echo "Expected output from diff was ''" +# echo "Actual output was '$DIFF'" +# exit 1 +# fi + + +# if [ "${S3_S3V4}" = "yes" ]; then +# aws configure set default.s3.signature_version s3v4 +# fi + +# OUT=$(sh backup.sh) +# EXPECTED="Creating dump of user database from postgres... +# Uploading dump to flowmoco-s3-backup-test +# SQL backup uploaded successfully" + +# if [ "$OUT" != "$EXPECTED" ]; then +# echo "Output '$OUT' does not equal expected '$EXPECTED'" +# exit 1 +# fi + +# # apt-get update && apt-get install -y wget + +# # wget "https://sample-videos.com/sql/Sample-SQL-File-10rows.sql" + + +# # echo "Cleaning Up..." +# # rm Sample-SQL-File-10rows.sql echo "This worked ok" From 65a7c1bca83079d87536f2de5ad35049f2db5ad8 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:20:57 +0100 Subject: [PATCH 4/9] Avoiding rebuild --- postgres-backup-s3/integration-tests.test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/postgres-backup-s3/integration-tests.test.yml b/postgres-backup-s3/integration-tests.test.yml index 9772ac0..2201b2b 100644 --- a/postgres-backup-s3/integration-tests.test.yml +++ b/postgres-backup-s3/integration-tests.test.yml @@ -7,10 +7,7 @@ services: - POSTGRES_USER=user - PGDATA=/var/lib/postgresql/data/pgdata sut: - build: - context: . - args: - DOCKER_API_VERSION: "1.37" + image: robwithhair/postgres-backup-s3:this command: 'sh integration-tests.sh' depends_on: - postgres From 5e598216eeeae322f0b19c66973eef48f4b065f6 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:29:10 +0100 Subject: [PATCH 5/9] Change of arguments --- postgres-backup-s3/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/postgres-backup-s3/Dockerfile b/postgres-backup-s3/Dockerfile index 7dffc14..59014f9 100644 --- a/postgres-backup-s3/Dockerfile +++ b/postgres-backup-s3/Dockerfile @@ -1,8 +1,6 @@ FROM alpine:3.7 LABEL maintainer="Johannes Schickling " -ARG DOCKER_API_VERSION - ADD install.sh install.sh RUN sh install.sh && rm install.sh From b44b5756433a608f4905a85f6ebda18a407659f0 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:39:51 +0100 Subject: [PATCH 6/9] Changed version --- postgres-backup-s3/integration-tests.test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres-backup-s3/integration-tests.test.yml b/postgres-backup-s3/integration-tests.test.yml index 2201b2b..a70b342 100644 --- a/postgres-backup-s3/integration-tests.test.yml +++ b/postgres-backup-s3/integration-tests.test.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.6' services: postgres: image: camptocamp/postgres:9.6 From cf44d73e23a1ab1dcb964599ea731ae24eb50697 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:49:30 +0100 Subject: [PATCH 7/9] Added integration tests --- postgres-backup-s3/integration-tests.test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/postgres-backup-s3/integration-tests.test.yml b/postgres-backup-s3/integration-tests.test.yml index a70b342..ca4c1d8 100644 --- a/postgres-backup-s3/integration-tests.test.yml +++ b/postgres-backup-s3/integration-tests.test.yml @@ -7,7 +7,8 @@ services: - POSTGRES_USER=user - PGDATA=/var/lib/postgresql/data/pgdata sut: - image: robwithhair/postgres-backup-s3:this + build: + context: . command: 'sh integration-tests.sh' depends_on: - postgres From bf84d74b6028efcfcdfadf8936595cb13e2d10f5 Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 17:52:41 +0100 Subject: [PATCH 8/9] Added tests back in as were missing before --- postgres-backup-s3/integration-tests.sh | 156 ++++++++++++------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/postgres-backup-s3/integration-tests.sh b/postgres-backup-s3/integration-tests.sh index 6e196ec..dca4f03 100644 --- a/postgres-backup-s3/integration-tests.sh +++ b/postgres-backup-s3/integration-tests.sh @@ -2,84 +2,84 @@ set -e -# RETRIES=60 - -# until psql -h postgres -U user -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do -# echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." -# sleep 3 -# done - -# OUT=$(psql -h postgres -U user -v ON_ERROR_STOP=1 -1 -f sample_sql_file.sql) - -# EXPECTED="SET -# SET -# SET -# SET -# SET -# set_config -# ------------ +RETRIES=60 + +until psql -h postgres -U user -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do + echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." + sleep 3 +done + +OUT=$(psql -h postgres -U user -v ON_ERROR_STOP=1 -1 -f sample_sql_file.sql) + +EXPECTED="SET +SET +SET +SET +SET + set_config +------------ -# (1 row) - -# SET -# SET -# SET -# SET -# CREATE EXTENSION -# COMMENT -# SET -# SET -# CREATE TABLE -# ALTER TABLE -# CREATE SEQUENCE -# ALTER TABLE -# ALTER SEQUENCE -# ALTER TABLE -# COPY 10 -# setval -# -------- -# 1 -# (1 row) - -# ALTER TABLE" - -# if [ "$OUT" != "$EXPECTED" ]; then -# echo "OUT = '$OUT'" -# echo "Not '$EXPECTED'" -# exit 1 -# fi - -# pg_dump -h postgres -U user > sample_output.sql - -# DIFF=$(diff sample_sql_file.sql sample_output.sql) - -# if [ "$DIFF" != "" ]; then -# echo "Expected output from diff was ''" -# echo "Actual output was '$DIFF'" -# exit 1 -# fi - - -# if [ "${S3_S3V4}" = "yes" ]; then -# aws configure set default.s3.signature_version s3v4 -# fi - -# OUT=$(sh backup.sh) -# EXPECTED="Creating dump of user database from postgres... -# Uploading dump to flowmoco-s3-backup-test -# SQL backup uploaded successfully" - -# if [ "$OUT" != "$EXPECTED" ]; then -# echo "Output '$OUT' does not equal expected '$EXPECTED'" -# exit 1 -# fi - -# # apt-get update && apt-get install -y wget - -# # wget "https://sample-videos.com/sql/Sample-SQL-File-10rows.sql" - - -# # echo "Cleaning Up..." -# # rm Sample-SQL-File-10rows.sql +(1 row) + +SET +SET +SET +SET +CREATE EXTENSION +COMMENT +SET +SET +CREATE TABLE +ALTER TABLE +CREATE SEQUENCE +ALTER TABLE +ALTER SEQUENCE +ALTER TABLE +COPY 10 + setval +-------- + 1 +(1 row) + +ALTER TABLE" + +if [ "$OUT" != "$EXPECTED" ]; then + echo "OUT = '$OUT'" + echo "Not '$EXPECTED'" + exit 1 +fi + +pg_dump -h postgres -U user > sample_output.sql + +DIFF=$(diff sample_sql_file.sql sample_output.sql) + +if [ "$DIFF" != "" ]; then + echo "Expected output from diff was ''" + echo "Actual output was '$DIFF'" + exit 1 +fi + + +if [ "${S3_S3V4}" = "yes" ]; then + aws configure set default.s3.signature_version s3v4 +fi + +OUT=$(sh backup.sh) +EXPECTED="Creating dump of user database from postgres... +Uploading dump to flowmoco-s3-backup-test +SQL backup uploaded successfully" + +if [ "$OUT" != "$EXPECTED" ]; then + echo "Output '$OUT' does not equal expected '$EXPECTED'" + exit 1 +fi + +# apt-get update && apt-get install -y wget + +# wget "https://sample-videos.com/sql/Sample-SQL-File-10rows.sql" + + +# echo "Cleaning Up..." +# rm Sample-SQL-File-10rows.sql echo "This worked ok" From 949ec1bb71fcd1276ce2067f18f98fa95fa6c7cf Mon Sep 17 00:00:00 2001 From: Rob Harrison Date: Thu, 27 Jun 2019 18:02:24 +0100 Subject: [PATCH 9/9] Removed some space --- postgres-backup-s3/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/postgres-backup-s3/Dockerfile b/postgres-backup-s3/Dockerfile index 59014f9..54fa911 100644 --- a/postgres-backup-s3/Dockerfile +++ b/postgres-backup-s3/Dockerfile @@ -25,6 +25,4 @@ ADD backup.sh backup.sh ADD integration-tests.sh integration-tests.sh ADD config/sample_sql_file.sql sample_sql_file.sql - - CMD ["sh", "run.sh"]