diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9e8e5ab --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +# Help +.SILENT: +.PHONY: help + +help: ## Display this help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# Docker +docker-up: ## start docker elasticsearch server + docker-compose up -d elasticsearch +docker-down: ## start docker elasticsearch server + docker-compose down + +# Testing +test: test-unit test-behavior ## launch full test suite +test-unit: ## launch unit tests + ./vendor/bin/atoum +test-behavior: docker-up ## launch behavior tests + ./scripts/waitForElastic.sh + ./vendor/bin/behat + make docker-down + diff --git a/scripts/waitForElastic.sh b/scripts/waitForElastic.sh new file mode 100755 index 0000000..7b901c0 --- /dev/null +++ b/scripts/waitForElastic.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +echo -n "Waiting for elasticsearch to be ready ..." + +code=`curl --write-out %{http_code} --silent --output /dev/null http://localhost:9200/_cluster/health`; +iteration=0; + +while [ $code -ne 200 ] ; do + sleep 1; + /bin/echo -n "."; + + code=`curl --write-out %{http_code} --silent --output /dev/null http://localhost:9200/_cluster/health`; + iteration=`expr $iteration + 1`; + + if [ $iteration -gt 180 ]; then + echo "TIMEOUT !" + exit 1; + fi +done; + +echo " READY !" ; +exit 0;