Skip to content

Conversation

@Saumya-R
Copy link
Contributor

This PR adds C++ test cases for default values scenarios to achieve parity with existing Rust tests. The implementation includes a temporary workaround to create hash files for C++ KVS, which requires them for validation (unlike Rust). The changes enable parameterized testing across both Rust and C++ versions.

Key changes:

Added C++ test scenarios for default values testing (default_values, remove_key, reset operations, checksum)
Implemented temporary hash file generation in Python test fixtures to support C++ requirements
Modified Rust test scenarios to use string-based result logging for cross-language compatibility

The CPP KVS needs a hash file which is not needed by RUST , leading to failure of test cases.
Created the issue at : #170

@Saumya-R Saumya-R changed the title Saumya cpp default values test Test Cases for default values in case of CPP added Nov 19, 2025
@github-actions
Copy link

github-actions bot commented Nov 19, 2025

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.3.0) and connecting to it...
INFO: Invocation ID: 5b52b193-93e2-4eba-8ea6-a128f9e61ac8
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
DEBUG: Rule 'rust_qnx8_toolchain+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-oEubHgeZDdT0svMmBKJx7c3/2TdSI/vfwRUyDn+TPGA="
DEBUG: Repository rust_qnx8_toolchain+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:394:31: in <toplevel>
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_rust', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'platforms', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 4 packages loaded
Loading: 4 packages loaded
    currently loading: 
Analyzing: target //:license-check (5 packages loaded, 0 targets configured)
Analyzing: target //:license-check (5 packages loaded, 0 targets configured)

Analyzing: target //:license-check (89 packages loaded, 9 targets configured)

Analyzing: target //:license-check (139 packages loaded, 391 targets configured)

Analyzing: target //:license-check (159 packages loaded, 4073 targets configured)

Analyzing: target //:license-check (162 packages loaded, 6985 targets configured)

INFO: Analyzed target //:license-check (165 packages loaded, 9001 targets configured).
[3 / 13] [Prepa] Creating source manifest for @@score_tooling+//dash/tool/formatters:dash_format_converter [for tool]
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 65 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 28.126s, Critical Path: 0.37s
INFO: 14 processes: 5 disk cache hit, 9 internal.
INFO: Build completed successfully, 14 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@Saumya-R Saumya-R force-pushed the saumya_cpp_default_values_test branch 2 times, most recently from f484ec1 to 3e5a5c6 Compare November 19, 2025 09:43
@Saumya-R Saumya-R marked this pull request as draft November 19, 2025 09:48
@github-actions
Copy link

The created documentation from the pull request is available at: docu-html

@Saumya-R Saumya-R force-pushed the saumya_cpp_default_values_test branch 6 times, most recently from 6e98d14 to f011478 Compare November 19, 2025 12:49
@Saumya-R Saumya-R marked this pull request as ready for review November 19, 2025 12:57
@Saumya-R Saumya-R requested a review from PiotrKorkus November 19, 2025 12:57
@igorostrowskiq
Copy link
Contributor

Run locally bazel run //:format.fix to fix format issues

@Saumya-R Saumya-R force-pushed the saumya_cpp_default_values_test branch from 97ec258 to 5548a2e Compare November 20, 2025 12:20
@Saumya-R Saumya-R requested a review from PiotrKorkus November 20, 2025 12:28
@igorostrowskiq
Copy link
Contributor

Please restore and use 4 space indentation for cpp files

@Saumya-R Saumya-R force-pushed the saumya_cpp_default_values_test branch from 21e1562 to 13a6b44 Compare December 3, 2025 07:14
Refactor C++ main exception handling to use unique exit codes for errors.
Extract hash file creation into a separate function for clarity.
Remove redundant temp_dir logic from Python fixtures and rely on pytest setup.
Remove leftover get_binary usage in pytest configuration.
Suppress unnecessary defaults file warnings in conftest.py.
Replace explicit srcs list with glob in Bazel BUILD for maintainability.
Adding the xfail and bug details .
merging with the fixed bug changes for hash file
@Saumya-R Saumya-R force-pushed the saumya_cpp_default_values_test branch from ec4cde8 to 1b1d2b6 Compare December 3, 2025 07:25
Copy link
Member

@pahmann pahmann left a comment

