diff --git a/score/mw/com/impl/bindings/lola/proxy.cpp b/score/mw/com/impl/bindings/lola/proxy.cpp index aad7bd8a7..4f71a80bf 100644 --- a/score/mw/com/impl/bindings/lola/proxy.cpp +++ b/score/mw/com/impl/bindings/lola/proxy.cpp @@ -37,6 +37,7 @@ #include "score/mw/com/impl/configuration/service_type_deployment.h" #include "score/mw/com/impl/find_service_handle.h" #include "score/mw/com/impl/handle_type.h" +#include "score/mw/com/impl/proxy_binding.h" #include "score/mw/com/impl/runtime.h" #include "score/mw/com/impl/service_element_type.h" @@ -624,9 +625,9 @@ void Proxy::UnregisterEventBinding(const std::string_view service_element_name) } } -score::Result Proxy::SetupMethods(const std::vector& enabled_method_names) +score::Result Proxy::SetupMethods() { - auto enabled_method_data = GetMethodIdAndQueueSizeFromNames(enabled_method_names); + auto enabled_method_data = GetMethodIdAndQueueSizeForEnabledMethods(); // Add field Get/Set methods to the enabled method data. // TODO(Ticket-250429): Replace these constants with actual per-field configuration flags @@ -744,31 +745,32 @@ memory::shared::SharedMemoryFactory::UserPermissions Proxy::GetSkeletonShmPermis } std::vector> -Proxy::GetMethodIdAndQueueSizeFromNames(const std::vector& enabled_method_names) const +Proxy::GetMethodIdAndQueueSizeForEnabledMethods() const { - std::vector> method_data{}; - std::transform( - enabled_method_names.cbegin(), - enabled_method_names.cend(), - std::back_inserter(method_data), - [this](const auto& method_name) -> std::pair { - const std::string method_name_string{method_name}; - const auto& lola_service_type_deployment = GetLoLaServiceTypeDeployment(handle_); + std::vector> + enabled_method_ids_and_queue_sizes{}; + const auto& lola_service_instance_deployment = GetLoLaInstanceDeployment(handle_); + const auto& lola_service_type_deployment = GetLoLaServiceTypeDeployment(handle_); + + // Get enabled methods from config and build method data + for (const auto& [method_name, method_deployment] : lola_service_instance_deployment.methods_) + { + if (method_deployment.enabled_.has_value() && method_deployment.enabled_.value()) + { const auto method_id = - GetServiceElementId(lola_service_type_deployment, method_name_string); + GetServiceElementId(lola_service_type_deployment, method_name); - const auto& lola_service_instance_deployment = GetLoLaInstanceDeployment(handle_); - const auto& method_instance_deployment = GetServiceElementInstanceDeployment( - lola_service_instance_deployment, method_name_string); SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE( - method_instance_deployment.queue_size_.has_value(), + method_deployment.queue_size_.has_value(), "Method instance deployment must contain queue_size on proxy side!"); - const auto queue_size = method_instance_deployment.queue_size_.value(); + const auto queue_size = method_deployment.queue_size_.value(); - return {{method_id, MethodType::kMethod}, queue_size}; - }); + enabled_method_ids_and_queue_sizes.emplace_back(UniqueMethodIdentifier{method_id, MethodType::kMethod}, + queue_size); + } + } - return method_data; + return enabled_method_ids_and_queue_sizes; } std::size_t Proxy::CalculateRequiredShmSize( diff --git a/score/mw/com/impl/bindings/lola/proxy.h b/score/mw/com/impl/bindings/lola/proxy.h index a2cba4e4a..961c7a059 100644 --- a/score/mw/com/impl/bindings/lola/proxy.h +++ b/score/mw/com/impl/bindings/lola/proxy.h @@ -179,7 +179,7 @@ class Proxy : public ProxyBinding /// been destructed. void UnregisterEventBinding(const std::string_view service_element_name) noexcept override; - score::Result SetupMethods(const std::vector& enabled_method_names) override; + score::Result SetupMethods() override; QualityType GetQualityType() const noexcept; @@ -210,7 +210,7 @@ class Proxy : public ProxyBinding memory::shared::SharedMemoryFactory::UserPermissions GetSkeletonShmPermissions() const; std::vector> - GetMethodIdAndQueueSizeFromNames(const std::vector& enabled_method_names) const; + GetMethodIdAndQueueSizeForEnabledMethods() const; std::vector GetTypeErasedElementInfoForEnabledMethods( const std::vector>& enabled_method_data) const; diff --git a/score/mw/com/impl/bindings/lola/proxy_method_handling_test.cpp b/score/mw/com/impl/bindings/lola/proxy_method_handling_test.cpp index e23f547e6..0898e8e47 100644 --- a/score/mw/com/impl/bindings/lola/proxy_method_handling_test.cpp +++ b/score/mw/com/impl/bindings/lola/proxy_method_handling_test.cpp @@ -49,10 +49,12 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -111,12 +113,6 @@ const LolaServiceTypeDeployment kLolaServiceTypeDeploymentWithMethods{ {}, {{kDummyMethodName0, kDummyMethodId0}, {kDummyMethodName1, kDummyMethodId1}, {kDummyMethodName2, kDummyMethodId2}}}; -const ConfigurationStore kConfigurationStore{InstanceSpecifier::Create(std::string{"my_instance_spec"}).value(), - make_ServiceIdentifierType("foo"), - QualityType::kASIL_B, - kLolaServiceTypeDeploymentWithMethods, - kLolaServiceInstanceDeploymentWithMethods}; - const std::optional kEmptyInArgsTypeErasedDataInfo{}; const std::optional kEmptyReturnTypeTypeErasedDataInfo{}; const DataTypeSizeInfo kValidInArgsTypeErasedDataInfo{16U, 16U}; @@ -127,8 +123,6 @@ const DataTypeSizeInfo kValidReturnTypeTypeErasedDataInfo1{32U, 16U}; const TypeErasedCallQueue::TypeErasedElementInfo kEmptyTypeErasedInfo{{}, {}, 0}; const ServiceHandleContainer kEmptyServiceHandleContainer{}; -const ServiceHandleContainer kServiceHandleContainerWithOneHandle{ - make_HandleType(kConfigurationStore.GetInstanceIdentifier())}; const FindServiceHandle kFindServiceHandle{make_FindServiceHandle(10U)}; @@ -154,11 +148,39 @@ class ProxyMethodHandlingFixture : public ProxyMockedMemoryFixture ProxyMethodHandlingFixture& GivenAProxy() { - InitialiseProxyWithConstructor(kConfigurationStore.GetInstanceIdentifier()); + SCORE_LANGUAGE_FUTURECPP_ASSERT(configuration_store_ != nullptr); + InitialiseProxyWithConstructor(configuration_store_->GetInstanceIdentifier()); SCORE_LANGUAGE_FUTURECPP_ASSERT(proxy_ != nullptr); return *this; } + ProxyMethodHandlingFixture& GivenAConfigurationWithEnabledMethods( + const std::vector& enabled_method_names) + { + const auto is_method_enabled = [&enabled_method_names](const std::string_view method_name) { + return std::find(enabled_method_names.begin(), enabled_method_names.end(), method_name) != + enabled_method_names.end(); + }; + const bool is_method_0_enabled = is_method_enabled(kDummyMethodName0); + const bool is_method_1_enabled = is_method_enabled(kDummyMethodName1); + const bool is_method_2_enabled = is_method_enabled(kDummyMethodName2); + + configuration_store_ = std::make_unique(ConfigurationStore{ + InstanceSpecifier::Create(std::string{"my_instance_spec"}).value(), + make_ServiceIdentifierType("foo"), + QualityType::kASIL_B, + kLolaServiceTypeDeploymentWithMethods, + LolaServiceInstanceDeployment{ + kLolaInstanceId, + {}, + {}, + {{kDummyMethodName0, LolaMethodInstanceDeployment{kDummyQueueSize0, is_method_0_enabled}}, + {kDummyMethodName1, LolaMethodInstanceDeployment{kDummyQueueSize1, is_method_1_enabled}}, + {kDummyMethodName2, LolaMethodInstanceDeployment{kDummyQueueSize2, is_method_2_enabled}}}}}); + + return *this; + } + ProxyMethodHandlingFixture& GivenAMockedSharedMemoryResource() { mock_method_memory_resource_ = std::make_shared(); @@ -200,7 +222,10 @@ class ProxyMethodHandlingFixture : public ProxyMockedMemoryFixture void OfferService() { ASSERT_TRUE(find_service_handler_.has_value()); - std::invoke(find_service_handler_.value(), kServiceHandleContainerWithOneHandle, kFindServiceHandle); + SCORE_LANGUAGE_FUTURECPP_ASSERT(configuration_store_ != nullptr); + const ServiceHandleContainer service_handle_container_with_one_handle{ + make_HandleType(configuration_store_->GetInstanceIdentifier())}; + std::invoke(find_service_handler_.value(), service_handle_container_with_one_handle, kFindServiceHandle); } const MethodData& GetMethodDataFromShm() @@ -224,18 +249,19 @@ class ProxyMethodHandlingFixture : public ProxyMockedMemoryFixture containers::NonRelocatableVector proxy_method_storage_{5U}; std::optional> find_service_handler_{}; + std::unique_ptr configuration_store_{nullptr}; }; TEST_F(ProxyMethodHandlingFixture, EnablingZeroMethodsDoesNotCreateSharedMemory) { // Given that no ProxyMethods were registered - GivenAProxy().GivenAMockedSharedMemoryResource(); + GivenAConfigurationWithEnabledMethods({}).GivenAProxy().GivenAMockedSharedMemoryResource(); // Expecting that no shared memory region will be created EXPECT_CALL(shared_memory_factory_mock_guard_.mock_, Create(StartsWith(kMethodChannelPrefix), _, _, _, _)).Times(0); // When calling SetupMethods with an empty enabled_method_names vector - const auto result = proxy_->SetupMethods({}); + const auto result = proxy_->SetupMethods(); // Then no error is returned EXPECT_TRUE(result.has_value()); @@ -244,17 +270,20 @@ TEST_F(ProxyMethodHandlingFixture, EnablingZeroMethodsDoesNotCreateSharedMemory) TEST_F(ProxyMethodHandlingFixture, SuccessfullyCreatingSharedMemoryReturnsSuccess) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that the shared memory creation succeeds EXPECT_CALL(shared_memory_factory_mock_guard_.mock_, Create(StartsWith(kMethodChannelPrefix), _, _, _, _)) .WillOnce(Return(mock_method_memory_resource_)); // When calling SetupMethods with the name of the registered ProxyMethod - const auto result = proxy_->SetupMethods({kDummyMethodName0}); + const auto result = proxy_->SetupMethods(); // Then no error is returned EXPECT_TRUE(result.has_value()); @@ -263,17 +292,20 @@ TEST_F(ProxyMethodHandlingFixture, SuccessfullyCreatingSharedMemoryReturnsSucces TEST_F(ProxyMethodHandlingFixture, FailingToCreateSharedMemoryReturnsError) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that the shared memory creation fails and returns a nullptr EXPECT_CALL(shared_memory_factory_mock_guard_.mock_, Create(StartsWith(kMethodChannelPrefix), _, _, _, _)) .WillOnce(Return(nullptr)); // When calling SetupMethods with the name of the registered ProxyMethod - const auto result = proxy_->SetupMethods({kDummyMethodName0}); + const auto result = proxy_->SetupMethods(); // Then an error is returned ASSERT_FALSE(result.has_value()); @@ -283,16 +315,19 @@ TEST_F(ProxyMethodHandlingFixture, FailingToCreateSharedMemoryReturnsError) TEST_F(ProxyMethodHandlingFixture, CreatesMethodCallQueueForEachMethodInShm) { // Given that 2 ProxyMethods are registered - GivenAProxy().GivenAFakeSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo1, kValidReturnTypeTypeErasedDataInfo1, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAFakeSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo1, kValidReturnTypeTypeErasedDataInfo1, kDummyQueueSize1}}}); // When calling SetupMethods with the name of the registered ProxyMethod - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); // Then a MethodData object will be created which contains TypeErasedCallQueues // for each method @@ -300,23 +335,26 @@ TEST_F(ProxyMethodHandlingFixture, CreatesMethodCallQueueForEachMethodInShm) ASSERT_EQ(method_data.method_call_queues_.size(), 2U); const UniqueMethodIdentifier expected_method_0{kDummyMethodId0, MethodType::kMethod}; const UniqueMethodIdentifier expected_method_1{kDummyMethodId1, MethodType::kMethod}; - EXPECT_EQ(method_data.method_call_queues_.at(0).first, expected_method_0); - EXPECT_EQ(method_data.method_call_queues_.at(1).first, expected_method_1); + EXPECT_THAT(method_data.method_call_queues_, + UnorderedElementsAre(Pair(expected_method_0, _), Pair(expected_method_1, _))); } TEST_F(ProxyMethodHandlingFixture, SetsInArgsAndReturnStoragesForEachMethodInShm) { // Given that 2 ProxyMethods are registered - GivenAProxy().GivenAFakeSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo1, kValidReturnTypeTypeErasedDataInfo1, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAFakeSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo1, kValidReturnTypeTypeErasedDataInfo1, kDummyQueueSize1}}}); // When calling SetupMethods with the name of the registered ProxyMethod - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); // Then the SetInArgsAndReturnStorages will be set for each method (which we validate by checking whether the method // can allocate InArgs without crashing, since the allocation is using the inserted storages) @@ -331,10 +369,13 @@ TEST_F(ProxyMethodHandlingFixture, CreatesSharedMemoryWithUserPermissionsContain // Given that a ProxyMethod is registered which is connected to a Fake ServiceDataStorage which stores kDummyUid as // the UID of the skeleton (check the construction of FakeMockedServiceData in the constructor of // ProxyMockedMemoryFixture) - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that the shared memory creation is called with read and write permissions for the skeleton's // uid @@ -360,17 +401,20 @@ TEST_F(ProxyMethodHandlingFixture, CreatesSharedMemoryWithUserPermissionsContain }))); // When calling SetupMethods with the name of the registered ProxyMethod - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); } using ProxySetupMethodsPartialRestartFixture = ProxyMethodHandlingFixture; TEST_F(ProxySetupMethodsPartialRestartFixture, RemovesStaleArtefactsIfShmFileAlreadyExists) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that we check if the shm file already exists in the filesystem // which returns that it already exists (indicating that a previous Proxy was created which then crashed). @@ -380,23 +424,26 @@ TEST_F(ProxySetupMethodsPartialRestartFixture, RemovesStaleArtefactsIfShmFileAlr EXPECT_CALL(shared_memory_factory_mock_guard_.mock_, RemoveStaleArtefacts(StartsWith(kMethodChannelPrefix))); // When calling SetupMethods with the name of the registered ProxyMethod - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); } TEST_F(ProxySetupMethodsPartialRestartFixture, ReturnsErrorWhenCheckingIfShmFileAlreadyExistsReturnsError) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that we check if the shm file already exists in the filesystem which returns an error EXPECT_CALL(filesystem_fake_.GetStandard(), Exists(StartsWith(kMethodShmChannelPrefix))) .WillOnce(Return(MakeUnexpected(filesystem::ErrorCode::kCouldNotRetrieveStatus))); // When calling SetupMethods with the name of the registered ProxyMethod - const auto result = proxy_->SetupMethods({kDummyMethodName0}); + const auto result = proxy_->SetupMethods(); // Then an error is returned ASSERT_FALSE(result.has_value()); @@ -407,10 +454,13 @@ using ProxySetupMethodsProxyAutoReconnectFixture = ProxyMethodHandlingFixture; TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, DoesNotResendSubscribeMethodIfSkeletonReOfferedButSetupMethodsNeverCalled) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will never be called EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).Times(0); @@ -428,17 +478,20 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, ResendsSubscribeMethodEveryTimeSkeletonReOffered) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will be called three times: once in SetupMethods and once for every time // the find service handler is called when the service has been reoffered EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).Times(3); // Given that SetupMethods was called - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); // Given that the service was initially offered OfferService(); @@ -454,16 +507,19 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, ResendsSubscribeMethodEveryTi TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, MarksProxyMethodsUnsubscribedWhenSkeletonStopOffered) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); // Given that SetupMethods was called which should mark the ProxyMethods as subscribed - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); EXPECT_TRUE(proxy_method_storage_.at(0).IsSubscribed()); EXPECT_TRUE(proxy_method_storage_.at(1).IsSubscribed()); @@ -481,13 +537,16 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, MarksProxyMethodsUnsubscribed TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, MarksProxyMethodsSubscribedWhenSkeletonReOfferedAndSubscriptionSucceeds) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); // Expecting that SubscribeServiceMethod will be called once in SetupMethods and a second time in the find service // handler when the service has been reoffered which succeeds @@ -496,7 +555,7 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, .WillRepeatedly(Return(score::Result{})); // Given that SetupMethods was called - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); // and given that the service was initially offered and then stop-offered OfferService(); @@ -513,13 +572,16 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, DoesNotMarkProxyMethodsSubscribedWhenSkeletonReOfferedAndSubscriptionFails) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); // Expecting that SubscribeServiceMethod will be called once in SetupMethods Sequence subscribe_service_method_sequence{}; @@ -532,7 +594,7 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, .WillOnce(Return(MakeUnexpected(ComErrc::kBindingFailure))); // Given that SetupMethods was called - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); // and given that the service was initially offered and then stop-offered OfferService(); @@ -548,16 +610,19 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, DoesNotResendSubscribeMethodIfSkeletonNeverCrashed) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will be called only once in SetupMethods EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).Times(1); // Given that SetupMethods was called - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); // When the service is initially offered (but never crashed) OfferService(); @@ -565,16 +630,19 @@ TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, DoesNotResendSubscribeMethodI TEST_F(ProxySetupMethodsProxyAutoReconnectFixture, DoesNotResendSubscribeMethodIfSkeletonNeverReOffered) { - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will be called only once in SetupMethods EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).Times(1); // Given that SetupMethods was called - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); // Given that the service was initially offered OfferService(); @@ -587,10 +655,13 @@ using ProxySetupMethodsMessagePassingFixture = ProxyMethodHandlingFixture; TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithArgsOrReturnTypesCallsSubscribeServiceMethod) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will be called EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)) @@ -603,16 +674,19 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithArgsOrReturnTypesCalls }))); // When calling SetupMethods with the name of the registered ProxyMethod - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0}); + score::cpp::ignore = proxy_->SetupMethods(); } TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithArgsOrReturnTypesForwardsErrorFromSubscribeServiceMethod) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that SubscribeServiceMethod will be called which returns an error const auto call_service_method_subscribed_error_code = ComErrc::kCallQueueFull; @@ -620,7 +694,7 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithArgsOrReturnTypesForwa .WillOnce(Return(MakeUnexpected(call_service_method_subscribed_error_code))); // When calling SetupMethods with the name of the registered ProxyMethod - const auto setup_methods_result = proxy_->SetupMethods({kDummyMethodName0}); + const auto setup_methods_result = proxy_->SetupMethods(); // Then the result contains the error returned by message passing ASSERT_FALSE(setup_methods_result.has_value()); @@ -630,19 +704,22 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithArgsOrReturnTypesForwa TEST_F(ProxySetupMethodsMessagePassingFixture, ProxyMethodsMarkedAsSubscribedWhenSubscribeServiceMethodReturnsValid) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); // Expecting that SubscribeServiceMethod will be called and returns a valid result EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).WillOnce(Return(score::Result{})); // When calling SetupMethods with the name of the registered ProxyMethods - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); // Then all registered proxy methods should be marked as subscribed EXPECT_TRUE(proxy_method_storage_.at(0).IsSubscribed()); @@ -653,13 +730,16 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, ProxyMethodsNotMarkedAsUnsubscribedWhenSubscribeServiceMethodReturnsError) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, - {kDummyMethodId1, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}, + {kDummyMethodId1, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize1}}}); // Expecting that SubscribeServiceMethod will be called which returns an error const auto call_service_method_subscribed_error_code = ComErrc::kCallQueueFull; @@ -667,7 +747,7 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, .WillOnce(Return(MakeUnexpected(call_service_method_subscribed_error_code))); // When calling SetupMethods with the name of the registered ProxyMethods - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); // Then all registered proxy methods should be marked as unsubscribed EXPECT_FALSE(proxy_method_storage_.at(0).IsSubscribed()); @@ -677,20 +757,22 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, TEST_F(ProxySetupMethodsMessagePassingFixture, EnablingZeroMethodsDoesNotNotifiesSubscribeServiceMethod) { // Given that no ProxyMethods were registered - GivenAProxy().GivenAMockedSharedMemoryResource(); + GivenAConfigurationWithEnabledMethods({}).GivenAProxy().GivenAMockedSharedMemoryResource(); // Expecting that SubscribeServiceMethod will not be called EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)).Times(0); // When calling SetupMethods with an empty enabled_method_names vector - score::cpp::ignore = proxy_->SetupMethods({}); + score::cpp::ignore = proxy_->SetupMethods(); } TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithoutArgsOrReturnTypesForwardsErrorFromSubscribeServiceMethod) { // Given that 2 ProxyMethods with no in args or return types were registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, kEmptyTypeErasedInfo}, {kDummyMethodId1, kEmptyTypeErasedInfo}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods({{kDummyMethodId0, kEmptyTypeErasedInfo}, {kDummyMethodId1, kEmptyTypeErasedInfo}}); // Expecting that SubscribeServiceMethod will be called which returns an error const auto call_service_method_subscribed_error_code = ComErrc::kCallQueueFull; @@ -698,7 +780,7 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithoutArgsOrReturnTypesFo .WillOnce(Return(MakeUnexpected(call_service_method_subscribed_error_code))); // When calling SetupMethods with the names of the two registered ProxyMethods - const auto setup_methods_result = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + const auto setup_methods_result = proxy_->SetupMethods(); // Then the result contains the error returned by message passing ASSERT_FALSE(setup_methods_result.has_value()); @@ -708,8 +790,10 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, MethodsWithoutArgsOrReturnTypesFo TEST_F(ProxySetupMethodsMessagePassingFixture, EnablingMethodsWithoutArgsOrReturnTypesNotifiesServiceMethodSubscribed) { // Given that 2 ProxyMethods with no in args or return types were registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, kEmptyTypeErasedInfo}, {kDummyMethodId1, kEmptyTypeErasedInfo}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0, kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods({{kDummyMethodId0, kEmptyTypeErasedInfo}, {kDummyMethodId1, kEmptyTypeErasedInfo}}); // Expecting that SubscribeServiceMethod will be called EXPECT_CALL(*mock_service_, SubscribeServiceMethod(_, _, _, _)) @@ -722,16 +806,19 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, EnablingMethodsWithoutArgsOrRetur }))); // When calling SetupMethods with the names of the two registered ProxyMethods - score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0, kDummyMethodName1}); + score::cpp::ignore = proxy_->SetupMethods(); } TEST_F(ProxySetupMethodsMessagePassingFixture, FailingToGetLolaRuntimeTerminates) { // Given that a ProxyMethod is registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, - TypeErasedCallQueue::TypeErasedElementInfo{ - kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName0}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods( + {{kDummyMethodId0, + TypeErasedCallQueue::TypeErasedElementInfo{ + kValidInArgsTypeErasedDataInfo, kValidReturnTypeTypeErasedDataInfo, kDummyQueueSize0}}}); // Expecting that GetBindingRuntime is called on the impl runtime which returns // a nullptr @@ -739,7 +826,7 @@ TEST_F(ProxySetupMethodsMessagePassingFixture, FailingToGetLolaRuntimeTerminates // When calling SetupMethods with the name of the registered ProxyMethod // Then the program terminates - SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0})); + SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods()); } class ProxySetupMethodsShmSizeParamaterizedFixture @@ -847,7 +934,10 @@ TEST_P(ProxySetupMethodsShmSizeParamaterizedFixture, AllocatesEveryByteInSpecifi { // Given that 2 ProxyMethods with various in args / return types const auto& [method_names, methods_to_register] = GetParam(); - GivenAProxy().GivenAFakeSharedMemoryResource().WithRegisteredProxyMethods(methods_to_register); + GivenAConfigurationWithEnabledMethods(method_names) + .GivenAProxy() + .GivenAFakeSharedMemoryResource() + .WithRegisteredProxyMethods(methods_to_register); // Expecting that a shared memory region will be created with the calculated shm // size @@ -861,33 +951,77 @@ TEST_P(ProxySetupMethodsShmSizeParamaterizedFixture, AllocatesEveryByteInSpecifi return fake_method_memory_resource_; }))); - // When calling SetupMethods with the names of the registered ProxyMethods - score::cpp::ignore = proxy_->SetupMethods(method_names); + // When calling SetupMethods + score::cpp::ignore = proxy_->SetupMethods(); // Then the number of bytes allocated should equal the size that the shm region // was created with EXPECT_EQ(fake_method_memory_resource_->GetUserAllocatedBytes(), actual_shm_size); } -TEST_F(ProxyMethodHandlingFixture, EnablingMethodsThatWereNotRegisteredTerminates) +TEST_F(ProxyMethodHandlingFixture, EnabledMethodWithoutRegisteredProxyMethodTerminates) { // Given that a ProxyMethod was registered - GivenAProxy().GivenAMockedSharedMemoryResource().WithRegisteredProxyMethods( - {{kDummyMethodId0, kEmptyTypeErasedInfo}}); + GivenAConfigurationWithEnabledMethods({kDummyMethodName1}) + .GivenAProxy() + .GivenAMockedSharedMemoryResource() + .WithRegisteredProxyMethods({{kDummyMethodId0, kEmptyTypeErasedInfo}}); // When calling SetupMethods with a ProxyMethod name which does not correspond // to the registered ProxyMethod Then the program terminates - SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName1})); + SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods()); } -TEST_F(ProxyMethodHandlingFixture, EnablingMethodsThatAreNotInTheConfigurationTerminates) +TEST_F(ProxyMethodHandlingFixture, EnabledMethodPresentOnlyInInstanceDeploymentTerminates) { - GivenAProxy().GivenAMockedSharedMemoryResource(); + // Given a configuration where an enabled method exists only in the instance deployment + // and is missing from the type deployment + const LolaServiceInstanceDeployment lola_service_instance_deployment_with_unknown_method{ + kLolaInstanceId, {}, {}, {{"unknown_method", LolaMethodInstanceDeployment{kDummyQueueSize0, true}}}}; + const LolaServiceTypeDeployment lola_service_type_deployment_without_unknown_method{kLolaServiceId, {}, {}, {}}; + + const ConfigurationStore configuration_store{InstanceSpecifier::Create(std::string{"my_instance_spec"}).value(), + make_ServiceIdentifierType("foo"), + QualityType::kASIL_B, + lola_service_type_deployment_without_unknown_method, + lola_service_instance_deployment_with_unknown_method}; + + InitialiseProxyWithCreate(configuration_store.GetInstanceIdentifier()); + SCORE_LANGUAGE_FUTURECPP_ASSERT(proxy_ != nullptr); + + GivenAMockedSharedMemoryResource(); + + // When calling SetupMethods for a method that is enabled in the instance deployment but missing in the type + // deployment Then the program terminates + SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods()); +} - // When calling SetupMethods with a ProxyMethod name which does not exist in the - // configuration Then the program terminates - SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = - proxy_->SetupMethods({"SomeInvalidMethodName"})); +TEST_F(ProxyMethodHandlingFixture, MethodPresentOnlyInTypeDeploymentDoesNotCreateSharedMemory) +{ + // Given a configuration where a method exists only in the type deployment and not in the instance deployment + const LolaServiceInstanceDeployment lola_service_instance_deployment_without_method{kLolaInstanceId, {}, {}, {}}; + const LolaServiceTypeDeployment lola_service_type_deployment_with_method{ + kLolaServiceId, {}, {}, {{kDummyMethodName0, kDummyMethodId0}}}; + + const ConfigurationStore configuration_store{InstanceSpecifier::Create(std::string{"my_instance_spec"}).value(), + make_ServiceIdentifierType("foo"), + QualityType::kASIL_B, + lola_service_type_deployment_with_method, + lola_service_instance_deployment_without_method}; + + InitialiseProxyWithCreate(configuration_store.GetInstanceIdentifier()); + SCORE_LANGUAGE_FUTURECPP_ASSERT(proxy_ != nullptr); + + GivenAMockedSharedMemoryResource(); + + // Expecting that no shared memory should be created, since no method is enabled in the instance deployment. + EXPECT_CALL(shared_memory_factory_mock_guard_.mock_, Create(StartsWith(kMethodChannelPrefix), _, _, _, _)).Times(0); + + // When calling SetupMethods + const auto result = proxy_->SetupMethods(); + + // Then SetupMethods succeeds + EXPECT_TRUE(result.has_value()); } TEST_F(ProxyMethodHandlingFixture, EnablingMethodThatDoesNotContainQueueSizeInConfigurationTerminates) @@ -896,7 +1030,7 @@ TEST_F(ProxyMethodHandlingFixture, EnablingMethodThatDoesNotContainQueueSizeInCo // empty queue size const std::optional empty_queue_size{}; const LolaServiceInstanceDeployment lola_service_instance_deployment_missing_queue_size{ - kLolaInstanceId, {}, {}, {{kDummyMethodName0, LolaMethodInstanceDeployment{empty_queue_size}}}}; + kLolaInstanceId, {}, {}, {{kDummyMethodName0, LolaMethodInstanceDeployment{empty_queue_size, true}}}}; const LolaServiceTypeDeployment lola_service_type_deployment{ kLolaServiceId, {}, {}, {{kDummyMethodName0, kDummyMethodId0}}}; @@ -914,7 +1048,7 @@ TEST_F(ProxyMethodHandlingFixture, EnablingMethodThatDoesNotContainQueueSizeInCo // When calling SetupMethods with a ProxyMethod name which corresponds to the // registered ProxyMethod Then the program terminates - SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods({kDummyMethodName0})); + SCORE_LANGUAGE_FUTURECPP_EXPECT_CONTRACT_VIOLATED(score::cpp::ignore = proxy_->SetupMethods()); } } // namespace diff --git a/score/mw/com/impl/bindings/mock_binding/proxy.h b/score/mw/com/impl/bindings/mock_binding/proxy.h index bb8c8a3fc..812581d18 100644 --- a/score/mw/com/impl/bindings/mock_binding/proxy.h +++ b/score/mw/com/impl/bindings/mock_binding/proxy.h @@ -15,6 +15,7 @@ #include "score/mw/com/impl/proxy_binding.h" +#include "score/result/result.h" #include namespace score::mw::com::impl::mock_binding @@ -30,7 +31,7 @@ class Proxy : public ProxyBinding MOCK_METHOD(bool, IsEventProvided, (const std::string_view), (const, noexcept, override)); MOCK_METHOD(void, RegisterEventBinding, (std::string_view, ProxyEventBindingBase&), (noexcept, override)); MOCK_METHOD(void, UnregisterEventBinding, (std::string_view), (noexcept, override)); - MOCK_METHOD(Result, SetupMethods, (const std::vector& enabled_method_names), (override)); + MOCK_METHOD(Result, SetupMethods, (), (override)); }; class ProxyFacade : public ProxyBinding @@ -55,9 +56,9 @@ class ProxyFacade : public ProxyBinding proxy_.UnregisterEventBinding(service_element_name); } - Result SetupMethods(const std::vector& enabled_method_names) override + Result SetupMethods() override { - return proxy_.SetupMethods(enabled_method_names); + return proxy_.SetupMethods(); } private: diff --git a/score/mw/com/impl/configuration/config_parser.cpp b/score/mw/com/impl/configuration/config_parser.cpp index 11bd15564..bd2a2106f 100644 --- a/score/mw/com/impl/configuration/config_parser.cpp +++ b/score/mw/com/impl/configuration/config_parser.cpp @@ -13,6 +13,7 @@ #include "score/mw/com/impl/configuration/config_parser.h" #include "score/mw/com/impl/configuration/configuration_common_resources.h" +#include "score/mw/com/impl/configuration/lola_method_instance_deployment.h" #include "score/mw/com/impl/configuration/lola_service_instance_deployment.h" #include "score/mw/com/impl/configuration/quality_type.h" #include "score/mw/com/impl/configuration/service_type_deployment.h" @@ -23,6 +24,7 @@ #include "score/json/json_parser.h" #include "score/mw/log/logging.h" +#include #include #include @@ -67,6 +69,8 @@ constexpr auto kMethodsKey = "methods"sv; constexpr auto kMethodNameKey = "methodName"sv; constexpr auto kMethodIdKey = "methodId"sv; constexpr auto kMethodQueueSizeKey = "queueSize"sv; +constexpr auto kMethodEnabledKey = "enabled"sv; +constexpr auto kMethodEnabledDefaultValue = true; constexpr auto kEventNumberOfSampleSlotsKey = "numberOfSampleSlots"sv; constexpr auto kEventMaxSamplesKey = "maxSamples"sv; constexpr auto kEventMaxSubscribersKey = "maxSubscribers"sv; @@ -523,7 +527,9 @@ auto ParseLolaMethodInstanceDeployment(const score::json::Object& json_map, Lola const auto& method_name = GetValueFromJson(method_object, kMethodNameKey); const std::optional queue_size = GetOptionalValueFromJson(method_object, kMethodQueueSizeKey); - const LolaMethodInstanceDeployment method_deployment{queue_size}; + const bool method_enabled = + GetOptionalValueFromJson(method_object, kMethodEnabledKey).value_or(kMethodEnabledDefaultValue); + const LolaMethodInstanceDeployment method_deployment{queue_size, method_enabled}; const auto emplace_result = service.methods_.emplace( std::piecewise_construct, std::forward_as_tuple(method_name), std::forward_as_tuple(method_deployment)); diff --git a/score/mw/com/impl/configuration/config_parser_methods_test.cpp b/score/mw/com/impl/configuration/config_parser_methods_test.cpp index ea6118dd1..2fe37c553 100644 --- a/score/mw/com/impl/configuration/config_parser_methods_test.cpp +++ b/score/mw/com/impl/configuration/config_parser_methods_test.cpp @@ -631,5 +631,139 @@ TEST_F(ConfigParserFixture, MethodQueueSizeCanBeSpecified) EXPECT_EQ(lola_deployment.methods_.at("SetPressure").queue_size_, 5); } +TEST_F(ConfigParserFixture, MethodCanBeExplicitlyDisabled) +{ + // Given a JSON with a method with enabled set to false + auto j2 = R"( +{ + "serviceTypes": [ + { + "serviceTypeName": "/score/ncar/services/TirePressureService", + "version": { + "major": 12, + "minor": 34 + }, + "bindings": [ + { + "binding": "SHM", + "serviceId": 1234, + "events": [], + "fields": [], + "methods": [ + { + "methodName": "SetPressure", + "methodId": 40 + } + ] + } + ] + } + ], + "serviceInstances": [ + { + "instanceSpecifier": "abc/abc/TirePressurePort", + "serviceTypeName": "/score/ncar/services/TirePressureService", + "version": { + "major": 12, + "minor": 34 + }, + "instances": [ + { + "instanceId": 1234, + "asil-level": "QM", + "binding": "SHM", + "events": [], + "fields": [], + "methods": [ + { + "methodName": "SetPressure", + "enabled": false + } + ] + } + ] + } + ] +} +)"_json; + + // When parsing the JSON + const auto config = score::mw::com::impl::configuration::Parse(std::move(j2)); + + // Then the method should be disabled + const auto deployments = + config.GetServiceInstances().at(InstanceSpecifier::Create(std::string{"abc/abc/TirePressurePort"}).value()); + const auto& lola_deployment = std::get(deployments.bindingInfo_); + ASSERT_TRUE(lola_deployment.methods_.at("SetPressure").enabled_.has_value()); + EXPECT_FALSE(lola_deployment.methods_.at("SetPressure").enabled_.value()); +} + +TEST_F(ConfigParserFixture, MethodCanBeExplicitlyEnabled) +{ + // Given a JSON with a method with enabled set to true + auto j2 = R"( +{ + "serviceTypes": [ + { + "serviceTypeName": "/score/ncar/services/TirePressureService", + "version": { + "major": 12, + "minor": 34 + }, + "bindings": [ + { + "binding": "SHM", + "serviceId": 1234, + "events": [], + "fields": [], + "methods": [ + { + "methodName": "SetPressure", + "methodId": 40 + } + ] + } + ] + } + ], + "serviceInstances": [ + { + "instanceSpecifier": "abc/abc/TirePressurePort", + "serviceTypeName": "/score/ncar/services/TirePressureService", + "version": { + "major": 12, + "minor": 34 + }, + "instances": [ + { + "instanceId": 1234, + "asil-level": "QM", + "binding": "SHM", + "events": [], + "fields": [], + "methods": [ + { + "methodName": "SetPressure", + "enabled": true + } + ] + } + ] + } + ] +} +)"_json; + + // When parsing the JSON + const auto config = score::mw::com::impl::configuration::Parse(std::move(j2)); + + // Then the method should be enabled + const auto deployments = + config.GetServiceInstances().at(InstanceSpecifier::Create(std::string{"abc/abc/TirePressurePort"}).value()); + const auto& lola_deployment = std::get(deployments.bindingInfo_); + ASSERT_TRUE(lola_deployment.methods_.at("SetPressure").enabled_.has_value()); + EXPECT_TRUE(lola_deployment.methods_.at("SetPressure").enabled_.value()); +} + } // namespace } // namespace score::mw::com::impl diff --git a/score/mw/com/impl/configuration/config_parser_test.cpp b/score/mw/com/impl/configuration/config_parser_test.cpp index 9ada2b143..47e10e00b 100644 --- a/score/mw/com/impl/configuration/config_parser_test.cpp +++ b/score/mw/com/impl/configuration/config_parser_test.cpp @@ -116,6 +116,8 @@ TEST_F(ConfigParserFixture, ParseExampleJson) EXPECT_EQ(secondDeploymentInfo.fields_.at("CurrentTemperatureFrontLeft").max_subscribers_.value(), 6); EXPECT_EQ(secondDeploymentInfo.fields_.at("CurrentTemperatureFrontLeft").enforce_max_samples_, true); EXPECT_EQ(secondDeploymentInfo.fields_.at("CurrentTemperatureFrontLeft").max_concurrent_allocations_.value(), 1); + ASSERT_TRUE(secondDeploymentInfo.methods_.at("SetPressure").enabled_.has_value()); + EXPECT_TRUE(secondDeploymentInfo.methods_.at("SetPressure").enabled_.value()); const auto service_deployment = config.GetServiceTypes().at(deployments.service_); const auto* const lola_service_type_deployment = diff --git a/score/mw/com/impl/configuration/configuration_test.cpp b/score/mw/com/impl/configuration/configuration_test.cpp index dbb353145..f3176654f 100644 --- a/score/mw/com/impl/configuration/configuration_test.cpp +++ b/score/mw/com/impl/configuration/configuration_test.cpp @@ -185,7 +185,7 @@ TEST_F(ConfigurationFixture, ConfigIsCorrectlyParsedFromFile) const LolaEventInstanceDeployment lola_event_instance{event_max_samples, event_max_subscribers, 1U, true, 0}; const LolaFieldInstanceDeployment lola_field_instance{field_max_samples, field_max_subscribers, 1U, true, 7}; - const LolaMethodInstanceDeployment lola_method_instance{method_queue_size}; + const LolaMethodInstanceDeployment lola_method_instance{method_queue_size, true}; const LolaServiceInstanceDeployment::EventInstanceMapping instance_events{ {instance_event_name, lola_event_instance}}; diff --git a/score/mw/com/impl/configuration/lola_method_instance_deployment.cpp b/score/mw/com/impl/configuration/lola_method_instance_deployment.cpp index 1f6eb680c..5a40b7866 100644 --- a/score/mw/com/impl/configuration/lola_method_instance_deployment.cpp +++ b/score/mw/com/impl/configuration/lola_method_instance_deployment.cpp @@ -22,21 +22,29 @@ namespace { using std::string_view_literals::operator""sv; constexpr auto kQueueSizeKey = "queueSize"sv; +constexpr auto kMethodEnabledKey = "enabled"sv; } // namespace -LolaMethodInstanceDeployment::LolaMethodInstanceDeployment(std::optional queue_size) - : queue_size_{queue_size} +LolaMethodInstanceDeployment::LolaMethodInstanceDeployment(std::optional queue_size, + std::optional enabled) + : queue_size_{queue_size}, enabled_{enabled} { } LolaMethodInstanceDeployment::LolaMethodInstanceDeployment( const score::json::Object& serialized_lola_method_instance_deployment) + : queue_size_{std::nullopt}, enabled_{std::nullopt} { const auto queue_size_iter = serialized_lola_method_instance_deployment.find(kQueueSizeKey.data()); if (queue_size_iter != serialized_lola_method_instance_deployment.cend()) { queue_size_ = queue_size_iter->second.As().value(); } + const auto enabled_iter = serialized_lola_method_instance_deployment.find(kMethodEnabledKey.data()); + if (enabled_iter != serialized_lola_method_instance_deployment.cend()) + { + enabled_ = enabled_iter->second.As().value(); + } } LolaMethodInstanceDeployment LolaMethodInstanceDeployment::CreateFromJson( @@ -52,6 +60,10 @@ score::json::Object LolaMethodInstanceDeployment::Serialize() const { result[kQueueSizeKey.data()] = score::json::Any{queue_size_.value()}; } + if (enabled_.has_value()) + { + result[kMethodEnabledKey.data()] = score::json::Any{enabled_.value()}; + } return result; } diff --git a/score/mw/com/impl/configuration/lola_method_instance_deployment.h b/score/mw/com/impl/configuration/lola_method_instance_deployment.h index 2b4dcd6a1..d5fe061b1 100644 --- a/score/mw/com/impl/configuration/lola_method_instance_deployment.h +++ b/score/mw/com/impl/configuration/lola_method_instance_deployment.h @@ -39,8 +39,11 @@ class LolaMethodInstanceDeployment * @brief Construct LolaMethodInstanceDeployment with optional queue size, because LolaMethodInstanceDeployment for * a consumer will have a value while one for a provider will not. * @param queue_size The maximum number of pending method requests that can be queued. + * @param enabled Optional flag to disable/enable the method. It is always filled on proxy side and always empty + * on skeleton side. */ - explicit LolaMethodInstanceDeployment(std::optional queue_size); + explicit LolaMethodInstanceDeployment(std::optional queue_size, + std::optional enabled = std::nullopt); explicit LolaMethodInstanceDeployment(const score::json::Object& serialized_lola_method_instance_deployment); @@ -69,12 +72,13 @@ class LolaMethodInstanceDeployment /** * @brief The maximum number of method requests that can be queued on the server side. */ - std::optional queue_size_{std::nullopt}; + std::optional queue_size_; + std::optional enabled_; }; inline bool operator==(const LolaMethodInstanceDeployment& lhs, const LolaMethodInstanceDeployment& rhs) noexcept { - return lhs.queue_size_ == rhs.queue_size_; + return lhs.queue_size_ == rhs.queue_size_ && lhs.enabled_ == rhs.enabled_; } } // namespace score::mw::com::impl diff --git a/score/mw/com/impl/configuration/lola_method_instance_deployment_test.cpp b/score/mw/com/impl/configuration/lola_method_instance_deployment_test.cpp index 3271be4d0..783d231b8 100644 --- a/score/mw/com/impl/configuration/lola_method_instance_deployment_test.cpp +++ b/score/mw/com/impl/configuration/lola_method_instance_deployment_test.cpp @@ -91,6 +91,49 @@ TEST(LolaMethodInstanceDeploymentSerializationTest, CreateFromJsonWithoutQueueSi EXPECT_EQ(unit.queue_size_, std::nullopt); } +TEST(LolaMethodInstanceDeploymentSerializationTest, CreateFromJsonWithoutEnabledLeavesEnabledUnset) +{ + // Given a JSON object without enabled + const LolaMethodInstanceDeployment::QueueSize queue_size{20U}; + score::json::Object json_object{}; + json_object["queueSize"] = score::json::Any{queue_size}; + + // When creating from JSON + auto unit = LolaMethodInstanceDeployment::CreateFromJson(json_object); + + // Then the method instance should keep enabled unset + EXPECT_FALSE(unit.enabled_.has_value()); + EXPECT_EQ(unit.enabled_, std::nullopt); +} + +TEST(LolaMethodInstanceDeploymentSerializationTest, CreateFromJsonWithEnabledFalseDisablesMethod) +{ + // Given a JSON object with enabled set to false + score::json::Object json_object{}; + json_object["enabled"] = score::json::Any{false}; + + // When creating from JSON + auto unit = LolaMethodInstanceDeployment::CreateFromJson(json_object); + + // Then the method instance should be disabled + ASSERT_TRUE(unit.enabled_.has_value()); + EXPECT_FALSE(unit.enabled_.value()); +} + +TEST(LolaMethodInstanceDeploymentSerializationTest, CreateFromJsonWithEnabledTrueEnablesMethod) +{ + // Given a JSON object with enabled set to true + score::json::Object json_object{}; + json_object["enabled"] = score::json::Any{true}; + + // When creating from JSON + auto unit = LolaMethodInstanceDeployment::CreateFromJson(json_object); + + // Then the method instance should be enabled + ASSERT_TRUE(unit.enabled_.has_value()); + EXPECT_TRUE(unit.enabled_.value()); +} + TEST(LolaMethodInstanceDeploymentSerializationTest, SerializeAndDeserializePreservesQueueSize) { // Given a LolaMethodInstanceDeployment with custom queue size @@ -125,5 +168,38 @@ TEST(LolaMethodInstanceDeploymentSerializationTest, SerializeIncludesQueueSize) EXPECT_EQ(queue_size_iter->second.As().value(), queue_size); } +TEST(LolaMethodInstanceDeploymentSerializationTest, SerializeAndDeserializePreservesEnabled) +{ + // Given a LolaMethodInstanceDeployment with enabled set to false + score::json::Object json_object{}; + json_object["enabled"] = score::json::Any{false}; + auto original_unit = LolaMethodInstanceDeployment::CreateFromJson(json_object); + + // When serializing and deserializing + auto serialized = original_unit.Serialize(); + auto reconstructed_unit = LolaMethodInstanceDeployment::CreateFromJson(serialized); + + // Then the enabled state should be preserved + ASSERT_TRUE(reconstructed_unit.enabled_.has_value()); + EXPECT_FALSE(reconstructed_unit.enabled_.value()); + EXPECT_EQ(reconstructed_unit, original_unit); +} + +TEST(LolaMethodInstanceDeploymentSerializationTest, SerializeIncludesEnabled) +{ + // Given a LolaMethodInstanceDeployment with enabled set to false + score::json::Object json_object{}; + json_object["enabled"] = score::json::Any{false}; + auto unit = LolaMethodInstanceDeployment::CreateFromJson(json_object); + + // When serializing + auto serialized = unit.Serialize(); + + // Then the serialized object should contain the enabled key and the value is correct + auto enabled_iter = serialized.find("enabled"); + ASSERT_NE(enabled_iter, serialized.end()); + EXPECT_FALSE(enabled_iter->second.As().value()); +} + } // namespace } // namespace score::mw::com::impl diff --git a/score/mw/com/impl/configuration/mw_com_config_schema.json b/score/mw/com/impl/configuration/mw_com_config_schema.json index 00fe1e343..a5276c039 100644 --- a/score/mw/com/impl/configuration/mw_com_config_schema.json +++ b/score/mw/com/impl/configuration/mw_com_config_schema.json @@ -413,6 +413,11 @@ "description": "Optional Binding specific consumer/proxy side setting for maximum number of pending method requests that can be queued on the server side before new requests are rejected.", "minimum": 1, "maximum": 255 + }, + "enabled": { + "type": "boolean", + "description": "Optional flag to disable/enable method. Default value is true, which means the method is enabled. This flag is only relevant on the proxy side and is ignored if specified in skeleton configuration.", + "default": true } } } diff --git a/score/mw/com/impl/proxy_base.cpp b/score/mw/com/impl/proxy_base.cpp index 9a89a8cbc..26209a6b3 100644 --- a/score/mw/com/impl/proxy_base.cpp +++ b/score/mw/com/impl/proxy_base.cpp @@ -158,9 +158,9 @@ score::Result ProxyBase::StopFindService(const FindServiceHandle handle) n return stop_find_service_result; } -Result ProxyBase::SetupMethods(const std::vector& enabled_method_names) +Result ProxyBase::SetupMethods() { - const auto result = proxy_binding_->SetupMethods(enabled_method_names); + const auto result = proxy_binding_->SetupMethods(); if (!result.has_value()) { return MakeUnexpected(result.error()); diff --git a/score/mw/com/impl/proxy_base.h b/score/mw/com/impl/proxy_base.h index bcbe04f5e..60e608832 100644 --- a/score/mw/com/impl/proxy_base.h +++ b/score/mw/com/impl/proxy_base.h @@ -137,7 +137,7 @@ class ProxyBase return is_proxy_binding_valid && are_service_element_bindings_valid_; } - Result SetupMethods(const std::vector& enabled_method_names); + Result SetupMethods(); // Suppress "AUTOSAR C++14 M11-0-1" rule findings. This rule states: "Member data in non-POD class types shall // be private.". We need these data elements to exchange this information between the ProxyBase and the diff --git a/score/mw/com/impl/proxy_binding.h b/score/mw/com/impl/proxy_binding.h index c3c41d492..c24524d36 100644 --- a/score/mw/com/impl/proxy_binding.h +++ b/score/mw/com/impl/proxy_binding.h @@ -61,7 +61,7 @@ class ProxyBinding /// Unregisters a ProxyEvent binding with its parent proxy virtual void UnregisterEventBinding(const std::string_view service_element_name) noexcept = 0; - virtual Result SetupMethods(const std::vector& enabled_method_names) = 0; + virtual Result SetupMethods() = 0; }; } // namespace score::mw::com::impl diff --git a/score/mw/com/impl/proxy_binding_test.cpp b/score/mw/com/impl/proxy_binding_test.cpp index a16b9e502..fd7ba4dd2 100644 --- a/score/mw/com/impl/proxy_binding_test.cpp +++ b/score/mw/com/impl/proxy_binding_test.cpp @@ -31,7 +31,7 @@ class MyProxy final : public ProxyBinding } void RegisterEventBinding(std::string_view, ProxyEventBindingBase&) noexcept override {} void UnregisterEventBinding(std::string_view) noexcept override {} - Result SetupMethods(const std::vector&) override + Result SetupMethods() override { return {}; } diff --git a/score/mw/com/impl/traits.h b/score/mw/com/impl/traits.h index 6f5f444b1..1c51a0587 100644 --- a/score/mw/com/impl/traits.h +++ b/score/mw/com/impl/traits.h @@ -328,10 +328,8 @@ class ProxyWrapperClass : public Interface /// \details Exception-less proxy constructor that creates a proxy wrapper by creating the proxy binding /// for the given service handle and validating all service element bindings. /// \param instance_handle The handle identifying the service instance to connect to. - /// \param enabled_method_names The handle identifying the service instance to connect to. /// \return On success, returns a ProxyWrapperClass instance. On failure, returns an error code. - static Result Create(const HandleType instance_handle, - const std::vector& enabled_method_names = {}) noexcept + static Result Create(const HandleType instance_handle) noexcept { if (creation_results_.has_value()) { @@ -350,7 +348,7 @@ class ProxyWrapperClass : public Interface return MakeUnexpected(ComErrc::kBindingFailure); } - const auto setup_methods_result = proxy_wrapper.SetupMethods(enabled_method_names); + const auto setup_methods_result = proxy_wrapper.SetupMethods(); if (!(setup_methods_result.has_value())) { ::score::mw::log::LogError("lola") << "Could not setup methods on Proxy side"; diff --git a/score/mw/com/impl/traits_test.cpp b/score/mw/com/impl/traits_test.cpp index 6bec8299e..7074a6829 100644 --- a/score/mw/com/impl/traits_test.cpp +++ b/score/mw/com/impl/traits_test.cpp @@ -126,7 +126,7 @@ class ProxyCreationFixture : public ::testing::Test .WillByDefault(Return(ByMove(std::move(proxy_method_binding_mock_ptr)))); // By default that the proxy_binding can successfully call SetupMethods - ON_CALL(proxy_binding_mock_, SetupMethods(_)).WillByDefault(Return(score::Result{})); + ON_CALL(proxy_binding_mock_, SetupMethods()).WillByDefault(Return(score::Result{})); // By default the runtime configuration resolves instance identifiers resolved_instance_identifiers_.push_back(identifier_with_valid_binding_); @@ -288,7 +288,7 @@ TEST_F(GeneratedProxyCreationTestFixture, ReturnErrorWhenCreatingProxyWithNoProx TEST_F(GeneratedProxyCreationTestFixture, ReturnErrorWhenCreatingProxyProxyBindingCanNotSuccessfullySetUpMethods) { // Expecting that the Create call on the ProxyMethodBindingFactory returns an invalid binding for the method. - EXPECT_CALL(proxy_binding_mock_, SetupMethods(_)).WillOnce(Return(MakeUnexpected(ComErrc::kBindingFailure))); + EXPECT_CALL(proxy_binding_mock_, SetupMethods()).WillOnce(Return(MakeUnexpected(ComErrc::kBindingFailure))); // When constructing a proxy with a handle const auto unit = MyProxy::Create(std::move(handle_)); diff --git a/score/mw/com/test/methods/basic_acceptance_test/consumer.cpp b/score/mw/com/test/methods/basic_acceptance_test/consumer.cpp index 6f344453d..2550f3b9e 100644 --- a/score/mw/com/test/methods/basic_acceptance_test/consumer.cpp +++ b/score/mw/com/test/methods/basic_acceptance_test/consumer.cpp @@ -49,7 +49,7 @@ int run_consumer() // Step 1. Find service and create proxy std::cout << "\nConsumer: Step 1" << std::endl; - if (!consumer.CreateProxy(kInstanceSpecifier, {"with_in_args_and_return"})) + if (!consumer.CreateProxy(kInstanceSpecifier)) { std::cerr << "Methods basic_acceptance_test consumer failed: CreateProxy" << std::endl; process_synchronizer_result->Notify(); diff --git a/score/mw/com/test/methods/methods_test_resources/method_consumer.h b/score/mw/com/test/methods/methods_test_resources/method_consumer.h index f14521d5e..2ce415dd4 100644 --- a/score/mw/com/test/methods/methods_test_resources/method_consumer.h +++ b/score/mw/com/test/methods/methods_test_resources/method_consumer.h @@ -61,7 +61,7 @@ class MethodConsumer WITH_COPY }; - bool CreateProxy(InstanceSpecifier instance_specifier, const std::vector& enabled_method_names); + bool CreateProxy(InstanceSpecifier instance_specifier); bool CallMethodWithInArgsAndReturn(const std::int32_t input_argument_a, const std::int32_t input_argument_b, @@ -80,10 +80,9 @@ class MethodConsumer }; template -bool MethodConsumer::CreateProxy(InstanceSpecifier instance_specifier, - const std::vector& enabled_method_names) +bool MethodConsumer::CreateProxy(InstanceSpecifier instance_specifier) { - return proxy_container_.CreateProxy(std::move(instance_specifier), enabled_method_names); + return proxy_container_.CreateProxy(std::move(instance_specifier)); } template diff --git a/score/mw/com/test/methods/methods_test_resources/proxy_container.h b/score/mw/com/test/methods/methods_test_resources/proxy_container.h index c9ed171f9..61a9f9fc9 100644 --- a/score/mw/com/test/methods/methods_test_resources/proxy_container.h +++ b/score/mw/com/test/methods/methods_test_resources/proxy_container.h @@ -31,7 +31,7 @@ class ProxyContainer public: ProxyContainer(); - bool CreateProxy(InstanceSpecifier instance_specifier, const std::vector& enabled_method_names); + bool CreateProxy(InstanceSpecifier instance_specifier); Proxy& GetProxy() { @@ -55,8 +55,7 @@ ProxyContainer::ProxyContainer() } template -bool ProxyContainer::CreateProxy(InstanceSpecifier instance_specifier, - const std::vector& enabled_method_names) +bool ProxyContainer::CreateProxy(InstanceSpecifier instance_specifier) { bool callback_called{false}; auto find_service_callback = [this, &callback_called](auto service_handle_container, @@ -98,7 +97,7 @@ bool ProxyContainer::CreateProxy(InstanceSpecifier instance_specifier, return false; } - auto proxy_result = Proxy::Create(*handle_, enabled_method_names); + auto proxy_result = Proxy::Create(*handle_); proxy_creation_lock.unlock(); if (!proxy_result.has_value()) { diff --git a/score/mw/com/test/methods/non_trivial_constructors/consumer.cpp b/score/mw/com/test/methods/non_trivial_constructors/consumer.cpp index 22ea63828..6f7b7e321 100644 --- a/score/mw/com/test/methods/non_trivial_constructors/consumer.cpp +++ b/score/mw/com/test/methods/non_trivial_constructors/consumer.cpp @@ -129,7 +129,7 @@ int run_consumer() // Step 1. Find service and create proxy std::cout << "\nConsumer: Step 1" << std::endl; - if (!consumer.CreateProxy(kInstanceSpecifier, {"with_in_args_and_return", "with_in_args_only", "with_return_only"})) + if (!consumer.CreateProxy(kInstanceSpecifier)) { std::cerr << "Methods non_trivial_constructors consumer failed: CreateProxy" << std::endl; process_synchronizer_result->Notify(); diff --git a/score/mw/com/test/methods/signature_variations/consumer.cpp b/score/mw/com/test/methods/signature_variations/consumer.cpp index 869176c1d..f7f4d45e0 100644 --- a/score/mw/com/test/methods/signature_variations/consumer.cpp +++ b/score/mw/com/test/methods/signature_variations/consumer.cpp @@ -58,9 +58,7 @@ int run_consumer() // Step 1. Find service and create proxy std::cout << "\nConsumer: Step 1" << std::endl; - if (!consumer.CreateProxy( - kInstanceSpecifier, - {"with_in_args_and_return", "with_in_args_only", "with_return_only", "without_args_or_return"})) + if (!consumer.CreateProxy(kInstanceSpecifier)) { std::cerr << "Methods signature_variations consumer failed: CreateProxy" << std::endl; process_synchronizer_result->Notify();