Skip to content

Commit

Permalink
Merge pull request #365 from lufia/add-test-psql
Browse files Browse the repository at this point in the history
[check-postgresql] add test.sh
  • Loading branch information
lufia committed May 26, 2020
2 parents 1cd1e5b + 11397dd commit b5c422b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
11 changes: 11 additions & 0 deletions check-postgresql/UPDATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# How to check the plugin

## Requirements

* dockerd

## Steps

* Run postgres:11
* Run the plugin standalone
* Check the exit code
32 changes: 32 additions & 0 deletions check-postgresql/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

prog=$(basename $0)
if ! [[ -S /var/run/docker.sock ]]
then
echo "$prog: there are no running docker" >&2
exit 2
fi

cd $(dirname $0)
plugin=$(basename $(pwd))
if ! which -s $plugin
then
echo "$prog: $plugin is not installed" >&2
exit 2
fi

user=postgres
password=passpass
docker run -d \
--name test-$plugin \
-p 15432:5432 \
-e POSTGRES_PASSWORD=$password postgres:11
trap 'docker stop test-$plugin; docker rm test-$plugin; exit' EXIT
sleep 10

if $plugin connection --port 15432 --user=$user --password=$password >/dev/null 2>&1
then
echo OK
else
echo FAIL
fi

0 comments on commit b5c422b

Please sign in to comment.