Skip to content

Conversation

@mherwege
Copy link
Contributor

@mherwege mherwege commented Aug 20, 2025

See discussion: #4818 (comment)

This reduces the impact of now() on the persistence extensions test reliability. There only was a major impact for average on OnOff types. This impact has been removed by not testing the AverageSince and AverageUntil methods, only the AverageBetween method.

@jimtng @Nadahar FYI

EDIT: I am running the tests with a sleep of 1 minute on every query to the persistence service. If this succeeds, I consider the persistence extension tests to be independent from the current time for all practical purposes.

@mherwege mherwege requested a review from a team as a code owner August 20, 2025 07:52
@mherwege mherwege marked this pull request as draft August 20, 2025 09:54
@wborn wborn requested a review from Copilot August 20, 2025 13:04
Copy link

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

This PR fixes reliability issues in persistence extensions tests by reducing the impact of timing dependencies on test outcomes. The main change is eliminating tests that rely on the current time (now()) for OnOff type average calculations, specifically removing AverageSince and AverageUntil tests in favor of only testing AverageBetween.

Key changes:

  • Replaces hardcoded year values with dynamic calculations based on current year to reduce time dependencies
  • Removes time-sensitive average tests for OnOff types (AverageSince and AverageUntil)
  • Consolidates Riemann sum tests to use only RiemannSumBetween method
  • Includes commented-out debugging code for adding delays to test queries

Reviewed Changes

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

File Description
TestPersistenceService.java Updates hardcoded year constants to be relative to current year and adds a now() helper method
TestCachedValuesPersistenceService.java Adds commented debugging code for introducing delays in persistence queries
PersistenceExtensionsTest.java Removes AverageSince/AverageUntil tests and consolidates to AverageBetween tests only

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

@mherwege
Copy link
Contributor Author

I have removed 2 more tests to reduce potential issues. All remaining tests now work even if there would be a 1 minute delay in the persistence query (tested with 1 minute, but I expect it can even be more). I think that should cover stability issues.

@mherwege mherwege marked this pull request as ready for review August 20, 2025 17:23
@mherwege
Copy link
Contributor Author

This is now ready for review.

Copy link
Member

@holgerfriedrich holgerfriedrich left a comment

Choose a reason for hiding this comment

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

Thanks!

@holgerfriedrich holgerfriedrich merged commit 75ceb0f into openhab:main Sep 16, 2025
4 checks passed
@holgerfriedrich holgerfriedrich added this to the 5.1 milestone Sep 16, 2025
@mherwege mherwege deleted the persistence_tests branch September 16, 2025 21:07
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.

2 participants