Skip to content

Commit

Permalink
Make: support for commands to be passed in tests
Browse files Browse the repository at this point in the history
To be able to test running caramel with commands only for example, ability to
pass commands to thbe tools/scripts is needed.
  • Loading branch information
teoti001 committed Jul 27, 2021
1 parent c0847e8 commit 5018231
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ $(CARAMEL_TOOL): $(PYTHON3) setup.py
gen-db%: $(CARAMEL_TOOL)
@$(BOLD); echo "Create a new DB at $(DB_FILE)";\
$(BLR);
$(VENV)/bin/caramel_initialize_db
$(VENV)/bin/caramel_initialize_db $(CARAMEL_COMMAND_LINE)
@$(BLR)

# Generate a new CA cert and key pair
.PHONY: ca-cert%
ca-cert%: $(CARAMEL_TOOL)
@$(BOLD); echo "Generate new CA cert and key with tests/ca_test_input.txt";\
$(BLR)
$(VENV)/bin/caramel_ca < tests/ca_test_input.txt
$(VENV)/bin/caramel_ca $(CARAMEL_COMMAND_LINE) < tests/ca_test_input.txt
@$(BLR)

# Start caramel using pserve in the background, save PID to SERVER
Expand All @@ -81,6 +81,7 @@ $(SERVER)-env.pid: ca-cert-env gen-db-env
sleep 2s
@$(BLR)


# Start caramel using pserve in the background, save PID to SERVER
$(SERVER)-in%.pid: ca-cert-in% gen-db-in%
@ $(BOLD); echo "Start new caramel server in the background, sleep 2s to \
Expand Down Expand Up @@ -111,16 +112,39 @@ client-run%: $(SERVER)%.pid $(AUTOSIGN)%.pid
./scripts/client-example.sh $(VENV)
@$(BLR)


# Basic tests that caramel can be installed and run with test data,
.PHONY: systest%
systest: systest-env systest-ini systest-ini-env systest-ini-commandline
@ $(PASS); $(LINE);\
echo "Systest passed"; \
$(BLR)

# using environment variables for config
.PHONY: systest-env
systest-env: export CARAMEL_COMMAND_LINE =
systest-env: export CARAMEL_DBURL = $(DB_URL)
systest-env: export CARAMEL_CA_CERT = $(CA_CERT)
systest-env: export CARAMEL_CA_KEY = $(CA_KEY)
systest-env: export CARAMEL_HOST = 127.0.0.1
systest-env: export CARAMEL_PORT = 6543
systest-env: export CARAMEL_LOG_LEVEL = ERROR

# using only .ini-file for config on the command line
systest-ini: export CARAMEL_COMMAND_LINE = $(VENV)/development.ini

# using only .ini-file for config for server, rest ini from env
systest-ini-env: export CARAMEL_INI = $(VENV)/development.ini
$(SERVER)-ini-env.pid: export CARAMEL_COMMAND_LINE = $(VENV)/development.ini
$(AUTOSIGN)-db-ini-env.pid: export CARAMEL_COMMAND_LINE =
ca-cert-ini-env: export CARAMEL_COMMAND_LINE =
gen-db-ini-env: export CARAMEL_COMMAND_LINE =

# using only .ini-file for config for server, rest commandline
$(SERVER)-ini-commandline.pid: export CARAMEL_COMMAND_LINE = $(VENV)/development.ini
$(AUTOSIGN)-ini-commandline.pid: export CARAMEL_COMMAND_LINE = --dburl=$(DB_URL) --ca-cert="$(CA_CERT)" --ca-key="$(CA_KEY)"
ca-cert-ini-commandline: export CARAMEL_COMMAND_LINE = --ca-cert="$(CA_CERT)" --ca-key="$(CA_KEY)"
gen-db-ini-commandline: export CARAMEL_COMMAND_LINE = --dburl $(DB_URL)

systest-%: client-run-%
@kill $(shell cat $(SERVER)-$*.pid);\
if [ $$? -eq 0 ]; then \
Expand Down

0 comments on commit 5018231

Please sign in to comment.