Skip to content

Commit

Permalink
Local s3-plugin testing using Minio
Browse files Browse the repository at this point in the history
Minio is an s3 compliant object store. A Minio server can be setup
locally and used to test our s3 plugin. This make local testing of our
s3 plugin possible and easy without going through the trouble of needing
to setup Amazon S3 just for a testing endpoint. Created a new makefile
rule to setup a Minio server using docker, run our plugin_test against
the s3 plugin, and tear it down.

Co-authored-by: Kevin Yeap <kyeap@vmware.com>
Co-authored-by: Brent Doil <bdoil@vmware.com>
  • Loading branch information
kyeap-vmware and bmdoil committed Dec 8, 2021
1 parent 3a9a4f5 commit 9950492
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ clean :
rm -f $(BIN_DIR)/$(BACKUP) $(BACKUP) $(BIN_DIR)/$(RESTORE) $(RESTORE) $(BIN_DIR)/$(HELPER) $(HELPER)
# Test artifacts
rm -rf /tmp/go-build* /tmp/gexec_artifacts* /tmp/ginkgo*
docker stop s3-minio # stop minio before removing its data directories
docker rm s3-minio
rm -rf /tmp/minio
rm -f /tmp/minio_config.yaml
# Code coverage files
rm -rf /tmp/cover* /tmp/unit*
go clean -i -r -x -testcache -modcache
Expand All @@ -126,3 +130,12 @@ info-report:
@echo "Info and verbose messaging:"
@echo ""
@ag "gplog.Info|gplog.Verbose" --ignore "*_test*"

test-s3-local: build install
${PWD}/plugins/generate_minio_config.sh
mkdir -p /tmp/minio/gpbackup-s3-test
docker run -d --name s3-minio -p 9000:9000 -p 9001:9001 -v /tmp/minio:/data/minio quay.io/minio/minio server /data/minio --console-address ":9001"
sleep 2 # Wait for minio server to start up
${PWD}/plugins/plugin_test.sh $(BIN_DIR)/gpbackup_s3_plugin /tmp/minio_config.yaml
docker stop s3-minio
docker rm s3-minio
11 changes: 11 additions & 0 deletions plugins/generate_minio_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cat <<MINIO_CONFIG > /tmp/minio_config.yaml
executablepath: $(which gpbackup_s3_plugin)
options:
endpoint: http://localhost:9000/
aws_access_key_id: minioadmin
aws_secret_access_key: minioadmin
bucket: gpbackup-s3-test
folder: test/backup
MINIO_CONFIG

0 comments on commit 9950492

Please sign in to comment.