Skip to content

Commit

Permalink
refactor: Randomized tests sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
PROFeNoM committed Feb 1, 2024
1 parent 819521f commit fa223f5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/randomized/lib/MakefileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function generate($destination, array $scenarioNames)
{
$targetsString = sprintf(
implode(
" \\\n ",
" \\\n\t",
array_map(
function ($identifier) {
return "test.scenario.$identifier";
Expand Down
2 changes: 1 addition & 1 deletion tests/randomized/lib/run-base-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cd "$(dirname "$0")"

LOCK=/tmp/randomized-tests-lock-dir
DOCKER_LOGS_DIR=./../.tmp.scenarios/.results/$SCENARIO/docker-logs
DOCKER_LOGS_DIR=./../.tmp.scenarios/.results/docker-logs
while true; do
if mkdir $LOCK 2>/dev/null; then
trap "rmdir $LOCK" EXIT
Expand Down
10 changes: 2 additions & 8 deletions tests/randomized/lib/templates/Makefile.scenario.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ DURATION := 30s
SCENARIO := {{scenario_name}}

run: prepare_results_folders
@SCENARIO=$(SCENARIO) bash ../../lib/run-base-docker-compose.sh
sleep 1
@DURATION=$(DURATION) docker-compose up php-test-$(SCENARIO)
sleep 1
@docker-compose down
sleep 1
@SCENARIO=$(SCENARIO) bash ../../lib/run-base-docker-compose.sh shutdown
sleep 1

shell: prepare_results_folders
@SCENARIO=$(SCENARIO) bash ../../lib/run-base-docker-compose.sh
@bash ../../lib/run-base-docker-compose.sh
@docker-compose run --rm php-test-$(SCENARIO) bash
@docker-compose down
@SCENARIO=$(SCENARIO) bash ../../lib/run-base-docker-compose.sh shutdown
@bash ../../lib/run-base-docker-compose.sh shutdown

prepare_results_folders:
@rm -rf $(RESULTS_DIR)/$(SCENARIO)
Expand Down
17 changes: 16 additions & 1 deletion tests/randomized/lib/templates/Makefile.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
.SHELLFLAGS = -e
DURATION := 30s
RESULTS_DIR := .results

test.scenario.%:
@make -C $(*) run DURATION=$(DURATION)

shell.scenario.%:
@make -C $(*) shell

test: {{test_targets}}
test: prepare_docker_logs_folder \
start_base_docker \
{{test_targets}} \
shutdown_base_docker

prepare_docker_logs_folder:
@mkdir -p $(RESULTS_DIR)/docker-logs
@chmod -R a+w $(RESULTS_DIR)/docker-logs

start_base_docker:
@bash ../lib/run-base-docker-compose.sh

shutdown_base_docker:
@bash ../lib/run-base-docker-compose.sh shutdown

# keep this line to avoid whitespace errors with generated files

0 comments on commit fa223f5

Please sign in to comment.