Skip to content

Implement integration tests for fields with set and notifier#463

Draft
sahithi-nukala wants to merge 7 commits into
eclipse-score:mainfrom
sahithi-nukala:sah_add_integration_test_for_fields
Draft

Implement integration tests for fields with set and notifier#463
sahithi-nukala wants to merge 7 commits into
eclipse-score:mainfrom
sahithi-nukala:sah_add_integration_test_for_fields

Conversation

@sahithi-nukala

@sahithi-nukala sahithi-nukala commented May 21, 2026

Copy link
Copy Markdown
Contributor
  • Move proxy and skeleton containers from methods to common test resources because it would be used by both fields and methods.
  • Update traits and traits tests for field get/set/notifier parameters.
  • Restructure field initial value integration tests and add set and notifier scenarios

@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch 4 times, most recently from 8306eb3 to 38982b6 Compare May 21, 2026 13:57
Comment thread score/mw/com/impl/traits.h
Comment thread score/mw/com/impl/traits_test.cpp
Comment thread score/mw/com/test/common_test_resources/BUILD
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch 6 times, most recently from 7bd4c90 to a4435a5 Compare May 27, 2026 11:52
@sahithi-nukala sahithi-nukala marked this pull request as ready for review May 27, 2026 12:18
@sahithi-nukala sahithi-nukala requested a review from bemerybmw May 27, 2026 12:18
Comment thread score/mw/com/test/field_initial_value/basic_acceptance_test/BUILD
@sahithi-nukala sahithi-nukala marked this pull request as draft May 28, 2026 05:04
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch 8 times, most recently from 0e981e5 to 5496cf0 Compare May 29, 2026 09:42
@sahithi-nukala sahithi-nukala requested a review from bemerybmw May 29, 2026 10:17
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch from 5496cf0 to 4039570 Compare May 29, 2026 10:17
@sahithi-nukala sahithi-nukala marked this pull request as ready for review May 29, 2026 11:06
Comment thread score/mw/com/test/fields/BUILD Outdated

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.

We usually consumer / provider instead of client / service. Could you please follow the same naming convention?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread score/mw/com/test/fields/set_and_notifier/config/logging.json
using Parameters = score::mw::com::test::SctfTestRunner::RunParameters::Parameters;

const std::vector<Parameters> allowed_parameters{Parameters::CYCLE_TIME, Parameters::MODE};
score::mw::com::test::SctfTestRunner test_runner(argc, argv, allowed_parameters);

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.

SctfTestRunner is very old and we don't use it for new tests. Please look at how we do config parsing here: https://github.com/eclipse-score/communication/blob/brem_methods_sctfs/score/mw/com/test/methods/multiple_proxies/main_provider.cpp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


const std::vector<Parameters> allowed_parameters{Parameters::CYCLE_TIME, Parameters::MODE};
score::mw::com::test::SctfTestRunner test_runner(argc, argv, allowed_parameters);
const auto& run_parameters = test_runner.GetRunParameters();

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

return -17;
}

while (!stop_token.stop_requested())

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.

Use ProcessSynchronizer instead of a loop on the stop token like in

auto process_synchronizer_result = ProcessSynchronizer::Create(kInterprocessNotificationShmPath);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

}
auto instance_specifier = std::move(instance_specifier_result).value();

auto service_result = SetEnabledSkeleton::Create(std::move(instance_specifier));

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.

Use SkeletonContainer instead of doing this yourself

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


