Skip to content

Conversation

@balazs-szucs
Copy link
Collaborator

@balazs-szucs balazs-szucs commented Oct 19, 2025

Description of Changes

Updated test files to use fixed string identifiers and timestamps instead of random UUIDs and system-dependent times. These changes make the tests more deterministic and easier to debug.

Test determinism and clarity improvements:

  • Replaced randomly generated UUIDs with fixed string identifiers in test cases for FileStorageTest.java and TaskManagerTest.java to ensure predictable test data.
  • Changed usages of System.currentTimeMillis() and Instant.now() to fixed values in tests for TempFileCleanupServiceTest.java, FileMonitorTest.java, and TextFinderTest.java to avoid flakiness due to timing issues.
  • Improved code clarity by adding explanatory comments for time offsets and by using direct string comparisons instead of equals() where appropriate.
  • Refactored a timeout simulation in JobExecutorServiceTest.java to use busy-waiting instead of Thread.sleep, reducing test flakiness and improving reliability.

Checklist

General

Documentation

UI Changes (if applicable)

  • Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)

Testing (if applicable)

  • I have tested my changes locally. Refer to the Testing Guide for more details.
…ed values and improve test stability by removing `Thread.sleep` with busy-wait loops and consistent timestamps.

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Copilot AI review requested due to automatic review settings October 19, 2025 19:57
@dosubot dosubot bot added the size:M This PR changes 30-99 lines ignoring generated files. label Oct 19, 2025
@stirlingbot stirlingbot bot added Test Testing-related issues or pull requests refactor Code changes that neither fix a bug nor add a feature labels Oct 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors tests to reduce flakiness by eliminating randomness and system-time dependencies, standardizing string identifiers, and clarifying time-based logic. Also disables a particularly flaky test and adjusts a timeout simulation approach.

  • Replace random UUIDs with deterministic string IDs in tests
  • Swap time-dependent calls with fixed or clearer time values and comments
  • Disable a flaky recursive cleanup test; change a timeout simulation from sleep to a busy-wait loop

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/core/src/test/java/stirling/software/SPDF/pdf/TextFinderTest.java Use fixed start/end timestamps to avoid timing flakiness.
app/common/src/test/java/stirling/software/common/util/FileMonitorTest.java Set deterministic lastModifiedTime values for test files/dirs.
app/common/src/test/java/stirling/software/common/service/TempFileCleanupServiceTest.java Clarify comments, NPE-safe string comparisons, fixed timestamps in one test, and disable a flaky test.
app/common/src/test/java/stirling/software/common/service/TaskManagerTest.java Replace UUIDs with fixed job IDs.
app/common/src/test/java/stirling/software/common/service/ResourceMonitorTest.java Clarify relative time via comment.
app/common/src/test/java/stirling/software/common/service/JobExecutorServiceTest.java Replace Thread.sleep with a busy-wait to simulate long-running work.
app/common/src/test/java/stirling/software/common/service/FileStorageTest.java Replace UUIDs with fixed file IDs.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

balazs-szucs and others added 3 commits October 19, 2025 22:02
…FileCleanupServiceTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
… by enhancing file timestamp mocking and removing debug prints.

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
@dosubot dosubot bot added size:L This PR changes 100-499 lines ignoring generated files. and removed size:M This PR changes 30-99 lines ignoring generated files. labels Oct 20, 2025
…meMillis` and `Instant.now` with deterministic test timestamps.

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
@balazs-szucs balazs-szucs added the Priority: Low Issues or pull requests with low priority label Oct 20, 2025
Ludy87
Ludy87 previously approved these changes Oct 30, 2025
# Conflicts:
#	app/common/src/test/java/stirling/software/common/model/FileInfoTest.java
#	app/common/src/test/java/stirling/software/common/service/TaskManagerTest.java
#	app/common/src/test/java/stirling/software/common/service/TempFileCleanupServiceTest.java
- Changed private constants `TEST_MOD_DATE` and `TEST_CREATION_DATE` to package-private for reuse.
- Reformatted nested `DateFormattingTests` for consistent indentation.
- Updated test assertions to use prefixed constants for better clarity.
- Removed redundant closing bracket.

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
- Replaced test timestamps with a fixed `FIXED_NOW` constant for deterministic testing.
- Updated test assertions to use adjusted timestamps for modifications and creations (e.g., `FIXED_NOW`, `FIXED_NOW.minusDays(1)`).
- Simplified file path construction using static strings instead of `File.separator`.
- Added test cases for null handling in modification and creation dates.
- Added tests for edge cases in file size formatting (e.g., rounding for KB, large sizes in GB).

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Low Issues or pull requests with low priority refactor Code changes that neither fix a bug nor add a feature size:L This PR changes 100-499 lines ignoring generated files. Test Testing-related issues or pull requests

2 participants