github.com/mackerelio/mackerel-agent-plugins@v0.89.3/mackerel-plugin-postgres/test.sh (about)

     1  #!/bin/sh
     2  
     3  prog=$(basename $0)
     4  if ! [ -S /var/run/docker.sock ]
     5  then
     6  	echo "$prog: there are no running docker" >&2
     7  	exit 2
     8  fi
     9  
    10  cd $(dirname $0)
    11  PATH=$(pwd):$PATH
    12  plugin=$(basename $(pwd))
    13  if ! which $plugin >/dev/null
    14  then
    15  	echo "$prog: $plugin is not installed" >&2
    16  	exit 2
    17  fi
    18  
    19  user=postgres
    20  password=passpass
    21  docker run -d \
    22  	--name test-$plugin \
    23  	-p 15432:5432 \
    24  	-e POSTGRES_PASSWORD=$password postgres:11
    25  trap 'docker stop test-$plugin; docker rm test-$plugin; exit' EXIT
    26  sleep 10
    27  
    28  exec $plugin -port 15432 -user=$user -password $password