github.com/mackerelio/mackerel-agent-plugins@v0.89.3/mackerel-plugin-elasticsearch/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 password=passpass 20 port=9200 21 docker run -d \ 22 --name test-$plugin \ 23 -p $port:$port \ 24 -e "ELASTIC_PASSWORD=$password" \ 25 -e "discovery.type=single-node" \ 26 -e "ingest.geoip.downloader.enabled=false" \ 27 elasticsearch:8.5.0 28 trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 29 30 # to store previous value to calculate a diff of metrics 31 ../tool/waituntil.bash -n 300 $plugin -scheme https -port $port -user=elastic -password $password -insecure -suppress-missing-error >/dev/null 2>&1 32 33 sleep 1 34 35 $plugin -scheme https -port $port -user=elastic -password $password -insecure -suppress-missing-error | graphite-metric-test -f rule.txt 36 status=$? 37 38 docker stop "test-$plugin" 39 docker rm "test-$plugin" 40 exit $status