while (!stop_token.stop_requested())
{
std::this_thread::sleep_for(cycle_time);

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.

We don't need cycle_time to be passed in from python, we only want to pass in params that need to be changed when calling the binary from python (e.g. mode). Anyway, this won't be needed when using ProcessSynchronizer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

if (!instance_specifier_result.has_value())
{
std::cerr << "Unable to create instance specifier, terminating\n";
return -3;

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.

Instead of returning error codes and propagating this up through all the layers, we should instead use FailTest to immediately fail the test e.g.

FailTest("Provider: Failed to register with_in_args_and_return handler");

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.

Same applies for the consumer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

auto instance_specifier = std::move(instance_specifier_result).value();

std::promise<std::vector<InitialOnlyProxy::HandleType>> service_discovery_promise{};
auto service_discovery_future = service_discovery_promise.get_future();

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.

Use ProxyContainer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

};

template <typename T>
class SetEnabledInterface : public T::Base

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.

We should have one class per file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

namespace score::mw::com::test
{

constexpr const char* const kInstanceSpecifierString = "test/fields/set_and_notifier";

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.

The shared constants should be in a different file, not with the interface classes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

return target.wrap_exec("bin/main_service", args, cwd="/opt/MainServiceApp", **kwargs)


def test_field_notifier_initial_value(target):

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.

We should have different python files per test configuration (e.g. https://github.com/eclipse-score/communication/tree/f6a14ef6f69482b404ec9392067fdd67c5126d51/score/mw/com/test/methods/mixed_criticality/integration_test). The configurations needed are mentioned in the ticket.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Separate files per configuration have been added for 2 cases from the ticket. and for the 4 configurations requiring getter support (test_get.py, test_get_and_notifier.py, test_set_and_get.py, test_set_get_and_notifier.py)

@sahithi-nukala sahithi-nukala marked this pull request as draft June 1, 2026 05:18
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch 3 times, most recently from 655b99c to e177601 Compare June 2, 2026 13:40
@sahithi-nukala sahithi-nukala marked this pull request as ready for review June 2, 2026 14:15
@sahithi-nukala sahithi-nukala marked this pull request as draft June 4, 2026 04:29
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch 2 times, most recently from 39f0cd4 to 02408e2 Compare June 4, 2026 04:42
@sahithi-nukala sahithi-nukala marked this pull request as ready for review June 4, 2026 05:29
@@ -0,0 +1,33 @@
/*******************************************************************************

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.

all header files should have a corresponding cpp file, even if it's empty.

public:
using T::Base::Base;

typename T::template Field<std::int32_t> test_field{*this, "test_field"};

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.

name it something like initial_only_field so it doesn't have the same name as the other field.

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.

We then would also need a differenet configuration file per test.

Comment on lines +25 to +28
public:
using T::Base::Base;

typename T::template Field<std::int32_t, false, true> test_field{*this, "test_field"};

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.

Name it set_enabled_field

typename T::template Field<std::int32_t, false, true> test_field{*this, "test_field"};
};

using InitialOnlyProxy = score::mw::com::AsProxy<InitialOnlyInterface>;

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.

This file should be removed and these aliases should go in the relevant interface files


const std::string kInterprocessNotificationShmPath{"/field_initial_value_interprocess_notification"};

int run_client(const std::size_t num_retries, const std::chrono::milliseconds retry_backoff_time)

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.

Also use FailTest in this file and run_client should return void?

run_notifier_consumer(num_retries, retry_backoff_time);
return;
}
if (mode == "set")

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.

This should be set_and_notifier?


auto& service = skeleton_container.GetSkeleton();
const auto register_handler_result = service.test_field.RegisterSetHandler([](std::int32_t& value) noexcept {
if (value > kSetAcceptedValue)

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.

I think that instead of doing clamping, we can simply have the set handler do some constant transformation, e.g. value * a + b; We can then check on proxy side that the value was transformed as expected. It means that we don't have to do 2 method calls.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i replaced the clamping logic with a transformation ([value * 2 + 1] in the set handler. this way the consumer only needs to make one set call - it sends [kSetRequestValue] and checks that the received notification equals [kSetRequestValue * 2 + 1].

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.

mains should have main_ prefix

constexpr auto kModeArg = "mode";
constexpr auto kServiceInstanceManifestArg = "service-instance-manifest";

const std::vector<std::pair<std::string, std::string>> parameter_description_pairs{

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 extract config parsing into a function like in the tests I sent you

],
)

cc_library(

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.

If this is now used not just in fields, it should be moved to common resources folder which is accessible by both. e.g. https://github.com/eclipse-score/communication/tree/main/score/mw/com/test/common_test_resources

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved the process_synchronizer target to common_test_resources

@sahithi-nukala sahithi-nukala marked this pull request as draft June 11, 2026 08:38
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch from 7a0e916 to 02408e2 Compare June 12, 2026 05:00
@sahithi-nukala sahithi-nukala force-pushed the sah_add_integration_test_for_fields branch from 02408e2 to 0b7a081 Compare June 12, 2026 05:35
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.

2 participants