The graceful stop feature allows you to safely abort a running ocs-ci test execution by creating a stop file in the repository root directory. This ensures that the currently running test completes properly with all fixtures and teardown operations, while skipping all remaining tests in the queue.
There are two stop file options available:
Creates a stop file that skips log collection for faster termination.
Usage:
# SSH to the executor where ocs-ci is running
cd /path/to/ocs-ci
# Create the stop file
touch .stopBehavior:
- Current test completes normally with all fixtures and teardown
- Test results are recorded (passed/failed/skipped)
- Log collection is skipped for failed tests
- All remaining tests are skipped
- Faster termination
Use when:
- You need to stop quickly
- Logs are not critical
- You want to minimize execution time
Creates a stop file that allows log collection to proceed normally.
Usage:
# SSH to the executor where ocs-ci is running
cd /path/to/ocs-ci
# Create the graceful stop file
touch .stop_gracefullyBehavior:
- Current test completes normally with all fixtures and teardown
- Test results are recorded (passed/failed/skipped)
- Log collection proceeds normally for failed tests (must-gather, etc.)
- All remaining tests are skipped
- Takes longer due to log collection
Use when:
- You need logs from the current test
- Debugging is important
- You can wait for log collection to complete
- Before each test starts, the framework checks for the presence of
.stopor.stop_gracefullyfiles in the repository root directory (TOP_DIR) - The check happens in the
pytest_runtest_setuphook
- Stop file detected: Framework logs a warning message
- Current test: Completes normally with all setup/teardown
- Test results: Written to
failed_testcases.txt,passed_testcases.txt, orskipped_testcases.txt - Log collection:
.stop: Skipped.stop_gracefully: Proceeds normally
- Remaining tests: All skipped with appropriate skip message
- Fixtures: All teardown/finalizers execute properly
The feature fully supports multicluster scenarios:
- Stop flags are set in the RUN config for all clusters
- Log collection behavior is consistent across all clusters
- Each cluster's context respects the stop flags
# You're running a 100-test suite and want to stop after test 25
ssh executor-host
cd /path/to/ocs-ci
touch .stop
# Result:
# - Test 25 completes
# - Tests 26-100 are skipped
# - No log collection
# - Clean teardown of all resources# Test is failing and you want logs before stopping
ssh executor-host
cd /path/to/ocs-ci
touch .stop_gracefully
# Result:
# - Current test completes
# - Logs collected if test fails
# - Remaining tests skipped
# - Clean teardown of all resources# If you change your mind, just remove the file
rm .stop
# or
rm .stop_gracefully
# Tests will continue normallyWARNING: Stop file detected at /path/to/ocs-ci/.stop.
Current test will complete without log collection, remaining tests will be skipped.
Skipping test: tests/functional/... - Stop requested via .stop file - skipping log collection
INFO: Skipping log collection due to .stop file - use .stop_gracefully if you want logs collected
WARNING: Graceful stop file detected at /path/to/ocs-ci/.stop_gracefully.
Current test will complete with log collection, remaining tests will be skipped.
Skipping test: tests/functional/... - Graceful stop requested via .stop_gracefully file
-
ocs_ci/framework/pytest_customization/ocscilib.py:check_stop_file(): Checks for stop filesset_stop_flags_for_all_clusters(): Sets flags in configpytest_runtest_setup(): Hook that checks before each testpytest_runtest_makereport(): Hook that controls log collection
-
ocs_ci/ocs/constants.py:TOP_DIR: Repository root directory constant
The following flags are set in ocsci_config.RUN:
stop_requested(bool): True when any stop file is detectedgraceful_stop(bool): True for.stop_gracefully, False for.stop
- Use
.stop_gracefullyby default unless you're in a hurry - Remove stop files after use to avoid accidentally stopping future runs
- Check logs to confirm the stop was detected and processed correctly
- Wait for current test to complete - don't force kill the process
- Verify cleanup after stop to ensure no resources are left behind
- Check file location: Must be in repository root (
TOP_DIR), not in a subdirectory - Check file name: Must be exactly
.stopor.stop_gracefully(note the leading dot) - Check timing: File must exist before the next test starts
- Check permissions: Ensure you have write access to create the file
- The current test must complete first
- Wait for fixtures and teardown to finish
- Check logs for stop detection messages
- Verify the file name is exactly
.stop_gracefully - Check that
--collect-logswas passed to run-ci - Review log messages for any errors during collection
| Method | Current Test | Fixtures | Log Collection | Remaining Tests | Safety |
|---|---|---|---|---|---|
.stop |
✅ Completes | ✅ Runs | ❌ Skipped | ⏭️ Skipped | ✅ Safe |
.stop_gracefully |
✅ Completes | ✅ Runs | ✅ Runs | ⏭️ Skipped | ✅ Safe |
Ctrl+C (once) |
✅ Completes | ✅ Runs | ✅ Runs | ❌ Aborted | |
Ctrl+C (twice) |
❌ Aborted | ❌ Skipped | ❌ Skipped | ❌ Aborted | ❌ Unsafe |
kill -9 |
❌ Killed | ❌ Skipped | ❌ Skipped | ❌ Killed | ❌ Unsafe |
kill -TERM |
✅ Completes | ✅ Runs | ✅ Runs | ❌ Aborted | ✅ Safe |
Potential improvements for this feature:
- Web UI to create/remove stop files remotely
- Email notification when stop is detected
- Configurable stop behavior per test suite
- Stop after N more tests instead of immediately
- Integration with CI/CD pipelines