mw/com: Add methods integration tests#485
Conversation
The signature_variations is the exact same as the mixed_criticality tests, except the latter runs the test for all combinations of asil levels of consumers and providers. Therefore, we remove signature_variations.
118eb76 to
ff33ccc
Compare
ff33ccc to
dd28657
Compare
| void check_result(std::future<score::Result<MethodReturnTypePtr<std::int32_t>>>&& result_future, | ||
| std::int32_t expected_value) | ||
| { | ||
| std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; |
There was a problem hiding this comment.
| std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; |
| if (!find_result.has_value() || find_result->size() != 1) | ||
| { | ||
| FailTest("FindService failed or returned wrong count. Error: ", find_result.error()); | ||
| } |
There was a problem hiding this comment.
find_result.error() will not exist if find_result->size() != 1 is the failing condition.
| @@ -0,0 +1,208 @@ | |||
| /******************************************************************************** | |||
There was a problem hiding this comment.
This file is never built. could be a duplicate of stop_offer_during_call.cpp?
| { | ||
| std::cout << "Could not create Instance specifier!.\n" | ||
| << "Here is why: " << instance_specifier_result.error() << "\n\n" | ||
| << std::flush; |
There was a problem hiding this comment.
FailTest should be added here
|
|
||
| auto async_result = | ||
| std::async(std::launch::async, [&proxy, test_input]() -> score::Result<MethodReturnTypePtr<std::int32_t>> { | ||
| while (true) |
There was a problem hiding this comment.
Maybe we should hardcode an upper limit of 1 Million iteration or sth. I know the test framework will interrupt long before that but this might get copy pasted to be executed in some other context
| return target.wrap_exec("./bin/stop_offer_during_call",args, | ||
| cwd="/opt/StopOfferDuringCallApp/", wait_on_exit=True, **kwargs) | ||
|
|
||
| def test_multiple_proxies(target, **kwargs): |
There was a problem hiding this comment.
| def test_multiple_proxies(target, **kwargs): | |
| def test_stop_offer_during_call(target, **kwargs): |
| load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") | ||
| load("//bazel/tools:json_schema_validator.bzl", "validate_json_schema_test") |
There was a problem hiding this comment.
this should be after the copyright?
| namespace | ||
| { | ||
| using namespace score::mw::com; | ||
| using namespace score::mw::com::test; |
There was a problem hiding this comment.
this could just be turned into
namespace score::mw::com::test {
| skeleton.StopOfferService(); | ||
| std::cout << "Step 4.4: StopOfferService was called while the method was still running\n" << std::flush; | ||
|
|
||
| ++repetiction_count; |
There was a problem hiding this comment.
| ++repetiction_count; | |
| ++repetition_count; |
| offer_service(skeleton); | ||
| } | ||
|
|
||
| if (repetiction_count == 0) |
There was a problem hiding this comment.
maybe this should be successful_repetition_count?
| } | ||
|
|
||
| template <typename ResultType> | ||
| void FailIfMethodCallDidNotFail(const std::string& method_name, const ResultType& call_result) |
There was a problem hiding this comment.
This is a nitpick, but the name has too much logic in it. Maybe name it sth without a negation, like FailOnUnexpectedSuccess?
| if (was_successfully_offered) | ||
| { | ||
| FailTest("ERROR: OfferService succeeded when it should have failed!"); | ||
| return; |
| std::cout << "\nConsumer: Step 10.1: Wait until proxy has reconnected to recreated skeleton" << std::endl; | ||
| // Since we have no way of being notified of the proxy being reconnected to the new skeleton, we keep calling a | ||
| // method in a loop until it succeeds. If it succeeded then it indicates that the proxy reconnected. | ||
| while (!consumer.GetProxy().without_args_or_return().has_value()) |
There was a problem hiding this comment.
should we add an upper bound to this loop just to be safe?
| int main(int argc, const char** argv) | ||
| { | ||
| score::mw::com::test::SetupAssertHandler(); | ||
| score::mw::com::runtime::InitializeRuntime(argc, argv); |
There was a problem hiding this comment.
This is the old runtime initializer, should we use the new one everywhere? Also in other tests...
|
|
||
| std::cout << "\nConsumer: Step 11: Call the same method again" << std::endl; | ||
| consumer.CallMethodWithInArgsAndReturn( | ||
| kTestValueA, kTestValueB, AllSignaturesMethodConsumer::CopyMode::WITH_COPY, kFailureMessagePrefix); |
There was a problem hiding this comment.
We could make one of these zero copy?
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| def test_edge_cases(target): | ||
| with target.wrap_exec("bin/incomplete_handlers_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: |
There was a problem hiding this comment.
| with target.wrap_exec("bin/incomplete_handlers_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: | |
| with target.wrap_exec("bin/incomplete_handlers_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True): |
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| def test_edge_cases(target): | ||
| with target.wrap_exec("bin/proxy_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: |
There was a problem hiding this comment.
| with target.wrap_exec("bin/proxy_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: | |
| with target.wrap_exec("bin/proxy_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True): |
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| def test_edge_cases(target): | ||
| with target.wrap_exec("bin/skeleton_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: |
There was a problem hiding this comment.
| with target.wrap_exec("bin/skeleton_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True) as process: | |
| with target.wrap_exec("bin/skeleton_recreation_test", cwd="/opt/EdgeCasesTestApp", wait_on_exit=True): |
| if (call_result.has_value()) | ||
| { | ||
| FailTest(kFailureMessagePrefix, " Consumer: ", method_name, " unexpectedly succeeded."); | ||
| return; |
| return; | ||
| } | ||
|
|
||
| std::cout << "Consumer: " << method_name << " failed as expected: " << call_result.error() << std::endl; |
There was a problem hiding this comment.
Technically we would need to disambiguate at call_result.error().
A method call could fail "propperly" with kBindingFailiure which is what we expect here. Or it could fail on this assertion, when we are trying to geth the queue_position.
| @@ -0,0 +1,90 @@ | |||
| { | |||
There was a problem hiding this comment.
this is identical to consumer_asil_b_to_asil_b_mw_com_config.json
I think it is confusing to have towo identical configurations that are named differently. we could have oine that is called asil_b_to_asil_b_mw_com_config.json
| @@ -0,0 +1,90 @@ | |||
| { | |||
There was a problem hiding this comment.
same comment as with provider_asil_b...
this file is identical to consumer_qm_to_qm... and should be deleted.
| Verifies that method calls are sent from consumer to provider with the correct values. | ||
| Verifies that the provider executes the correct handler on the provided values. | ||
| Verifies that the consumer receives the correct return values. |
There was a problem hiding this comment.
| Verifies that method calls are sent from consumer to provider with the correct values. | |
| Verifies that the provider executes the correct handler on the provided values. | |
| Verifies that the consumer receives the correct return values. |
There was a problem hiding this comment.
We should probably not have this here. It is not clear from the test name that these particular behaviors are verified. So someone could easily change the test behavior without knowing that these comments need to be updated
| Verifies that method calls are sent from consumer to provider with the correct values. | ||
| Verifies that the provider executes the correct handler on the provided values. | ||
| Verifies that the consumer receives the correct return values. |
There was a problem hiding this comment.
| Verifies that method calls are sent from consumer to provider with the correct values. | |
| Verifies that the provider executes the correct handler on the provided values. | |
| Verifies that the consumer receives the correct return values. |
| """ | ||
| def test_mixed_criticality_consumer_provider(target): | ||
| call_consumer_and_provider( | ||
| target, Criticality.QM, Criticality.QM, Criticality.QM) |
There was a problem hiding this comment.
| target, Criticality.QM, Criticality.QM, Criticality.QM) | |
| target, consumer_criticality=Criticality.QM, consumer_expects_criticality=Criticality.QM, provider_criticality=Criticality.QM) |
| FailTest( | ||
| "Methods mixed_criticality provider failed: WaitForProxyTestToFinish was stopped by " | ||
| "stop_token instead of notification"); | ||
| return; |
|
|
||
| /// \brief ASIL-B provider main entry point for mixed criticality method tests. | ||
|
|
There was a problem hiding this comment.
| /// \brief ASIL-B provider main entry point for mixed criticality method tests. |
There was a problem hiding this comment.
I think this information is contained in the file name
|
|
||
| int main(int argc, const char** argv) | ||
| { | ||
| auto service_instance_manifest_path = score::mw::com::test::ParseServiceInstanceManifest(argc, argv); |
| auto service_instance_manifest_path = score::mw::com::test::ParseServiceInstanceManifest(argc, argv); | ||
|
|
||
| score::mw::com::test::SetupAssertHandler(); | ||
| score::mw::com::runtime::InitializeRuntime(argc, argv); |
There was a problem hiding this comment.
instead of the legacy initializer we should use the new one which makes use of the service_instance_manifest_path
| provider_criticality: Criticality, | ||
| timeout_sec=60): |
There was a problem hiding this comment.
| provider_criticality: Criticality, | |
| timeout_sec=60): | |
| provider_criticality: Criticality): |
There was a problem hiding this comment.
this is no longer necessary with the current test framework
Depends-on: #479