

PYTHON=python
VERTICA_PYTHON=/opt/vertica/oss/python/lib/python2.7/site-packages
VERTICA_MODULE=$(CURDIR)/../../tools
MODULES=${VERTICA_MODULE}:${VERTICA_PYTHON}
CONFIGDIR=./test

BASE_URL="http://localhost:5444"

setup:
	@cd ..; PYTHONPATH=${MODULES} TARGET=${CONFIGDIR} ${PYTHON} ./simply_fast.py -i & echo "$$!" > ${CONFIGDIR}/log/agent.pid
	@# Allow the agent to startup completely before moving on to other targets
	@sleep 3

stop:
	@echo "Stopping agent .... "
	@kill -9 $(shell cat log/agent.pid)
	@rm log/agent.pid


databases: stop setup dbget dbpost

dbget:
	@rm -f results/databases results/databases.diff
	@cd results; wget -o databases.wget ${BASE_URL}/databases 
	@diff expected/databases results/databases > results/databases.diff; STAT=$$?; echo -ne  "Testing /databases\t\t";  if [ $$STAT -ne 0 ]; then echo "[FAILED]"; exit 1; else echo "[PASSED]"; fi
	
dbpost: 
	@wget --post-data "name=foo&passwd=bar&catalog=/tmp&data=/tmp&port=5666" http://localhost:5444/databases