Choose a reason for hiding this comment

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

I am missing any information for the test properties on which requirements they apply to and which test method was used. They are supposed to be Component Integration Tests, so we should be able to find a description as mentioned here: https://github.com/eclipse-score/process_description/blob/main/process/process_areas/verification/guidance/verification_templates.rst#c-properties-template

std::optional<bool> need_defaults;
std::optional<bool> need_kvs;
std::optional<std::string> dir;
uint64_t instance_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Restore and use 4 space indentation

reset_single_key_scenario, checksum_scenario},
{}}};

ScenarioGroup::Ptr cit_group{
Copy link
Contributor

Choose a reason for hiding this comment

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

Only Component Integratio Tests are expected here AFAIK, so we can remove this additional group.

std::cerr << ex.what() << std::endl;
return 1;
run_cli_app(raw_arguments, test_context);
} catch (const ScenarioError &ex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we want try catch around run_cli_app at all.
Right now there is just a description string that you still need to find manually or add some debug steps.
Without try catch there will be termination like:

terminate called after throwing an instance of 'std::runtime_error'
  what():  TestError

and you just need to rerun it with gdb with bt at the end to find where it happened.

To be discussed.

@igorostrowskiq
Copy link
Contributor

Partial review done, have not touched test implementation yet.

Override is not needed
Test group moved to header
@PiotrKorkus
Copy link
Contributor

I am missing any information for the test properties on which requirements they apply to and which test method was used. They are supposed to be Component Integration Tests, so we should be able to find a description as mentioned here: https://github.com/eclipse-score/process_description/blob/main/process/process_areas/verification/guidance/verification_templates.rst#c-properties-template

Hi @pahmann, the properties are added in python file:
https://github.com/eclipse-score/persistency/pull/171/files#diff-a584b9bf616ce290a7c22550473b7fd287de6869aa29a48c2bfbaa91cfafae4eR92-R107

* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#ifndef TEST_DEFAULT_VALUES_HPP
#define TEST_DEFAULT_VALUES_HPP
Copy link
Contributor

Choose a reason for hiding this comment

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

Header guard or #pragma once, choose one. I would go for the pragma version.

*
* @param key The key being queried or modified in the KVS.
* @param value_is_default String encoding whether the current value matches the
* default ("Ok(true)", "Ok(false)", or error string).
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see now that we actually have python part with Ok(), Err() and lots of stringification... It should be refactored to have there original values. But it will be done as some future task, now let's keep it as is for now.


#include "scenario.hpp"
#include <memory>
#include <optional>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used

#include <optional>
#include <string>
#include <vector>

Copy link
Contributor

Choose a reason for hiding this comment

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

All defined data should be wrapper in the namespace e.g. namespace test_default_values { ... } to keep it clean

std::vector<std::shared_ptr<const Scenario>> get_default_value_scenarios();

// Default values group
extern Scenario::Ptr default_values_scenario;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for any externs, just create a group and use it in main.
hpp:

ScenarioGroup::Ptr create_default_values_group();

cpp:

ScenarioGroup::Ptr create_default_values_group() {
  return ScenarioGroup::Ptr{
      new ScenarioGroupImpl{"default_values",
                            {std::make_shared<DefaultValuesScenario>(),
                             std::make_shared<RemoveKeyScenario>(),
                             std::make_shared<ResetAllKeysScenario>(),
                             std::make_shared<ResetSingleKeyScenario>(),
                             std::make_shared<ChecksumScenario>()},
                            {}}};
}

#include <string>
#include <type_traits>
#include <variant>
#include <vector>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please clean-up unused and redeclared from hpp headers at the end

<< std::get<double>(get_value_result.value().getValue());
current_value = "Ok(F64(" + oss.str() + "))";
}
// value_is_default
Copy link
Contributor

Choose a reason for hiding this comment

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

In rust there is a special function to determine if given value is default or set value. In a scenario where default value is set to x and then the key is overwritten with regular value x this WorkAround would still show that is default value. Rust implementation would return that is later set value.

I would contact cpp persistency devs to determine if they are going to fix the gap to understand where it is going to and maybe just use has_default_value for now with eventual xfail.

That applies to many other occurrences of this issue - we can discuss.

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.

4 participants