-
Notifications
You must be signed in to change notification settings - Fork 15
Add test for feat_req__persistency__multiple_kvs #73
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
igorostrowskiq
wants to merge
1
commit into
eclipse-score:main
Choose a base branch
from
qorix-group:igorostrowskiq_add_persistency_fit
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
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
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
10 changes: 10 additions & 0 deletions
10
feature_integration_tests/python_test_cases/test_properties.py
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,10 @@ | ||
| try: | ||
| from attribute_plugin import add_test_properties # type: ignore[import-untyped] | ||
| except ImportError: | ||
| # Define no-op decorator if attribute_plugin is not available (outside bazel) | ||
| # Keeps IDE debugging functionality | ||
| def add_test_properties(*args, **kwargs): | ||
| def decorator(func): | ||
| return func # No-op decorator | ||
|
|
||
| return decorator |
17 changes: 3 additions & 14 deletions
17
...re_integration_tests/python_test_cases/tests/basic/test_orchestartion_with_persistency.py
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
89 changes: 89 additions & 0 deletions
89
feature_integration_tests/python_test_cases/tests/persistency/multiple_kvs_per_app.py
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,89 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2025 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 | ||
| # ******************************************************************************* | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any, Generator | ||
|
|
||
| import pytest | ||
| from fit_scenario import FitScenario, temp_dir_common | ||
| from test_properties import add_test_properties | ||
| from testing_utils import LogContainer | ||
|
|
||
|
|
||
| @add_test_properties( | ||
| partially_verifies=["feat_req__persistency__multiple_kvs"], | ||
| test_type="requirements-based", | ||
| derivation_technique="requirements-analysis", | ||
| ) | ||
| class TestMultipleInstanceIds(FitScenario): | ||
| """ | ||
| Verifies that multiple KVS instances with different IDs store and retrieve independent values without interference. | ||
| """ | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def scenario_name(self) -> str: | ||
| return "persistency.multiple_instance_ids" | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def kvs_key(self) -> str: | ||
| return "number" | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def kvs_value_1(self) -> float: | ||
| return 111.1 | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def kvs_value_2(self) -> float: | ||
| return 222.2 | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def temp_dir( | ||
| self, | ||
| tmp_path_factory: pytest.TempPathFactory, | ||
| ) -> Generator[Path, None, None]: | ||
| yield from temp_dir_common(tmp_path_factory, self.__class__.__name__) | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def test_config( | ||
| self, | ||
| temp_dir: Path, | ||
| kvs_key: str, | ||
| kvs_value_1: float, | ||
| kvs_value_2: float, | ||
| ) -> dict[str, Any]: | ||
| return { | ||
| "kvs_parameters_1": { | ||
| "kvs_parameters": {"instance_id": 1, "dir": str(temp_dir)}, | ||
| }, | ||
| "kvs_parameters_2": { | ||
| "kvs_parameters": {"instance_id": 2, "dir": str(temp_dir)}, | ||
| }, | ||
| "test": {"key": kvs_key, "value_1": kvs_value_1, "value_2": kvs_value_2}, | ||
| } | ||
|
|
||
| def test_ok( | ||
| self, | ||
| kvs_key: str, | ||
| kvs_value_1: float, | ||
| kvs_value_2: float, | ||
| logs_info_level: LogContainer, | ||
| ): | ||
| log1 = logs_info_level.find_log("instance", value="kvs1") | ||
| assert log1 is not None | ||
| assert log1.key == kvs_key | ||
| assert log1.value == kvs_value_1 | ||
|
|
||
| log2 = logs_info_level.find_log("instance", value="kvs2") | ||
| assert log2 is not None | ||
| assert log2.key == kvs_key | ||
| assert log2.value == kvs_value_2 |
13 changes: 13 additions & 0 deletions
13
feature_integration_tests/rust_test_scenarios/src/internals/kyron/mod.rs
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,13 @@ | ||
| // | ||
| // Copyright (c) 2025 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 | ||
| // | ||
| pub mod runtime_helper; |
File renamed without changes.
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 |
|---|---|---|
|
|
@@ -10,4 +10,5 @@ | |
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| pub mod runtime_helper; | ||
| pub mod kyron; | ||
| pub mod persistency; | ||
29 changes: 29 additions & 0 deletions
29
feature_integration_tests/rust_test_scenarios/src/internals/persistency/kvs_instance.rs
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,29 @@ | ||
| //! KVS instance test helpers. | ||
|
|
||
| use crate::internals::persistency::kvs_parameters::KvsParameters; | ||
| use rust_kvs::prelude::{ErrorCode, Kvs, KvsBuilder}; | ||
|
|
||
| /// Create KVS instance based on provided parameters. | ||
| pub fn kvs_instance(kvs_parameters: KvsParameters) -> Result<Kvs, ErrorCode> { | ||
| let mut builder = KvsBuilder::new(kvs_parameters.instance_id); | ||
|
|
||
| if let Some(flag) = kvs_parameters.defaults { | ||
| builder = builder.defaults(flag); | ||
| } | ||
|
|
||
| if let Some(flag) = kvs_parameters.kvs_load { | ||
| builder = builder.kvs_load(flag); | ||
| } | ||
|
|
||
| if let Some(dir) = kvs_parameters.dir { | ||
| builder = builder.dir(dir.to_string_lossy().to_string()); | ||
| } | ||
|
|
||
| if let Some(snapshot_max_count) = kvs_parameters.snapshot_max_count { | ||
| builder = builder.snapshot_max_count(snapshot_max_count); | ||
| } | ||
|
|
||
| let kvs: Kvs = builder.build()?; | ||
|
|
||
| Ok(kvs) | ||
| } |
71 changes: 71 additions & 0 deletions
71
feature_integration_tests/rust_test_scenarios/src/internals/persistency/kvs_parameters.rs
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,71 @@ | ||
| //! KVS parameters test helpers. | ||
|
|
||
| use rust_kvs::prelude::{InstanceId, KvsDefaults, KvsLoad}; | ||
| use serde::{de, Deserialize, Deserializer}; | ||
| use std::path::PathBuf; | ||
|
|
||
| /// KVS parameters in serde-compatible format. | ||
| #[derive(Deserialize, Debug, Clone)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct KvsParameters { | ||
| #[serde(deserialize_with = "deserialize_instance_id")] | ||
| pub instance_id: InstanceId, | ||
| #[serde(default, deserialize_with = "deserialize_defaults")] | ||
| pub defaults: Option<KvsDefaults>, | ||
| #[serde(default, deserialize_with = "deserialize_kvs_load")] | ||
| pub kvs_load: Option<KvsLoad>, | ||
| pub dir: Option<PathBuf>, | ||
| pub snapshot_max_count: Option<usize>, | ||
| } | ||
|
|
||
| impl KvsParameters { | ||
| /// Parse `KvsParameters` from `Value`. | ||
| /// `Value` is expected to contain `kvs_parameters` field. | ||
| pub fn from_value(value: &serde_json::Value) -> Result<Self, serde_json::Error> { | ||
| serde_json::from_value(value["kvs_parameters"].clone()) | ||
| } | ||
| } | ||
|
|
||
| fn deserialize_instance_id<'de, D>(deserializer: D) -> Result<InstanceId, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let value = usize::deserialize(deserializer)?; | ||
| Ok(InstanceId(value)) | ||
| } | ||
|
|
||
| fn deserialize_defaults<'de, D>(deserializer: D) -> Result<Option<KvsDefaults>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let value_opt: Option<String> = Option::deserialize(deserializer)?; | ||
| if let Some(value_str) = value_opt { | ||
| let value = match value_str.as_str() { | ||
| "ignored" => KvsDefaults::Ignored, | ||
| "optional" => KvsDefaults::Optional, | ||
| "required" => KvsDefaults::Required, | ||
| _ => return Err(de::Error::custom("Invalid \"defaults\" mode")), | ||
| }; | ||
| return Ok(Some(value)); | ||
| } | ||
|
|
||
| Ok(None) | ||
| } | ||
|
|
||
| fn deserialize_kvs_load<'de, D>(deserializer: D) -> Result<Option<KvsLoad>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let value_opt: Option<String> = Option::deserialize(deserializer)?; | ||
| if let Some(value_str) = value_opt { | ||
| let value = match value_str.as_str() { | ||
| "ignored" => KvsLoad::Ignored, | ||
| "optional" => KvsLoad::Optional, | ||
| "required" => KvsLoad::Required, | ||
| _ => return Err(de::Error::custom("Invalid \"kvs_load\" mode")), | ||
| }; | ||
| return Ok(Some(value)); | ||
| } | ||
|
|
||
| Ok(None) | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
feature_integration_tests/rust_test_scenarios/src/internals/persistency/mod.rs
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,2 @@ | ||
| pub mod kvs_instance; | ||
| pub mod kvs_parameters; |
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
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
23 changes: 23 additions & 0 deletions
23
feature_integration_tests/rust_test_scenarios/src/scenarios/persistency/mod.rs
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,23 @@ | ||
| // Copyright (c) 2025 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 | ||
| // | ||
| mod multiple_kvs_per_app; | ||
|
|
||
| use multiple_kvs_per_app::MultipleInstanceIds; | ||
| use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; | ||
|
|
||
| pub fn persistency_group() -> Box<dyn ScenarioGroup> { | ||
| Box::new(ScenarioGroupImpl::new( | ||
| "persistency", | ||
| vec![Box::new(MultipleInstanceIds)], | ||
| vec![], | ||
| )) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
from_valuemethod expects a nestedkvs_parametersfield within the provided value, which creates an inconsistent API. The method already receives a value parameter, so requiring anotherkvs_parameterskey inside it is confusing. Consider either removing the nested access or renaming the method to clarify this expectation.