Skip to content

cleanup test directories before running tests#826

Open
Edu92337 wants to merge 2 commits intogetfloresta:masterfrom
Edu92337:functional-tests
Open

cleanup test directories before running tests#826
Edu92337 wants to merge 2 commits intogetfloresta:masterfrom
Edu92337:functional-tests

Conversation

@Edu92337
Copy link
Contributor

@Edu92337 Edu92337 commented Feb 4, 2026

Related to #760 (mitigation)

Keep unconditional /data cleanup at start
Make /logs cleanup conditional on --preserve-data-dir flag
Prevents reusing old log state between test runs
Description and Notes
Currently, the cleanup of /logs directory happens at the END of test execution and only if tests pass. This causes:

Failed tests leave corrupted log state for next run
Tests may fail when run multiple times without manual cleanup
This PR provides a temporary mitigation by making /logs cleanup conditional on the --preserve-data-dir flag, while keeping /data unconditionally cleaned at start.

Note: This is a partial fix. Complete resolution will come in a follow-up PR after #742 is merged, where cleanup logic will be migrated to the Python runner for better control over test data management.

How to verify the changes you have done?

Test 1: Run tests multiple times

./tests/prepare.sh
./tests/run.sh
./tests/run.sh # Should work without manual cleanup

Test 2: Preserve logs for debugging

./tests/run.sh --preserve-data-dir
ls -la $FLORESTA_TEMP_DIR/logs # Logs preserved
Next Steps
After #742 is merged, I plan to submit a follow-up PR to:

Migrate cleanup logic to the Python test runner
Provide more granular control over test data management
Fully resolve #760
Contributor Checklist
I've followed the contribution guidelines
I've verified one of the following:
Ran just pcc (skipped - changes are bash-only, validated manually)
Ran just lint-features '-- -D warnings' && cargo test --release (not applicable)
Confirmed CI passed on my fork (will run after PR creation)
I've linked any related issue(s) in the sections above
Manual validation performed:

✅ Bash syntax check (bash -n)
✅ Logic tested with simulations
✅ --preserve-data-dir flag tested
✅ Consecutive test runs verified

@Davidson-Souza
Copy link
Member

The PR title could be a bit more descriptive. Also, please squash the last two commits onto the first

@Edu92337 Edu92337 changed the title Functional tests cleanup test directories before running tests Feb 4, 2026
@Edu92337 Edu92337 force-pushed the functional-tests branch 2 times, most recently from 4b0b6e8 to a8fe5ad Compare February 5, 2026 14:00
Fixes getfloresta#760

- Keep unconditional /data cleanup at start
- Make /logs cleanup conditional on --preserve-data-dir flag

fi

# Clean existing data/logs directories before running the tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this comment here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Functional tests failing if you dont clean datadir

3 participants