Skip to content

fix(tests): generate log records with utc timestamps#237

Merged
yordis merged 1 commit intomasterfrom
yordis/fix-utc-test-log-records
May 9, 2026
Merged

fix(tests): generate log records with utc timestamps#237
yordis merged 1 commit intomasterfrom
yordis/fix-utc-test-log-records

Conversation

@yordis
Copy link
Copy Markdown
Member

@yordis yordis commented May 8, 2026

  • Keep test-generated log records stable across local timezone boundaries.
  • Reduce timestamp-kind drift in storage and projection fixtures that behave like event data.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 8, 2026

PR Summary

Low Risk
Test-only changes that standardize timestamps to UTC to avoid timezone-dependent failures; minimal risk outside of potentially surfacing hidden assumptions in existing tests.

Overview
Standardizes test log-record timestamps to UTC. Updates multiple test fixtures that construct PrepareLogRecord, CommitLogRecord, SystemLogRecord, and EventRecord to use DateTime.UtcNow instead of DateTime.Now (including a UtcNow.Ticks-based timestamp in PrepareLogRecordViewTests) so serialized record data is stable across local timezone boundaries.

Also includes a small import reordering in StreamBasedAuthPolicyRegistryTests with no behavior change.

Reviewed by Cursor Bugbot for commit 9871438. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@yordis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 41 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 559bb4f5-dca0-4a78-a6d3-58cdc092a3b2

📥 Commits

Reviewing files that changed from the base of the PR and between 68f55cf and 9871438.

📒 Files selected for processing (7)
  • src/EventStore.Core.Tests/Services/Storage/WriteEventsToIndexScenario.cs
  • src/EventStore.Core.XUnit.Tests/Authorization/StreamBasedAuthPolicyRegistryTests.cs
  • src/EventStore.Core.XUnit.Tests/Index/IndexTrackerTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/Chunks/TFChunkTrackerTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/SizeOnDiskTests.cs
  • src/EventStore.Projections.Core.Javascript.Tests/Integration/SubsystemScenario.cs

Walkthrough

This PR standardizes test timestamps across seven test files by replacing DateTime.Now with DateTime.UtcNow in log record and event record helper methods and fixtures. No public APIs or test logic are altered; only the timestamp source is changed to UTC semantics in in-memory test data construction.

Changes

Test Timestamp Standardization to UTC

Layer / File(s) Summary
Core Storage Test Infrastructure
src/EventStore.Core.Tests/Services/Storage/WriteEventsToIndexScenario.cs, src/EventStore.Core.XUnit.Tests/TransactionLog/Chunks/TFChunkTrackerTests.cs
CreatePrepareLogRecord, CreatePrepareLogRecords, CreateCommitLogRecord (WriteEventsToIndexScenario) and CreatePrepare, CreateSystemRecord, CreateCommit (TFChunkTrackerTests) now use DateTime.UtcNow instead of DateTime.Now.
Index and Tracking Tests
src/EventStore.Core.XUnit.Tests/Index/IndexTrackerTests.cs
CreatePrepare() helper method updates PrepareLogRecord timestamp to DateTime.UtcNow.
Serialization and View Tests
src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs, src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/SizeOnDiskTests.cs
_timestamp fixture field (PrepareLogRecordViewTests) and record factory helpers CreatePrepareLogRecord, CreateCommitLogRecord, CreateSystemLogRecord (SizeOnDiskTests) switched to DateTime.UtcNow.
Authorization, Resolution, and Integration Tests
src/EventStore.Core.XUnit.Tests/Authorization/StreamBasedAuthPolicyRegistryTests.cs, src/EventStore.Projections.Core.Javascript.Tests/Integration/SubsystemScenario.cs
StreamBasedAuthPolicyRegistryTests reorders using directives and updates CreateResolvedEvent timestamp. SubsystemScenario.MiniStore.WriteEvents switches EventRecord timestamp to DateTime.UtcNow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Poem

🐰 A whisker of time, now running true,
Local clocks fade, all greet the UTC dew,
From core to edge, each test now gleams,
With UTC timestamps in their dreams.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: switching test log record generation from local time to UTC timestamps.
Description check ✅ Passed The description directly relates to the changeset, explaining the rationale for replacing DateTime.Now with DateTime.UtcNow in test fixtures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/fix-utc-test-log-records

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs`:
- Line 20: The test fails because _timestamp is set to DateTime.UtcNow
(Kind=Utc) while PrepareLogRecord stores only ticks and PrepareLogRecordView
recreates the DateTime via new DateTime(ticks) (Kind=Unspecified), so Equals
fails; fix by making the test use an Unspecified-kind DateTime that matches the
deserializer (change the _timestamp in PrepareLogRecordViewTests to construct
the expected value with the same ticks/kind produced by
PrepareLogRecord/PrepareLogRecordView—e.g., use new
DateTime(DateTime.UtcNow.Ticks) or explicitly new DateTime(ticks) so
Kind=Unspecified), or alternatively implement round-trip Kind preservation in
PrepareLogRecord.Serialize/PrepareLogRecordView.Deserialize by storing/restoring
DateTime.Kind alongside the 8 tick bytes; update either _timestamp in the test
or the serialize/deserialize in PrepareLogRecord/PrepareLogRecordView
accordingly so ticks and Kind match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7f7d1b8-5a78-4517-8023-88c34cff699d

📥 Commits

Reviewing files that changed from the base of the PR and between 6f1e444 and 68f55cf.

📒 Files selected for processing (7)
  • src/EventStore.Core.Tests/Services/Storage/WriteEventsToIndexScenario.cs
  • src/EventStore.Core.XUnit.Tests/Authorization/StreamBasedAuthPolicyRegistryTests.cs
  • src/EventStore.Core.XUnit.Tests/Index/IndexTrackerTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/Chunks/TFChunkTrackerTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs
  • src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/SizeOnDiskTests.cs
  • src/EventStore.Projections.Core.Javascript.Tests/Integration/SubsystemScenario.cs

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/fix-utc-test-log-records branch from 68f55cf to 9871438 Compare May 8, 2026 22:46
@yordis yordis merged commit c0b9cb6 into master May 9, 2026
22 checks passed
@yordis yordis deleted the yordis/fix-utc-test-log-records branch May 9, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant