-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add TimeDaemon CIT with pip hub infrastructure #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gordon9901
wants to merge
16
commits into
eclipse-score:main
Choose a base branch
from
gordon9901:ecarx_time_daemon_cit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d4d2e1c
feat: add TimeDaemon CIT with pip hub infrastructure
gordon9901 03ad91c
Update Bazel lockfile
gordon9901 492fe60
feat: add TimeDaemon CIT with pip hub infrastructure
gordon9901 1a98719
style: apply clang-format to test scenario sources
gordon9901 7be7b78
drop premature MIT visibility from shm_ptp_engine
gordon9901 e8075f5
fix: address PR review comments on TimeDaemon CIT
gordon9901 df02744
update lock file
gordon9901 8e61df6
chore: add local clang-tidy config to silence noise
gordon9901 12dd06f
test(time_daemon/cit): narrow to multi-module integration
gordon9901 0b23511
test(time_daemon): move pipeline to gtest, drop redundant CIT scenarios
gordon9901 d562538
Merge branch 'main' into ecarx_time_daemon_cit
gordon9901 3a84524
merge: resolve MODULE.bazel conflict with origin/main
gordon9901 8cb00fc
merge: resolve MODULE.bazel.lock conflict with origin/main
gordon9901 048caf1
Merge branch 'main' into ecarx_time_daemon_cit
gordon9901 2a34095
Merge branch 'main' into ecarx_time_daemon_cit
gordon9901 4840af5
Merge branch 'main' into ecarx_time_daemon_cit
gordon9901 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| # Local clang-tidy overrides for the score_time module. | ||
| # | ||
| # The S-CORE baseline from @score_cpp_policies//clang_tidy:.clang-tidy is | ||
| # applied first; settings here are layered on top per clang-tidy's standard | ||
| # merge rules. Only module-specific suppressions belong here — do not remove | ||
| # baseline checks. | ||
|
|
||
| # Only analyze headers inside the score/ source tree. Without this, | ||
| # clang-tidy picks up warnings from externally provided headers | ||
| # (e.g. toolchain redacted_dates.h) that we cannot fix. | ||
| HeaderFilterRegex: 'score/' | ||
|
|
||
| # Suppress the builtin-macro-redefined diagnostic emitted by the LLVM | ||
| # toolchain's redacted_dates.h (which redefines __DATE__/__TIME__ for | ||
| # deterministic builds). This is injected by the toolchain via -include | ||
| # and is not user code, so suppressing it here is appropriate. | ||
| Checks: >- | ||
| -clang-diagnostic-builtin-macro-redefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...aemon/src/verification_machine/svt/svt_verification_machine_pipeline_integration_test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
| #include "score/time_daemon/src/common/data_types/ptp_time_info.h" | ||
| #include "score/time_daemon/src/ptp_machine/stub/factory.h" | ||
| #include "score/time_daemon/src/verification_machine/svt/factory.h" | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <chrono> | ||
| #include <future> | ||
|
|
||
| namespace score | ||
| { | ||
| namespace td | ||
| { | ||
|
|
||
| // Verifies that PtpTimeInfo published by GPTPStubMachine flows correctly through | ||
| // SvtVerificationMachine (SynchronizationValidator -> TimeoutValidator -> TimeJumpsValidator) | ||
| // and emerges with the expected status fields intact. | ||
| class VerificationPipelineIntegrationTest : public ::testing::Test | ||
| { | ||
| protected: | ||
| void SetUp() override | ||
| { | ||
| ptp_machine_ = CreateGPTPStubMachine("verif_pipeline_ptp"); | ||
| verifier_ = CreateSvtVerificationMachine("verif_pipeline"); | ||
|
|
||
| // Wire PTP machine output into the verification pipeline. | ||
| ptp_machine_->SetPublishCallback([this](const PtpTimeInfo& data) { | ||
| verifier_->OnMessage(data); | ||
| }); | ||
|
|
||
| // Capture the first data point that exits the verification pipeline. | ||
| verifier_->SetPublishCallback([this](const PtpTimeInfo& data) { | ||
| try | ||
| { | ||
| verified_promise_.set_value(data); | ||
| } | ||
| catch (const std::future_error&) | ||
| { | ||
| // Capture only the first verified data point. | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| void TearDown() override | ||
| { | ||
| ptp_machine_->Stop(); | ||
| } | ||
|
|
||
| std::shared_ptr<GPTPStubMachine> ptp_machine_; | ||
| std::shared_ptr<SvtVerificationMachine> verifier_; | ||
| std::promise<PtpTimeInfo> verified_promise_; | ||
| }; | ||
|
|
||
| TEST_F(VerificationPipelineIntegrationTest, DataFlowsThroughPipeline) | ||
| { | ||
| ASSERT_TRUE(verifier_->Init()); | ||
| ASSERT_TRUE(ptp_machine_->Init()); | ||
| ptp_machine_->Start(); | ||
|
|
||
| auto verified_future = verified_promise_.get_future(); | ||
| ASSERT_EQ(verified_future.wait_for(std::chrono::seconds(5)), std::future_status::ready); | ||
|
|
||
| const auto data = verified_future.get(); | ||
|
|
||
| // The stub always produces synchronized/correct data on its first publish; | ||
| // all three validators must let it through without flagging an anomaly. | ||
| EXPECT_TRUE(data.status.is_synchronized); | ||
| EXPECT_TRUE(data.status.is_correct); | ||
| EXPECT_FALSE(data.status.is_timeout); | ||
| EXPECT_FALSE(data.status.is_time_jump_future); | ||
| EXPECT_FALSE(data.status.is_time_jump_past); | ||
| EXPECT_GT(data.ptp_assumed_time.count(), 0); | ||
| } | ||
|
|
||
| } // namespace td | ||
| } // namespace score |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| load("@pip_time_daemon_venv//:requirements.bzl", "all_requirements") | ||
| load("@rules_python//python:pip.bzl", "compile_pip_requirements") | ||
| load("@score_tooling//python_basics:defs.bzl", "score_virtualenv") | ||
|
|
||
| # To regenerate requirements.txt.lock after editing requirements.txt, run: | ||
| # bazel run //score/time_daemon/tests/component_tests:requirements.update | ||
| compile_pip_requirements( | ||
| name = "requirements", | ||
| srcs = [ | ||
| "requirements.txt", | ||
| "@score_tooling//python_basics:requirements.in", | ||
| ], | ||
| requirements_txt = "requirements.txt.lock", | ||
| tags = ["manual"], | ||
| ) | ||
|
|
||
| score_virtualenv( | ||
| name = "python_tc_venv", | ||
| reqs = all_requirements, | ||
| venv_name = ".python_tc_venv", | ||
| ) | ||
|
|
||
| # NOTE: The time_daemon_cit pytest target is intentionally absent. | ||
| # | ||
| # Previous CIT scenarios (lifecycle, shm_roundtrip, pipeline) exercised | ||
| # component-internal behaviour inside a single process — those belong in | ||
| # gtest-based unit/component integration tests under src/. | ||
| # | ||
| # The CIT framework (Python driver + test_scenarios binary) is reserved | ||
| # for testing the TimeDaemon as an external binary, with true IPC between | ||
| # processes. Re-enable score_py_pytest here once a real process-level | ||
| # integration scenario is added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <!-- ---------------------------------------------------------------------------- | ||
| Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
|
|
||
| See the NOTICE file(s) distributed with this work for additional | ||
| information regarding copyright ownership. | ||
|
|
||
| This program and the accompanying materials are made available under the | ||
| terms of the Apache License Version 2.0 which is available at | ||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| ----------------------------------------------------------------------------- --> | ||
|
|
||
| # TimeDaemon Component Integration Tests (CIT) | ||
|
|
||
| ## Scope | ||
|
|
||
| Component integration tests verify the TimeDaemon running as an **external | ||
| process** — its startup, runtime behaviour, IPC interfaces, and shutdown — | ||
| exercised from outside the binary. They are NOT a replacement for unit tests or | ||
| for in-process component integration tests. | ||
|
|
||
| | Layer | Tool | Where it lives | What it covers | | ||
| |-------|------|----------------|----------------| | ||
| | Unit | gtest / gmock | `score/time_daemon/src/**/*_test.cpp` | Individual classes, white-box | | ||
| | Component integration (in-process) | gtest / gmock | `score/time_daemon/src/**/*_integration_test.cpp` | Multiple production objects wired together inside one process (e.g. GPTPStubMachine → SvtVerificationMachine) | | ||
| | **CIT (this layer)** | **pytest + scenario binary** | `score/time_daemon/tests/component_tests/` | **TimeDaemon running as a real binary, single- or multi-process interaction** | | ||
| | Module integration | pytest + ITF | `score/tests/module_integration_tests/` | TimeSlave ↔ TimeDaemon across components | | ||
| | System | pytest + ITF + QEMU / Docker | `score/tests/gptp_pipeline/` | Multi-binary end-to-end across OS targets | | ||
|
|
||
| **Rule of thumb** — if a scenario can be written by instantiating production | ||
| objects directly and linking them with gtest (i.e. everything happens inside one | ||
| test process), it belongs in the gtest layer under `src/`. CIT is reserved for | ||
| tests that must launch the real TimeDaemon executable (or multiple binaries) and | ||
| interact with it from outside, via its real IPC/SHM interfaces. | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| pytest (Python) test runner, assertions, reporting | ||
| │ | ||
| ▼ subprocess + structured-log parsing | ||
| scenario / daemon binary real TimeDaemon (or helper) process | ||
| │ | ||
| ▼ IPC / SHM / command line | ||
| TimeDaemon production code running in its own process | ||
| ``` | ||
|
|
||
| - Python side lives under `tests/` and subclasses `testing_utils.Scenario` | ||
| (see `tests/cit_scenario.py`). | ||
| - Each pytest class declares a `scenario_name` fixture that selects which | ||
| scenario/binary to run; results come back as exit code + structured log lines | ||
| parsed by `testing_utils.LogContainer`. | ||
| - The `conftest.py` provides CLI options for building and running C++ scenario | ||
| binaries (e.g. `--cpp-target-name`, `--build-scenarios`). | ||
|
|
||
| ## Status | ||
|
|
||
| The Python driver scaffolding (`conftest.py`, `cit_scenario.py`, `result_code.py`, | ||
| requirements, virtualenv) is in place. Active CIT scenarios will be added here | ||
| once the TimeDaemon binary can be launched standalone for process-level | ||
| integration testing. | ||
|
|
||
| In-process multi-module integration scenarios live in gtest under `src/` (e.g. | ||
| `svt_verification_machine_pipeline_integration_test.cpp`). | ||
|
|
||
| ## Running | ||
|
|
||
| When scenario targets exist, run with: | ||
|
|
||
| ```bash | ||
| bazel test //score/time_daemon/tests/component_tests:<target_name> | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.