Skip to content

test(lola): verify skeleton event timestamp after reopen#408

Open
rudresh-systream wants to merge 4 commits into
eclipse-score:mainfrom
rudresh-systream:feature/87-skeleton-event-current-timestamp
Open

test(lola): verify skeleton event timestamp after reopen#408
rudresh-systream wants to merge 4 commits into
eclipse-score:mainfrom
rudresh-systream:feature/87-skeleton-event-current-timestamp

Conversation

@rudresh-systream
Copy link
Copy Markdown

@rudresh-systream rudresh-systream commented May 12, 2026

What
Add a test that check that current_timestamp_ is set correctly.
It should be possible to inject your own EventDataControl which has some preset slot values using ExpectControlSegmentOpened() in the SkeletonMockedMemoryFixture.

How
No response

Estimates for realization
Effort low
No impact on users expected
Category

Affects Detailed Design

Summary:
This PR addresses issue #87: “Add unit test in skeleton_event.h for checking timestamp”.

The ticket asks for unit-test coverage to verify that current_timestamp_ is set correctly. The important scenario is not only the normal Send() path, but also the reopened/shared-memory path where existing EventDataControl already contains preset slot timestamp values. The test validates that SkeletonEvent correctly continues the timestamp sequence from the existing slot data.

link: #87

Changes made:

  1. Updated:
    score/mw/com/impl/bindings/lola/skeleton_event_test.cpp

    Added a new unit test:
    SkeletonEventTimestampFixture.PrepareOfferInitializesCurrentTimestampFromReopenedControlData

    This test:

    • Creates preset QM and ASIL-B ServiceDataControl objects.
    • Sets an existing event slot as ready with timestamp 42.
    • Injects these preset controls through the mocked shared-memory open path.
    • Calls PrepareOffer().
    • Allocates and sends a new sample.
    • Verifies that the newly sent sample gets timestamp 43.
  2. Updated:
    score/mw/com/impl/bindings/lola/test/skeleton_test_resources.h

    Added helper declarations:

    • ExpectControlSegmentOpened(...)
    • ExpectDataSegmentOpened(...)
  3. Updated:
    score/mw/com/impl/bindings/lola/test/skeleton_test_resources.cpp

    Added helper implementations to allow SkeletonMockedMemoryFixture tests to inject existing control/data shared-memory objects instead of always creating fresh memory objects.

Why the changes were made:
The existing timestamp coverage only checked normal timestamp incrementing during Send(). That proves the fresh/default case, but it does not prove the ticket requirement: that current_timestamp_ is initialized correctly when existing EventDataControl with preset slot values is reopened.

This new test covers the intended partial-restart/reopen scenario. If the existing shared-memory slot has timestamp 42, the next sent event must use timestamp 43. This verifies that timestamp continuity is preserved.

Alternatives considered:

  1. Test only normal Send() timestamp increments.

    • Rejected because this path was already covered and does not validate injected/preset EventDataControl slot values.
  2. Directly expose or read current_timestamp_ using friend access or an attorney helper.

    • Rejected because it would make the test tightly coupled to a private implementation detail.
  3. Verify behavior through externally observable timestamp output after injecting preset control data.

    • Chosen because it follows the ticket request, uses the existing SkeletonMockedMemoryFixture pattern, and validates the real behavior without exposing internal state.

Build and test results:
The focused unit test was executed with:

bazel test //score/mw/com/impl/bindings/lola:skeleton_event_test
--test_filter=SkeletonEventTimestampFixture.PrepareOfferInitializesCurrentTimestampFromReopenedControlData
--test_output=all

Result:

  • 1 test suite executed.
  • 1 test executed.
  • 1 test passed.
  • Test runtime reported by Google Test: 32 ms total.
  • Bazel reported: Build completed successfully, 8 total actions.
  • Bazel reported: //score/mw/com/impl/bindings/lola:skeleton_event_test PASSED in 1.6s.
  • Final result: Executed 1 out of 1 test: 1 test passes.

The LoLa package build was executed with:

bazel build //score/mw/com/impl/bindings/lola:all

Result:

  • 117 targets found/analyzed.
  • Build completed successfully.
  • Bazel reported: Build completed successfully, 201 total actions.
  • Elapsed time: 957.347s.
  • Critical path: 90.34s.

The wider LoLa test suite was executed with:

bazel test //score/mw/com/impl/bindings/lola/... --test_output=errors

Result:

  • 92 targets and 67 test targets found.
  • Build completed successfully.
  • Bazel reported: Build completed successfully, 25 total actions.
  • Visible test output shows LoLa tests passing/cached, including event data control, event data storage, event slot status, partial restart path builder, and other related LoLa tests.

The wider COM test command was also run:

bazel test //score/mw/com/... --test_output=errors

Result:

  • 962 targets and 248 test targets found.
  • Build completed successfully.
  • Bazel reported: Build completed successfully, 85 total actions.
  • Visible output shows COM and LoLa related tests passing/cached.

Verification:
The new test verifies the required timestamp behavior by setting an existing slot timestamp to 42 and confirming that the next sent sample receives timestamp 43 after PrepareOffer(). This confirms that SkeletonEvent initializes/continues current_timestamp_ correctly from reopened EventDataControl state.

Branch used:
feature/87-skeleton-event-current-timestamp

Linked issue:
Closes #87

Signed-off-by: Rudresh Shirwal <rudresh.shirwal@systream.io>
<< "The second timestamp should be exactly one greater than the first.";
}

TEST_F(SkeletonEventTimestampFixture, PrepareOfferInitializesCurrentTimestampFromReopenedControlData)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add the "Given/Expect that/when/then" comments like in the other test cases. Makes reading/understanding the test so much clearer.

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.

Add unit test in skeleton_event.h for checking timestamp

2 participants